A platform for community discussion. Free, open, simple.
DEV: Accquire file lock before checking if selenium webdriver cache (#25534)
Alan Guo Xiang Tan06b7a6bd59d3
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex 3969532bfe4..0c3b752f7ca 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -572,9 +572,10 @@ RSpec.configure do |config|## The long term fix here is to get `selenium-manager` to download the `chromedriver` binary to a unique path for each# process but the `--cache-path` option for `selenium-manager` is currently not supported in `selenium-webdriver`.- if !File.directory?(File.expand_path("~/.cache/selenium"))- File.open("#{Rails.root}/tmp/chrome_driver_flock", File::RDWR | File::CREAT, 0644) do |file|- file.flock(File::LOCK_EX)+ File.open("#{Rails.root}/tmp/chrome_driver_flock", File::RDWR | File::CREAT, 0644) do |file|+ file.flock(File::LOCK_EX)++ if !File.directory?(File.expand_path("~/.cache/selenium"))`#{Selenium::WebDriver::SeleniumManager.send(:binary)} --browser chrome`endend