mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Move chrome binary check into a shared lib (#13451)
We had checks for the chrome binary in 3 different places for tests and only one of them checked for google-chrome-stable, which is problematic for Arch linux users (there are dozens of us!) This PR moves all the code to one place and references it instead of copying and pasting.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "demon/rails_autospec"
|
||||
require 'rbconfig'
|
||||
require "chrome_installed_checker"
|
||||
|
||||
module Autospec
|
||||
|
||||
@@ -38,10 +38,8 @@ module Autospec
|
||||
|
||||
require "socket"
|
||||
|
||||
class ChromeNotInstalled < StandardError; end
|
||||
|
||||
def initialize
|
||||
ensure_chrome_is_installed
|
||||
ChromeInstalledChecker.run
|
||||
end
|
||||
|
||||
def start
|
||||
@@ -117,21 +115,6 @@ module Autospec
|
||||
|
||||
private
|
||||
|
||||
def ensure_chrome_is_installed
|
||||
if RbConfig::CONFIG['host_os'][/darwin|mac os/]
|
||||
binary = "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
|
||||
elsif system("command -v google-chrome-stable >/dev/null;")
|
||||
binary = "google-chrome-stable"
|
||||
end
|
||||
binary ||= "google-chrome" if system("command -v google-chrome >/dev/null;")
|
||||
|
||||
raise ChromeNotInstalled.new if !binary
|
||||
|
||||
if Gem::Version.new(`\"#{binary}\" --version`.match(/[\d\.]+/)[0]) < Gem::Version.new("59")
|
||||
raise "Chrome 59 or higher is required"
|
||||
end
|
||||
end
|
||||
|
||||
def port_available?(port)
|
||||
TCPServer.open(port).close
|
||||
true
|
||||
|
Reference in New Issue
Block a user