DEV: Add chromium to ChromeInstalledChecker (#16224)
This commit is contained in:
parent
508370e433
commit
bf8dc394bd
|
@ -3,8 +3,10 @@
|
||||||
require "rbconfig"
|
require "rbconfig"
|
||||||
|
|
||||||
class ChromeInstalledChecker
|
class ChromeInstalledChecker
|
||||||
class ChromeNotInstalled < StandardError; end
|
class ChromeError < StandardError; end
|
||||||
class ChromeVersionTooLow < StandardError; end
|
class ChromeVersionError < ChromeError; end
|
||||||
|
class ChromeNotInstalled < ChromeError; end
|
||||||
|
class ChromeVersionTooLow < ChromeError; end
|
||||||
|
|
||||||
def self.run
|
def self.run
|
||||||
if RbConfig::CONFIG['host_os'][/darwin|mac os/]
|
if RbConfig::CONFIG['host_os'][/darwin|mac os/]
|
||||||
|
@ -13,12 +15,20 @@ class ChromeInstalledChecker
|
||||||
binary = "google-chrome-stable"
|
binary = "google-chrome-stable"
|
||||||
end
|
end
|
||||||
binary ||= "google-chrome" if system("command -v google-chrome >/dev/null;")
|
binary ||= "google-chrome" if system("command -v google-chrome >/dev/null;")
|
||||||
|
binary ||= "chromium" if system("command -v chromium >/dev/null;")
|
||||||
|
|
||||||
if !binary
|
if !binary
|
||||||
raise ChromeNotInstalled.new("Chrome is not installed. Download from https://www.google.com/chrome/browser/desktop/index.html")
|
raise ChromeNotInstalled.new("Chrome is not installed. Download from https://www.google.com/chrome/browser/desktop/index.html")
|
||||||
end
|
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")
|
raise ChromeVersionTooLow.new("Chrome 59 or higher is required")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ChromeInstalledChecker.run
|
ChromeInstalledChecker.run
|
||||||
rescue ChromeNotInstalled, ChromeVersionTooLow => err
|
rescue ChromeInstalledChecker::ChromeError => err
|
||||||
abort err.message
|
abort err.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ task "smoke:test" do
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ChromeInstalledChecker.run
|
ChromeInstalledChecker.run
|
||||||
rescue ChromeNotInstalled, ChromeVersionTooLow => err
|
rescue ChromeInstalledChecker::ChromeError => err
|
||||||
abort err.message
|
abort err.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue