diagnostic: port to generic layer.
This commit is contained in:
parent
0e25fc0143
commit
9f74ca80af
@ -96,7 +96,7 @@ module Homebrew
|
||||
|
||||
<<-EOS.undent
|
||||
No developer tools installed.
|
||||
Install clang or gcc.
|
||||
#{DevelopmentTools.installation_instructions}
|
||||
EOS
|
||||
end
|
||||
|
||||
|
@ -48,70 +48,13 @@ module Homebrew
|
||||
EOS
|
||||
end
|
||||
|
||||
# TODO: distill down into single method definition a la BuildToolsError
|
||||
if MacOS.version >= "10.9"
|
||||
def check_for_installed_developer_tools
|
||||
return if MacOS::Xcode.installed? || MacOS::CLT.installed?
|
||||
|
||||
<<-EOS.undent
|
||||
No developer tools installed.
|
||||
Install the Command Line Tools:
|
||||
xcode-select --install
|
||||
EOS
|
||||
end
|
||||
|
||||
if OS::Mac.prerelease?
|
||||
def check_xcode_up_to_date
|
||||
return unless MacOS::Xcode.installed? && MacOS::Xcode.outdated?
|
||||
|
||||
<<-EOS.undent
|
||||
Your Xcode (#{MacOS::Xcode.version}) is outdated
|
||||
Please update to Xcode #{MacOS::Xcode.latest_version}.
|
||||
Xcode can be updated from
|
||||
https://developer.apple.com/xcode/downloads/
|
||||
EOS
|
||||
end
|
||||
else
|
||||
def check_xcode_up_to_date
|
||||
return unless MacOS::Xcode.installed? && MacOS::Xcode.outdated?
|
||||
|
||||
<<-EOS.undent
|
||||
Your Xcode (#{MacOS::Xcode.version}) is outdated
|
||||
Please update to Xcode #{MacOS::Xcode.latest_version}.
|
||||
Xcode can be updated from the App Store.
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def check_clt_up_to_date
|
||||
return unless MacOS::CLT.installed? && MacOS::CLT.outdated?
|
||||
|
||||
<<-EOS.undent
|
||||
A newer Command Line Tools release is available.
|
||||
Update them from Software Update in the App Store.
|
||||
EOS
|
||||
end
|
||||
elsif MacOS.version == "10.8" || MacOS.version == "10.7"
|
||||
def check_for_installed_developer_tools
|
||||
return if MacOS::Xcode.installed? || MacOS::CLT.installed?
|
||||
|
||||
<<-EOS.undent
|
||||
No developer tools installed.
|
||||
You should install the Command Line Tools.
|
||||
The standalone package can be obtained from
|
||||
https://developer.apple.com/downloads
|
||||
or it can be installed via Xcode's preferences.
|
||||
EOS
|
||||
end
|
||||
|
||||
def check_xcode_up_to_date
|
||||
return unless MacOS::Xcode.installed? && MacOS::Xcode.outdated?
|
||||
|
||||
<<-EOS.undent
|
||||
Your Xcode (#{MacOS::Xcode.version}) is outdated
|
||||
Please update to Xcode #{MacOS::Xcode.latest_version}.
|
||||
Xcode can be updated from
|
||||
https://developer.apple.com/xcode/downloads/
|
||||
#{MacOS::Xcode.update_instructions}
|
||||
EOS
|
||||
end
|
||||
|
||||
@ -120,33 +63,9 @@ module Homebrew
|
||||
|
||||
<<-EOS.undent
|
||||
A newer Command Line Tools release is available.
|
||||
The standalone package can be obtained from
|
||||
https://developer.apple.com/downloads
|
||||
or it can be installed via Xcode's preferences.
|
||||
#{MacOS::CLT.update_instructions}
|
||||
EOS
|
||||
end
|
||||
else
|
||||
def check_for_installed_developer_tools
|
||||
return if MacOS::Xcode.installed?
|
||||
|
||||
<<-EOS.undent
|
||||
Xcode is not installed. Most formulae need Xcode to build.
|
||||
It can be installed from
|
||||
https://developer.apple.com/xcode/downloads/
|
||||
EOS
|
||||
end
|
||||
|
||||
def check_xcode_up_to_date
|
||||
return unless MacOS::Xcode.installed? && MacOS::Xcode.outdated?
|
||||
|
||||
<<-EOS.undent
|
||||
Your Xcode (#{MacOS::Xcode.version}) is outdated
|
||||
Please update to Xcode #{MacOS::Xcode.latest_version}.
|
||||
Xcode can be updated from
|
||||
https://developer.apple.com/xcode/downloads/
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def check_for_osx_gcc_installer
|
||||
return unless MacOS.version < "10.7" || ((MacOS::Xcode.version || "0") > "4.1")
|
||||
|
@ -44,19 +44,6 @@ class DiagnosticChecksTest < Homebrew::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_check_for_other_package_managers
|
||||
MacOS.stubs(:macports_or_fink).returns ["fink"]
|
||||
assert_match "You have MacPorts or Fink installed:",
|
||||
@checks.check_for_other_package_managers
|
||||
end
|
||||
|
||||
def test_check_for_unsupported_osx
|
||||
ARGV.stubs(:homebrew_developer?).returns false
|
||||
OS::Mac.stubs(:prerelease?).returns true
|
||||
assert_match "We do not provide support for this pre-release version.",
|
||||
@checks.check_for_unsupported_osx
|
||||
end
|
||||
|
||||
def test_check_access_homebrew_repository
|
||||
mod = HOMEBREW_REPOSITORY.stat.mode & 0777
|
||||
HOMEBREW_REPOSITORY.chmod 0555
|
||||
@ -163,14 +150,6 @@ class DiagnosticChecksTest < Homebrew::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_check_for_unsupported_curl_vars
|
||||
MacOS.stubs(:version).returns OS::Mac::Version.new("10.10")
|
||||
ENV["SSL_CERT_DIR"] = "/some/path"
|
||||
|
||||
assert_match "SSL_CERT_DIR support was removed from Apple's curl.",
|
||||
@checks.check_for_unsupported_curl_vars
|
||||
end
|
||||
|
||||
def test_check_for_config_scripts
|
||||
mktmpdir do |path|
|
||||
file = "#{path}/foo-config"
|
||||
@ -226,9 +205,4 @@ class DiagnosticChecksTest < Homebrew::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_check_for_beta_xquartz
|
||||
MacOS::XQuartz.stubs(:version).returns("2.7.10_beta2")
|
||||
assert_match "The following beta release of XQuartz is installed: 2.7.10_beta2", @checks.check_for_beta_xquartz
|
||||
end
|
||||
end
|
||||
|
41
Library/Homebrew/test/test_os_mac_diagnostic.rb
Normal file
41
Library/Homebrew/test/test_os_mac_diagnostic.rb
Normal file
@ -0,0 +1,41 @@
|
||||
require "testing_env"
|
||||
require "fileutils"
|
||||
require "pathname"
|
||||
require "diagnostic"
|
||||
|
||||
class OSMacDiagnosticChecksTest < Homebrew::TestCase
|
||||
def setup
|
||||
@env = ENV.to_hash
|
||||
@checks = Homebrew::Diagnostic::Checks.new
|
||||
end
|
||||
|
||||
def teardown
|
||||
ENV.replace(@env)
|
||||
end
|
||||
|
||||
def test_check_for_other_package_managers
|
||||
MacOS.stubs(:macports_or_fink).returns ["fink"]
|
||||
assert_match "You have MacPorts or Fink installed:",
|
||||
@checks.check_for_other_package_managers
|
||||
end
|
||||
|
||||
def test_check_for_unsupported_osx
|
||||
ARGV.stubs(:homebrew_developer?).returns false
|
||||
OS::Mac.stubs(:prerelease?).returns true
|
||||
assert_match "We do not provide support for this pre-release version.",
|
||||
@checks.check_for_unsupported_osx
|
||||
end
|
||||
|
||||
def test_check_for_unsupported_curl_vars
|
||||
MacOS.stubs(:version).returns OS::Mac::Version.new("10.10")
|
||||
ENV["SSL_CERT_DIR"] = "/some/path"
|
||||
|
||||
assert_match "SSL_CERT_DIR support was removed from Apple's curl.",
|
||||
@checks.check_for_unsupported_curl_vars
|
||||
end
|
||||
|
||||
def test_check_for_beta_xquartz
|
||||
MacOS::XQuartz.stubs(:version).returns("2.7.10_beta2")
|
||||
assert_match "The following beta release of XQuartz is installed: 2.7.10_beta2", @checks.check_for_beta_xquartz
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user