Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 51985:a8e1ff9ac257
tests: fix a test hang on Windows when setting a debuglock
I have no idea why, but running the `hg -R auto-upgrade debuglock --set-lock`
command near the end of `test-upgrade-repo.t` hangs the test. It does
background the process and `killdaemons.py` runs without error, but control
doesn't return to `run-tests.py` until the process is manually killed. I did
notice that `$!` in MSYS is *not* the PID of the process that got backgrounded,
even when a simple `sleep 60 &` is run in MSYS without the *.t file. When
`killdaemons.py` is run manually with the PID in ProcessExplorer, the
backgrounded process terminates immediately, and returns control to
`run-tests.py`.
This looks like it would be a race, but the test waits 10s for the lock file to
appear before attempting to kill the process, so there's time. `hg serve` has a
`--pid-file` option to write the pid to the file, but this is only a debug
command, so I'm not bothering with cluttering the command line.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 03 Oct 2024 21:08:10 -0400 |
parents | 8d9767bf4adb |
children | a021da4ec509 |
comparison
equal
deleted
inserted
replaced
51984:ed90f4a1bb2c | 51985:a8e1ff9ac257 |
---|---|
2236 if opts.get('force_free_lock') or opts.get('force_free_wlock'): | 2236 if opts.get('force_free_lock') or opts.get('force_free_wlock'): |
2237 return 0 | 2237 return 0 |
2238 | 2238 |
2239 locks = [] | 2239 locks = [] |
2240 try: | 2240 try: |
2241 # Help the tests out on Windows by writing the correct PID when | |
2242 # invoked by the test harness, before creating the lock. | |
2243 pids = encoding.environ.get(b'DAEMON_PIDS') | |
2244 if pids: | |
2245 with open(pids, "ab") as fp: | |
2246 fp.write(b'%d\n' % os.getpid()) | |
2247 | |
2241 if opts.get('set_wlock'): | 2248 if opts.get('set_wlock'): |
2242 try: | 2249 try: |
2243 locks.append(repo.wlock(False)) | 2250 locks.append(repo.wlock(False)) |
2244 except error.LockHeld: | 2251 except error.LockHeld: |
2245 raise error.Abort(_(b'wlock is already held')) | 2252 raise error.Abort(_(b'wlock is already held')) |