aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2016-07-16 21:03:12 +0100
committerMike McQuaid2016-07-27 15:05:42 -0600
commit9f74ca80af828196ea9c5f23dcd5ffd81817927d (patch)
tree4cc23c254108f0301219dc0e89e09dd703fe1fc2
parent0e25fc01430ae10cc5638d9b0ae9c1784821d2c0 (diff)
downloadbrew-9f74ca80af828196ea9c5f23dcd5ffd81817927d.tar.bz2
diagnostic: port to generic layer.
-rw-r--r--Library/Homebrew/diagnostic.rb2
-rw-r--r--Library/Homebrew/extend/os/mac/diagnostic.rb109
-rw-r--r--Library/Homebrew/test/test_diagnostic.rb26
-rw-r--r--Library/Homebrew/test/test_os_mac_diagnostic.rb41
4 files changed, 56 insertions, 122 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index 4954cde7b..62f63b34f 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -96,7 +96,7 @@ module Homebrew
<<-EOS.undent
No developer tools installed.
- Install clang or gcc.
+ #{DevelopmentTools.installation_instructions}
EOS
end
diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb
index 739c8018f..120e5d15c 100644
--- a/Library/Homebrew/extend/os/mac/diagnostic.rb
+++ b/Library/Homebrew/extend/os/mac/diagnostic.rb
@@ -48,104 +48,23 @@ 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?
+ def check_xcode_up_to_date
+ return unless MacOS::Xcode.installed? && MacOS::Xcode.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/
- EOS
- 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.
- The standalone package can be obtained from
- https://developer.apple.com/downloads
- or it can be installed via Xcode's preferences.
- 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
+ <<-EOS.undent
+ Your Xcode (#{MacOS::Xcode.version}) is outdated
+ Please update to Xcode #{MacOS::Xcode.latest_version}.
+ #{MacOS::Xcode.update_instructions}
+ EOS
+ end
- def check_xcode_up_to_date
- return unless MacOS::Xcode.installed? && MacOS::Xcode.outdated?
+ def check_clt_up_to_date
+ return unless MacOS::CLT.installed? && MacOS::CLT.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
+ <<-EOS.undent
+ A newer Command Line Tools release is available.
+ #{MacOS::CLT.update_instructions}
+ EOS
end
def check_for_osx_gcc_installer
diff --git a/Library/Homebrew/test/test_diagnostic.rb b/Library/Homebrew/test/test_diagnostic.rb
index 0e0d110e7..2974b0590 100644
--- a/Library/Homebrew/test/test_diagnostic.rb
+++ b/Library/Homebrew/test/test_diagnostic.rb
@@ -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
diff --git a/Library/Homebrew/test/test_os_mac_diagnostic.rb b/Library/Homebrew/test/test_os_mac_diagnostic.rb
new file mode 100644
index 000000000..a52179ac6
--- /dev/null
+++ b/Library/Homebrew/test/test_os_mac_diagnostic.rb
@@ -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