mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:44:49 +08:00
DEV: Add chromium to ChromeInstalledChecker (#16224)
This commit is contained in:
parent
508370e433
commit
bf8dc394bd
|
@ -3,8 +3,10 @@
|
|||
require "rbconfig"
|
||||
|
||||
class ChromeInstalledChecker
|
||||
class ChromeNotInstalled < StandardError; end
|
||||
class ChromeVersionTooLow < StandardError; end
|
||||
class ChromeError < StandardError; end
|
||||
class ChromeVersionError < ChromeError; end
|
||||
class ChromeNotInstalled < ChromeError; end
|
||||
class ChromeVersionTooLow < ChromeError; end
|
||||
|
||||
def self.run
|
||||
if RbConfig::CONFIG['host_os'][/darwin|mac os/]
|
||||
|
@ -13,12 +15,20 @@ class ChromeInstalledChecker
|
|||
binary = "google-chrome-stable"
|
||||
end
|
||||
binary ||= "google-chrome" if system("command -v google-chrome >/dev/null;")
|
||||
binary ||= "chromium" if system("command -v chromium >/dev/null;")
|
||||
|
||||
if !binary
|
||||
raise ChromeNotInstalled.new("Chrome is not installed. Download from https://www.google.com/chrome/browser/desktop/index.html")
|
||||
end
|
||||
|
||||
if Gem::Version.new(`\"#{binary}\" --version`.match(/[\d\.]+/)[0]) < Gem::Version.new("59")
|
||||
version = `\"#{binary}\" --version`
|
||||
version_match = version.match(/[\d\.]+/)
|
||||
|
||||
if !version_match
|
||||
raise ChromeError.new("Can't get the #{binary} version")
|
||||
end
|
||||
|
||||
if Gem::Version.new(version_match[0]) < Gem::Version.new("59")
|
||||
raise ChromeVersionTooLow.new("Chrome 59 or higher is required")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
|||
|
||||
begin
|
||||
ChromeInstalledChecker.run
|
||||
rescue ChromeNotInstalled, ChromeVersionTooLow => err
|
||||
rescue ChromeInstalledChecker::ChromeError => err
|
||||
abort err.message
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ task "smoke:test" do
|
|||
|
||||
begin
|
||||
ChromeInstalledChecker.run
|
||||
rescue ChromeNotInstalled, ChromeVersionTooLow => err
|
||||
rescue ChromeInstalledChecker::ChromeError => err
|
||||
abort err.message
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user