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.
This commit is contained in:
parent
c5520d0050
commit
ddb576b582
@ -55,8 +55,6 @@ class Hardware
|
|||||||
elsif OS.linux?
|
elsif OS.linux?
|
||||||
require "os/linux/hardware"
|
require "os/linux/hardware"
|
||||||
CPU.extend LinuxCPUs
|
CPU.extend LinuxCPUs
|
||||||
else
|
|
||||||
raise "The system `#{`uname`.chomp}' is not supported."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.cores_as_words
|
def self.cores_as_words
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module OS
|
module OS
|
||||||
def self.mac?
|
def self.mac?
|
||||||
/darwin/i === RUBY_PLATFORM
|
/darwin/i === RUBY_PLATFORM && !ENV["HOMEBREW_TEST_GENERIC_OS"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.linux?
|
def self.linux?
|
||||||
@ -19,9 +19,5 @@ module OS
|
|||||||
elsif OS.linux?
|
elsif OS.linux?
|
||||||
ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting"
|
ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting"
|
||||||
PATH_OPEN = "xdg-open"
|
PATH_OPEN = "xdg-open"
|
||||||
# compatibility
|
|
||||||
::MACOS_FULL_VERSION = ::MACOS_VERSION = "0"
|
|
||||||
else
|
|
||||||
raise "Unknown operating system"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,6 +12,8 @@ module OS
|
|||||||
|
|
||||||
::MacOS = self # compatibility
|
::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
|
# This can be compared to numerics, strings, or symbols
|
||||||
# using the standard Ruby Comparable methods.
|
# using the standard Ruby Comparable methods.
|
||||||
def version
|
def version
|
||||||
|
@ -448,7 +448,9 @@ def exec_editor(*args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def exec_browser(*args)
|
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)
|
safe_exec(browser, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ rescue RuntimeError, SystemCallError => e
|
|||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
Utils::Analytics.report_exception(e)
|
Utils::Analytics.report_exception(e)
|
||||||
onoe e
|
onoe e
|
||||||
if internal_cmd
|
if internal_cmd && defined?(ISSUES_URL)
|
||||||
$stderr.puts "#{Tty.white}Please report this bug:"
|
$stderr.puts "#{Tty.white}Please report this bug:"
|
||||||
$stderr.puts " #{Tty.em}#{OS::ISSUES_URL}#{Tty.reset}"
|
$stderr.puts " #{Tty.em}#{OS::ISSUES_URL}#{Tty.reset}"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user