DEV: Fix system tests stuck on flock (#25495)

Why this change?

In workflow runs, we have seen processes being stuck on a flock lock and
I'm guessing because we are using `"w"` when opening the file which the
ruby documentation advises against as it states "don't use "w" because it truncates the file before lock."

Stuck workflow run: https://github.com/discourse/discourse/actions/runs/7690278010/job/20953851469
This commit is contained in:
Alan Guo Xiang Tan 2024-01-31 11:11:40 +08:00 committed by GitHub
parent f0e9a6fd0a
commit 0bd3e03144
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -573,7 +573,7 @@ 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", "w") do |file|
File.open("#{Rails.root}/tmp/chrome_driver_flock", File::RDWR | File::CREAT, 0644) do |file|
file.flock(File::LOCK_EX)
`#{Selenium::WebDriver::SeleniumManager.send(:binary)} --browser chrome`
end