grosser / parallel_tests

Ruby: 2 CPUs = 2x Testing Speed for RSpec, Test::Unit and Cucumber
3.38k stars 495 forks source link

Race Condition in Cucumber FailuresLogger #824

Open stefxzhou opened 3 years ago

stefxzhou commented 3 years ago

Found a race condition in FailuresLogger (prepare_io), where it first cleans out the existing log file before appending. The same step to clean out the existing log file is also done in Cucumber::Formatter::Rerun.

When running the tests in parallel, the initialize call of process B can overwrite the failed scenario that were logged by process A that finished eariler, resulting in not all of the failed scenarios being logged at the end.

grosser commented 3 years ago

Yeah, we might be able to do something like lock the file and then check it's mtime to decide if it needs cleaning or make all processes wait until the first process has cleaned it, PR welcome!

oehlschl commented 11 months ago

I've experienced the same, with ParallelTests::Cucumber::FailuresLogger specifically. Often, the failures recorded in the fail are incomplete, or occasionally missing all together. Thanks for the report to validate that this is indeed an issue.