summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2014-08-25 13:46:08 +1200
committerRobert Collins <robertc@robertcollins.net>2014-08-25 13:46:08 +1200
commitbc52d7cc0cc138161b5329cd1fc64f344e3f62f8 (patch)
treef026c34bfff527e666e921ada2ed62096d762919
parent6419a3dcaabaf09eaf438c6d8d85c90eba7a2b91 (diff)
downloadtestrepository-bc52d7cc0cc138161b5329cd1fc64f344e3f62f8.tar.gz
Tests will be reliably tagged with worker-%d.
The previous tagging logic had an implicit race - the tag id was looked up via a closure which gets the state of the pos variable at the position the overall loop has advanced too, not the position when the closure was created. Closes-Bug: #1316858
-rw-r--r--NEWS9
-rw-r--r--testrepository/commands/load.py7
2 files changed, 13 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index e7f1b1f..a990724 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,15 @@ testrepository release notes
NEXT (In development)
+++++++++++++++++++++
+IMPROVEMENTS
+-------
+
+* Tests will be reliably tagged with worker-%d. The previous tagging logic
+ had an implicit race - the tag id was looked up via a closure which gets
+ the state of the pos variable at the position the overall loop has advanced
+ too, not the position when the closure was created.
+ (Robert Collins, #1316858)
+
0.0.19
++++++
diff --git a/testrepository/commands/load.py b/testrepository/commands/load.py
index 0ca4688..1d52965 100644
--- a/testrepository/commands/load.py
+++ b/testrepository/commands/load.py
@@ -100,6 +100,8 @@ class load(Command):
streams = map(opener, self.ui.arguments['streams'])
else:
streams = self.ui.iter_streams('subunit')
+ mktagger = lambda pos, result:testtools.StreamTagger(
+ [result], add=['worker-%d' % pos])
def make_tests():
for pos, stream in enumerate(streams):
if v2_avail:
@@ -121,9 +123,8 @@ class load(Command):
case = testtools.DecorateTestCaseResult(case, wrap_result,
methodcaller('startTestRun'),
methodcaller('stopTestRun'))
- case = testtools.DecorateTestCaseResult(case,
- lambda result:testtools.StreamTagger(
- [result], add=['worker-%d' % pos]))
+ decorate = partial(mktagger, pos)
+ case = testtools.DecorateTestCaseResult(case, decorate)
yield (case, str(pos))
case = testtools.ConcurrentStreamTestSuite(make_tests)
# One unmodified copy of the stream to repository storage