run-tests: print number of tests and parallel process count
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 13 Oct 2018 12:11:45 +0200
changeset 40244 1039404c5e1d
parent 40243 96e50dfd8c94
child 40245 e7e70c033783
run-tests: print number of tests and parallel process count This seems like a useful output message to have. I also sneak in a change to lower the parallel process count if it is larger than the number of tests, as that makes no sense and output saying we're running more tests in parallel than there exists tests would be wonky. Differential Revision: https://phab.mercurial-scm.org/D5070
tests/run-tests.py
tests/test-run-tests.t
--- a/tests/run-tests.py	Sat Oct 13 12:29:43 2018 +0200
+++ b/tests/run-tests.py	Sat Oct 13 12:11:45 2018 +0200
@@ -2795,13 +2795,15 @@
 
             tests = [self._gettest(d, i) for i, d in enumerate(testdescs)]
 
+            jobs = min(len(tests), self.options.jobs)
+
             failed = False
             kws = self.options.keywords
             if kws is not None and PYTHON3:
                 kws = kws.encode('utf-8')
 
             suite = TestSuite(self._testdir,
-                              jobs=self.options.jobs,
+                              jobs=jobs,
                               whitelist=self.options.whitelisted,
                               blacklist=self.options.blacklist,
                               retest=self.options.retest,
@@ -2829,6 +2831,9 @@
                     assert self._installdir
                     self._installchg()
 
+                log('running %d tests using %d parallel processes' % (
+                    len(tests), jobs))
+
                 result = runner.run(suite)
 
             if result.failures:
--- a/tests/test-run-tests.t	Sat Oct 13 12:29:43 2018 +0200
+++ b/tests/test-run-tests.t	Sat Oct 13 12:11:45 2018 +0200
@@ -7,6 +7,7 @@
 Smoke test with install
 ============
   $ "$PYTHON" $TESTDIR/run-tests.py $HGTEST_RUN_TESTS_PURE -l
+  running 0 tests using 0 parallel processes 
   
   # Ran 0 tests, 0 skipped, 0 failed.
 
@@ -23,6 +24,7 @@
   $ ln -s `which true` hg
   $ "$PYTHON" $TESTDIR/run-tests.py --with-hg=./hg
   warning: --with-hg should specify an hg script
+  running 0 tests using 0 parallel processes 
   
   # Ran 0 tests, 0 skipped, 0 failed.
   $ rm hg
@@ -55,6 +57,7 @@
 
   $ touch test-empty.t
   $ rt
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
   $ rm test-empty.t
@@ -88,6 +91,7 @@
   > EOF
 
   $ rt
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
@@ -102,6 +106,7 @@
   >   | fo (re)
   > EOF
   $ rt test-failure.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -139,6 +144,7 @@
   >   value: * (glob)
   > EOF
   $ rt test-failure-globs.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure-globs.t
   +++ $TESTTMP/test-failure-globs.t.err
@@ -234,6 +240,7 @@
   >   missing (?)
   > EOF
   $ rt test-failure.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -292,6 +299,7 @@
   >>> fh.write(u'  l\u03b5\u03b5t\n'.encode('utf-8')) and None
 
   $ rt
+  running 3 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -323,6 +331,7 @@
 test --outputdir
   $ mkdir output
   $ rt --outputdir output
+  running 3 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/output/test-failure.t.err
@@ -359,6 +368,7 @@
 
 test --xunit support
   $ rt --xunit=xunit.xml
+  running 3 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -481,6 +491,7 @@
 ====================
 
   $ rt --retest
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -504,6 +515,7 @@
   $ mkdir output
   $ mv test-failure.t.err output
   $ rt --retest --outputdir output
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/output/test-failure.t.err
@@ -528,17 +540,20 @@
 successful
 
   $ rt test-success.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
 success w/ keyword
   $ rt -k xyzzy
+  running 2 tests using 1 parallel processes 
   .
   # Ran 2 tests, 1 skipped, 0 failed.
 
 failed
 
   $ rt test-failure.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -559,6 +574,7 @@
 
 failure w/ keyword
   $ rt -k rataxes
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -584,6 +600,7 @@
   >   $ echo 'abort: child process failed to start blah'
   > EOF
   $ rt test-serve-fail.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/test-serve-fail.t
   +++ $TESTTMP/test-serve-fail.t.err
@@ -614,6 +631,7 @@
   >   $ cat hg.pid >> \$DAEMON_PIDS
   > EOF
   $ rt test-serve-inuse.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
   $ rm test-serve-inuse.t
@@ -623,6 +641,7 @@
 ======================
 
   $ rt --debug 2>&1 | grep -v pwd
+  running 2 tests using 1 parallel processes 
   + echo *SALT* 0 0 (glob)
   *SALT* 0 0 (glob)
   + echo babar
@@ -661,6 +680,7 @@
   $ cp test-failure.t test-failure-copy.t
 
   $ rt --jobs 2 test-failure*.t -n
+  running 2 tests using 2 parallel processes 
   !!
   Failed test-failure*.t: output changed (glob)
   Failed test-failure*.t: output changed (glob)
@@ -670,6 +690,7 @@
 
 failures in parallel with --first should only print one failure
   $ rt --jobs 2 --first test-failure*.t
+  running 2 tests using 2 parallel processes 
   
   --- $TESTTMP/test-failure*.t (glob)
   +++ $TESTTMP/test-failure*.t.err (glob)
@@ -701,6 +722,7 @@
 Refuse the fix
 
   $ echo 'n' | rt -i
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -734,6 +756,7 @@
 Interactive with custom view
 
   $ echo 'n' | rt -i --view echo
+  running 2 tests using 1 parallel processes 
   $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err
   Accept this change? [n]* (glob)
   ERROR: test-failure.t output changed
@@ -746,6 +769,7 @@
 View the fix
 
   $ echo 'y' | rt --view echo
+  running 2 tests using 1 parallel processes 
   $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err
   
   ERROR: test-failure.t output changed
@@ -766,6 +790,7 @@
   >   saved backup bundle to \$TESTTMP/*.hg (glob)
   > EOF
   $ echo 'y' | rt -i 2>&1
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -815,6 +840,7 @@
   > EOF
 
   $ rt -i test-race.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/test-race.t
   +++ $TESTTMP/test-race.t.err
@@ -848,6 +874,7 @@
   > y
   > y
   > EOF
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/test-cases.t
   +++ $TESTTMP/test-cases.t#a.err
@@ -893,6 +920,7 @@
   >   B (b !)
   > EOF
   $ rt test-cases.t
+  running 2 tests using 1 parallel processes 
   ..
   # Ran 2 tests, 0 skipped, 0 failed.
 
@@ -911,6 +939,7 @@
   > #endif
   > EOF
   $ rt test-cases.t
+  running 4 tests using 1 parallel processes 
   ..
   --- $TESTTMP/test-cases.t
   +++ $TESTTMP/test-cases.t#b#c.err
@@ -939,6 +968,7 @@
 ===============
 
   $ rt --nodiff
+  running 2 tests using 1 parallel processes 
   !.
   Failed test-failure.t: output changed
   # Ran 2 tests, 0 skipped, 1 failed.
@@ -947,6 +977,7 @@
 
 test --tmpdir support
   $ rt --tmpdir=$TESTTMP/keep test-success.t
+  running 1 tests using 1 parallel processes 
   
   Keeping testtmp dir: $TESTTMP/keep/child1/test-success.t
   Keeping threadtmp dir: $TESTTMP/keep/child1 
@@ -963,6 +994,7 @@
   > echo '#require slow' > test-slow-timeout.t
   > cat test-timeout.t >> test-slow-timeout.t
   $ rt --timeout=1 --slowtimeout=3 test-timeout.t test-slow-timeout.t
+  running 2 tests using 1 parallel processes 
   st
   Skipped test-slow-timeout.t: missing feature: allow slow tests (use --allow-slow-tests)
   Failed test-timeout.t: timed out
@@ -971,6 +1003,7 @@
   [1]
   $ rt --timeout=1 --slowtimeout=3 \
   > test-timeout.t test-slow-timeout.t --allow-slow-tests
+  running 2 tests using 1 parallel processes 
   .t
   Failed test-timeout.t: timed out
   # Ran 2 tests, 0 skipped, 1 failed.
@@ -982,6 +1015,7 @@
 ==================
 
   $ rt test-success.t --time
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
   # Producing time report
@@ -992,6 +1026,7 @@
 ====================================
 
   $ rt test-success.t --time --jobs 2
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
   # Producing time report
@@ -1012,6 +1047,7 @@
   > #endif
   > EOF
   $ rt --nodiff
+  running 4 tests using 1 parallel processes 
   !.s.
   Skipped test-skip.t: missing feature: nail clipper
   Failed test-failure.t: output changed
@@ -1021,6 +1057,7 @@
 
   $ rm test-noskip.t
   $ rt --keyword xyzzy
+  running 3 tests using 1 parallel processes 
   .s
   Skipped test-skip.t: missing feature: nail clipper
   # Ran 2 tests, 2 skipped, 0 failed.
@@ -1028,6 +1065,7 @@
 Skips with xml
   $ rt --keyword xyzzy \
   >  --xunit=xunit.xml
+  running 3 tests using 1 parallel processes 
   .s
   Skipped test-skip.t: missing feature: nail clipper
   # Ran 2 tests, 2 skipped, 0 failed.
@@ -1045,6 +1083,7 @@
   $ echo test-failure.t > blacklist
   $ rt --blacklist=blacklist --json\
   >   test-failure.t test-bogus.t
+  running 2 tests using 1 parallel processes 
   ss
   Skipped test-bogus.t: Doesn't exist
   Skipped test-failure.t: blacklisted
@@ -1063,6 +1102,7 @@
   $ echo test-failure.t > whitelist
   $ rt --blacklist=blacklist --whitelist=whitelist --json\
   >   test-failure.t test-bogus.t
+  running 2 tests using 1 parallel processes 
   s
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -1086,10 +1126,12 @@
 be executed.
   $ echo test-success.t >> onlytest
   $ rt --test-list=onlytest
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
   $ echo test-bogus.t >> anothertest
   $ rt --test-list=onlytest --test-list=anothertest
+  running 2 tests using 1 parallel processes 
   s.
   Skipped test-bogus.t: Doesn't exist
   # Ran 1 tests, 1 skipped, 0 failed.
@@ -1099,6 +1141,7 @@
 ==================
 
   $ rt --json
+  running 3 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -1154,6 +1197,7 @@
   $ rm -r output
   $ mkdir output
   $ rt --json --outputdir output
+  running 3 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/output/test-failure.t.err
@@ -1215,6 +1259,7 @@
 
   $ cp test-failure.t backup
   $ echo y | rt --json -i
+  running 3 tests using 1 parallel processes 
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
@@ -1269,6 +1314,7 @@
   > EOF
 
   $ rt test-glob-backslash.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
@@ -1284,6 +1330,7 @@
 =======================================
 
   $ CUSTOM_TEST_RESULT=basic_test_result "$PYTHON" $TESTDIR/run-tests.py --with-hg=`which hg` "$@" test-success.t test-failure.t
+  running 2 tests using 1 parallel processes 
   
   # Ran 2 tests, 0 skipped, 0 failed.
   ON_START! <__main__.TestSuite tests=[<__main__.TTest testMethod=test-failure.t>, <__main__.TTest testMethod=test-success.t>]>
@@ -1306,6 +1353,7 @@
   >   foo
   > EOF
   $ rt test-hghave.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
@@ -1334,6 +1382,7 @@
   >   # check-code - a style and portability checker for Mercurial
   > EOF
   $ rt test-runtestdir.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
@@ -1351,6 +1400,7 @@
   >   hello world
   > EOF
   $ rt test-testdir-path.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
@@ -1363,10 +1413,12 @@
   >   pass
   > EOF
   $ rt test-very-slow-test.t
+  running 1 tests using 1 parallel processes 
   s
   Skipped test-very-slow-test.t: missing feature: allow slow tests (use --allow-slow-tests)
   # Ran 0 tests, 1 skipped, 0 failed.
   $ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
@@ -1377,6 +1429,7 @@
   >   pass
   > EOF
   $ rt nonlocal/test-is-not-here.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
@@ -1394,6 +1447,7 @@
   $ cp tmp/test-uno.t test-solo.t
 
   $ rt tmp/ test-solo.t tmpp
+  running 5 tests using 1 parallel processes 
   .....
   # Ran 5 tests, 0 skipped, 0 failed.
   $ rm -rf tmp tmpp
@@ -1417,6 +1471,7 @@
 
   $ cd ..
   $ rt tmp/test-*.t
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/tmp/test-folder-fail.t
   +++ $TESTTMP/anothertests/tmp/test-folder-fail.t.err
@@ -1447,6 +1502,7 @@
   > EOF
   $ hg ci -m 'bad'
   $ rt --known-good-rev=0 test-bisect.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/bisect/test-bisect.t
   +++ $TESTTMP/anothertests/bisect/test-bisect.t.err
@@ -1478,6 +1534,7 @@
   $ hg commit -Am dependent test-bisect-dependent.t
 
   $ rt --known-good-rev=0 test-bisect-dependent.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
   +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
@@ -1500,6 +1557,7 @@
   [2]
 
   $ rt --known-good-rev=0 --bisect-repo=../bisect test-bisect-dependent.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
   +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
@@ -1535,6 +1593,7 @@
   > EOF
   > done
   $ rt -j 2
+  running 5 tests using 2 parallel processes 
   ....
   # Ran 5 tests, 0 skipped, 0 failed.
   skipped: unknown feature: notarealhghavefeature
@@ -1572,6 +1631,7 @@
   >   [1]
   > EOF
   $ rt
+  running 3 tests using 1 parallel processes 
   .
   --- $TESTTMP/anothertests/cases/test-cases-abc.t
   +++ $TESTTMP/anothertests/cases/test-cases-abc.t#B.err
@@ -1595,6 +1655,7 @@
 --restart works
 
   $ rt --restart
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-abc.t
   +++ $TESTTMP/anothertests/cases/test-cases-abc.t#B.err
@@ -1620,6 +1681,7 @@
   $ mkdir output
   $ mv test-cases-abc.t#B.err output
   $ rt --restart --outputdir output
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-abc.t
   +++ $TESTTMP/anothertests/cases/output/test-cases-abc.t#B.err
@@ -1657,12 +1719,14 @@
   > #endif
   > EOF
   $ rt test-cases-ab.t
+  running 2 tests using 1 parallel processes 
   ..
   # Ran 2 tests, 0 skipped, 0 failed.
 
 Support running a specific test case
 
   $ rt "test-cases-abc.t#B"
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-abc.t
   +++ $TESTTMP/anothertests/cases/test-cases-abc.t#B.err
@@ -1686,6 +1750,7 @@
 Support running multiple test cases in the same file
 
   $ rt test-cases-abc.t#B test-cases-abc.t#C
+  running 2 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-abc.t
   +++ $TESTTMP/anothertests/cases/test-cases-abc.t#B.err
@@ -1709,6 +1774,7 @@
 Support ignoring invalid test cases
 
   $ rt test-cases-abc.t#B test-cases-abc.t#D
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-abc.t
   +++ $TESTTMP/anothertests/cases/test-cases-abc.t#B.err
@@ -1743,6 +1809,7 @@
     simple
 
   $ rt test-cases-advanced-cases.t
+  running 3 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-advanced-cases.t
   +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t#case-with-dashes.err
@@ -1771,6 +1838,7 @@
   [1]
 
   $ rt "test-cases-advanced-cases.t#case-with-dashes"
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-advanced-cases.t
   +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t#case-with-dashes.err
@@ -1788,6 +1856,7 @@
   [1]
 
   $ rt "test-cases-advanced-cases.t#casewith_-.chars"
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-cases-advanced-cases.t
   +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t#casewith_-.chars.err
@@ -1829,6 +1898,7 @@
   > EOF
 
   $ rt test-substitution.t
+  running 1 tests using 1 parallel processes 
   
   --- $TESTTMP/anothertests/cases/test-substitution.t
   +++ $TESTTMP/anothertests/cases/test-substitution.t.err
@@ -1853,5 +1923,6 @@
   > EOF
 
   $ rt --extra-config-opt extensions.purge= test-config-opt.t
+  running 1 tests using 1 parallel processes 
   .
   # Ran 1 tests, 0 skipped, 0 failed.