run-tests: send the test result after freeing the channel stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 24 May 2022 09:57:53 +0200
branchstable
changeset 49214 eca367970253
parent 49213 c95e5ba4de1e
child 49215 8d31ef3017c9
run-tests: send the test result after freeing the channel Sending the message about the test being "done" signals to the main thread that a new test can be started. Before this changeset, we sent this signal before freeing the channel, there is room for a race condition where a new test would search for a channel before the old test freed the one it used. This is an example of the failure it would produce: https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/552404
tests/run-tests.py
--- a/tests/run-tests.py	Tue May 24 09:36:40 2022 +0200
+++ b/tests/run-tests.py	Tue May 24 09:57:53 2022 +0200
@@ -2563,19 +2563,21 @@
             else:
                 raise ValueError('Could not find output channel')
             channels[channel] = "=" + test.name[5:].split(".")[0]
+
+            r = None
             try:
                 test(result)
-                done.put(None)
             except KeyboardInterrupt:
-                done.put(None)
+                pass
             except:  # re-raises
-                done.put(('!', test, 'run-test raised an error, see traceback'))
+                r = ('!', test, 'run-test raised an error, see traceback')
                 raise
             finally:
                 try:
                     channels[channel] = ''
                 except IndexError:
                     pass
+                done.put(r)
 
         def stat():
             count = 0