smartdispatch icon indicating copy to clipboard operation
smartdispatch copied to clipboard

Improve unit test for open_with_lock

Open MarcCote opened this issue 11 years ago • 0 comments

Find a cleaner way to test the open_with_lock function. Right now we rely on causing race conditions using time.sleep. The procedure is as follow:

  1. a file is locked in the main process, launch a new process and goes to sleep for T seconds.
  2. the other (newly created) process tries to lock the same file which raises a warning and gets blocked.
  3. after T seconds, the main process wakes up, release the lock and wait for the other process to finish.
  4. then, the unit test looks at the stderr of the other process and confirms that a warning have indeed been raised (read: successfully waited for the lock to be removed before resuming its execution).

EDIT: Added precision about what is done right now.

MarcCote avatar Sep 25 '14 20:09 MarcCote