grosser / parallel_tests

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

Suggestion: Add an UUID in ENV which is shared by the parallels #278

Open ghost opened 10 years ago

ghost commented 10 years ago

It might be a good idea to add an UUID to ENV so that all spawned processes in the same parallel run could see the same UUID. That would enable us to use that UUID for e.g. file locks when something needs to be mutexed between the parallels.

For example, I'm currently writing a parallel-aware formatter for Cucumber which would buffer output for a whole scenario and dump it at each scenario end, but the "dumping" part would have to be in a mutex so that lines don't get mixed up. Or is such a feature already implemented (some ident that all parallels in the same run share, but is different between individual runs)?

grosser commented 10 years ago

Hmm sounds interesting, how about parent process id -> PARALLEL_PPID ?

abotalov commented 9 years ago

Sounds like a good idea to me.

I also have a similar use case (each run has the unique lock file that is written by first process and is shared with processes of the same run. Processes of the other run should have another lock file).

grosser commented 9 years ago

this works:

def ppid(pid)
  `ps -p #{pid} -o ppid=`.strip
end

ppid(ppid(Process.pid))

but adding the PARALLEL_PID could also be nice, please open a PR if you care :)