aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-04-25 17:53:43 +0100
committerMike McQuaid2016-05-08 16:51:22 +0100
commitddb576b582ddc801ac702566bacbc2f231fc86af (patch)
tree797a86d0cdd540a5f0b8ad3995abe43aea17f2b9 /Library
parentc5520d0050e3a5a9050314daf643b298a5432d67 (diff)
downloadbrew-ddb576b582ddc801ac702566bacbc2f231fc86af.tar.bz2
Add support for testing generic OS.
If the environment variable HOMEBREW_TEST_GENERIC_OS is set ensure that neither Mac nor Linux-specific code is loaded. This allows easier testing of cross-platform code on OS X and will make it easier to port Homebrew to platforms other than OS X and Linux.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/hardware.rb2
-rw-r--r--Library/Homebrew/os.rb6
-rw-r--r--Library/Homebrew/os/mac.rb2
-rw-r--r--Library/Homebrew/utils.rb4
-rw-r--r--Library/brew.rb2
5 files changed, 7 insertions, 9 deletions
diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb
index f7a21ebd8..7ffd8714b 100644
--- a/Library/Homebrew/hardware.rb
+++ b/Library/Homebrew/hardware.rb
@@ -55,8 +55,6 @@ class Hardware
elsif OS.linux?
require "os/linux/hardware"
CPU.extend LinuxCPUs
- else
- raise "The system `#{`uname`.chomp}' is not supported."
end
def self.cores_as_words
diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb
index b0d685fa4..63c86b7f4 100644
--- a/Library/Homebrew/os.rb
+++ b/Library/Homebrew/os.rb
@@ -1,6 +1,6 @@
module OS
def self.mac?
- /darwin/i === RUBY_PLATFORM
+ /darwin/i === RUBY_PLATFORM && !ENV["HOMEBREW_TEST_GENERIC_OS"]
end
def self.linux?
@@ -19,9 +19,5 @@ module OS
elsif OS.linux?
ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting"
PATH_OPEN = "xdg-open"
- # compatibility
- ::MACOS_FULL_VERSION = ::MACOS_VERSION = "0"
- else
- raise "Unknown operating system"
end
end
diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb
index 73e499d40..98053f4ba 100644
--- a/Library/Homebrew/os/mac.rb
+++ b/Library/Homebrew/os/mac.rb
@@ -12,6 +12,8 @@ module OS
::MacOS = self # compatibility
+ raise "Loaded OS::Mac on generic OS!" if ENV["HOMEBREW_TEST_GENERIC_OS"]
+
# This can be compared to numerics, strings, or symbols
# using the standard Ruby Comparable methods.
def version
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 84bfb59b0..6502d5070 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -448,7 +448,9 @@ def exec_editor(*args)
end
def exec_browser(*args)
- browser = ENV["HOMEBREW_BROWSER"] || ENV["BROWSER"] || OS::PATH_OPEN
+ browser = ENV["HOMEBREW_BROWSER"] || ENV["BROWSER"]
+ browser ||= OS::PATH_OPEN if defined?(OS::PATH_OPEN)
+ return unless browser
safe_exec(browser, *args)
end
diff --git a/Library/brew.rb b/Library/brew.rb
index b72e24d3d..ba5857a76 100644
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -141,7 +141,7 @@ rescue RuntimeError, SystemCallError => e
rescue Exception => e
Utils::Analytics.report_exception(e)
onoe e
- if internal_cmd
+ if internal_cmd && defined?(ISSUES_URL)
$stderr.puts "#{Tty.white}Please report this bug:"
$stderr.puts " #{Tty.em}#{OS::ISSUES_URL}#{Tty.reset}"
end