view tests/test-status-inprocess.py @ 24507:a0668a587c04

run-tests: wait for test threads after first error The test runner has the ability to stop on first error. Tests are executed in new Python threads. The test runner starts new threads when it has capacity to do so. Before this patch, the "stop on first error" logic would return immediately from the "run tests" function, without waiting on test threads to complete. There was thus a race between the test runner thread doing cleanup work and the test thread performing activity. For example, the test thread could be in the middle of executing a test shell script and the test runner could remove the test's temporary directory. Depending on timing, this could result in any number of output from the test runner. This patch eliminates the race condition by having the test runner explicitly wait for test threads to complete before continuing. I discovered this issue as I modified the test harness in a subsequent patch and was reliably able to tickle the race condition.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 28 Mar 2015 19:39:03 -0700
parents 13a1b2fb7ef2
children 7779f9dfd938
line wrap: on
line source

#!/usr/bin/python
from mercurial.ui import ui
from mercurial.localrepo import localrepository
from mercurial.commands import add, commit, status

u = ui()

print '% creating repo'
repo = localrepository(u, '.', create=True)

f = open('test.py', 'w')
try:
    f.write('foo\n')
finally:
    f.close

print '% add and commit'
add(u, repo, 'test.py')
commit(u, repo, message='*')
status(u, repo, clean=True)


print '% change'
f = open('test.py', 'w')
try:
    f.write('bar\n')
finally:
    f.close()

# this would return clean instead of changed before the fix
status(u, repo, clean=True, modified=True)