run-tests: exit 80 if all tests are skipped

Summary:
This can be used by a wrapper script running a single test
to detect whether the test is skipped or not.

Reviewed By: DurhamG, phillco

Differential Revision: D6879864

fbshipit-source-id: 8bc535fccdbc6ad32eec870bd9e503b6f84f694b
This commit is contained in:
Jun Wu 2018-02-02 12:17:39 -08:00 committed by Saurabh Singh
parent fbaa53a84a
commit 8e2207b7e6
2 changed files with 9 additions and 2 deletions

View File

@ -2150,6 +2150,7 @@ class TextTestRunner(unittest.TextTestRunner):
self.stream.writeln(
'# Ran %d tests, %d skipped, %d failed.'
% (result.testsRun, skipped + ignored, failed))
result.testsSkipped = skipped + ignored
if failed:
self.stream.writeln('python hash seed: %s' %
os.environ['PYTHONHASHSEED'])
@ -2634,6 +2635,8 @@ class TestRunner(object):
desc['case'] = case
return self._gettest(desc, i)
failed = False
allskipped = False
try:
if self.options.restart:
orig = list(testdescs)
@ -2654,7 +2657,6 @@ class TestRunner(object):
tests = [self._gettest(d, i) for i, d in enumerate(testdescs)]
failed = False
kws = self.options.keywords
if kws is not None and PYTHON3:
kws = kws.encode('utf-8')
@ -2689,6 +2691,8 @@ class TestRunner(object):
self._usecorrecthg()
result = runner.run(suite)
if tests and result.testsSkipped == len(tests):
allskipped = True
if result.failures:
failed = True
@ -2701,6 +2705,8 @@ class TestRunner(object):
if failed:
return 1
elif allskipped:
return Test.SKIPPED_STATUS
def _getport(self, count):
port = self._ports.get(count) # do we have a cached entry?

View File

@ -23,7 +23,6 @@ error paths
#if symlink
$ ln -s `which true` hg
$ run-tests.py --with-hg=./hg
warning: --with-hg should specify an hg script
# Ran 0 tests, 0 skipped, 0 failed.
$ rm hg
@ -953,6 +952,7 @@ Missing skips or blacklisted skips don't count as executed:
Skipped test-bogus.t: Doesn't exist
Skipped test-failure.t: blacklisted
# Ran 0 tests, 2 skipped, 0 failed.
[80]
$ cat report.json
testreport ={
"test-bogus.t": {
@ -1259,6 +1259,7 @@ test support for --allow-slow-tests
s
Skipped test-very-slow-test.t: missing feature: allow slow tests (use --allow-slow-tests)
# Ran 0 tests, 1 skipped, 0 failed.
[80]
$ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t
.
# Ran 1 tests, 0 skipped, 0 failed.