##// END OF EJS Templates
run-tests: fix test result counts with --keyword specified or skips occurring...
Augie Fackler -
r21997:93c3b3f5 default
parent child Browse files
Show More
@@ -460,8 +460,15 b' class Test(unittest.TestCase):'
460 raise
460 raise
461 except SkipTest, e:
461 except SkipTest, e:
462 result.addSkip(self, str(e))
462 result.addSkip(self, str(e))
463 # The base class will have already counted this as a
464 # test we "ran", but we want to exclude skipped tests
465 # from those we count towards those run.
466 result.testsRun -= 1
463 except IgnoreTest, e:
467 except IgnoreTest, e:
464 result.addIgnore(self, str(e))
468 result.addIgnore(self, str(e))
469 # As with skips, ignores also should be excluded from
470 # the number of tests executed.
471 result.testsRun -= 1
465 except WarnTest, e:
472 except WarnTest, e:
466 result.addWarn(self, str(e))
473 result.addWarn(self, str(e))
467 except self.failureException, e:
474 except self.failureException, e:
@@ -1101,7 +1108,6 b' class TestResult(unittest._TextTestResul'
1101 # Polyfill.
1108 # Polyfill.
1102 def addSkip(self, test, reason):
1109 def addSkip(self, test, reason):
1103 self.skipped.append((test, reason))
1110 self.skipped.append((test, reason))
1104
1105 if self.showAll:
1111 if self.showAll:
1106 self.stream.writeln('skipped %s' % reason)
1112 self.stream.writeln('skipped %s' % reason)
1107 else:
1113 else:
@@ -1110,12 +1116,13 b' class TestResult(unittest._TextTestResul'
1110
1116
1111 def addIgnore(self, test, reason):
1117 def addIgnore(self, test, reason):
1112 self.ignored.append((test, reason))
1118 self.ignored.append((test, reason))
1113
1114 if self.showAll:
1119 if self.showAll:
1115 self.stream.writeln('ignored %s' % reason)
1120 self.stream.writeln('ignored %s' % reason)
1116 else:
1121 else:
1117 if reason != 'not retesting':
1122 if reason != 'not retesting':
1118 self.stream.write('i')
1123 self.stream.write('i')
1124 else:
1125 self.testsRun += 1
1119 self.stream.flush()
1126 self.stream.flush()
1120
1127
1121 def addWarn(self, test, reason):
1128 def addWarn(self, test, reason):
@@ -1339,18 +1346,8 b' class TextTestRunner(unittest.TextTestRu'
1339
1346
1340 self._runner._checkhglib('Tested')
1347 self._runner._checkhglib('Tested')
1341
1348
1342 # When '--retest' is enabled, only failure tests run. At this point
1343 # "result.testsRun" holds the count of failure test that has run. But
1344 # as while printing output, we have subtracted the skipped and ignored
1345 # count from "result.testsRun". Therefore, to make the count remain
1346 # the same, we need to add skipped and ignored count in here.
1347 if self._runner.options.retest:
1348 result.testsRun = result.testsRun + skipped + ignored
1349
1350 # This differs from unittest's default output in that we don't count
1351 # skipped and ignored tests as part of the total test count.
1352 self.stream.writeln('# Ran %d tests, %d skipped, %d warned, %d failed.'
1349 self.stream.writeln('# Ran %d tests, %d skipped, %d warned, %d failed.'
1353 % (result.testsRun - skipped - ignored,
1350 % (result.testsRun,
1354 skipped + ignored, warned, failed))
1351 skipped + ignored, warned, failed))
1355 if failed:
1352 if failed:
1356 self.stream.writeln('python hash seed: %s' %
1353 self.stream.writeln('python hash seed: %s' %
@@ -66,7 +66,7 b' test for --retest'
66 ERROR: test-failure.t output changed
66 ERROR: test-failure.t output changed
67 !
67 !
68 Failed test-failure.t: output changed
68 Failed test-failure.t: output changed
69 # Ran 1 tests, 1 skipped, 0 warned, 1 failed.
69 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
70 python hash seed: * (glob)
70 python hash seed: * (glob)
71 [1]
71 [1]
72
72
@@ -79,6 +79,11 b' successful'
79 .
79 .
80 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
80 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
81
81
82 success w/ keyword
83 $ $TESTDIR/run-tests.py --with-hg=`which hg` -k xyzzy
84 i.
85 # Ran 1 tests, 1 skipped, 0 warned, 0 failed.
86
82 failed
87 failed
83
88
84 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-failure.t
89 $ $TESTDIR/run-tests.py --with-hg=`which hg` test-failure.t
@@ -99,6 +104,25 b' failed'
99 python hash seed: * (glob)
104 python hash seed: * (glob)
100 [1]
105 [1]
101
106
107 failure w/ keyword
108 $ $TESTDIR/run-tests.py --with-hg=`which hg` -k rataxes
109 i
110 --- $TESTTMP/test-failure.t
111 +++ $TESTTMP/test-failure.t.err
112 @@ -1,4 +1,4 @@
113 $ echo babar
114 - rataxes
115 + babar
116 This is a noop statement so that
117 this test is still more bytes than success.
118
119 ERROR: test-failure.t output changed
120 !
121 Failed test-failure.t: output changed
122 # Ran 1 tests, 1 skipped, 0 warned, 1 failed.
123 python hash seed: * (glob)
124 [1]
125
102 Running In Debug Mode
126 Running In Debug Mode
103 ======================
127 ======================
104
128
@@ -262,3 +286,17 b' Skips'
262 python hash seed: * (glob)
286 python hash seed: * (glob)
263 [1]
287 [1]
264
288
289 $ $TESTDIR/run-tests.py --with-hg=`which hg` --keyword xyzzy
290 i.s
291 Skipped test-skip.t: irrelevant
292 # Ran 1 tests, 2 skipped, 0 warned, 0 failed.
293
294 Missing skips or blacklisted skips don't count as executed:
295 $ echo test-failure.t > blacklist
296 $ $TESTDIR/run-tests.py --with-hg=`which hg` --blacklist=blacklist \
297 > test-failure.t test-bogus.t
298 ss
299 Skipped test-bogus.t: Doesn't exist
300 Skipped test-failure.t: blacklisted
301 # Ran 0 tests, 2 skipped, 0 warned, 0 failed.
302
General Comments 0
You need to be logged in to leave comments. Login now