run-tests: allow bisecting a different repo
Add `--bisect-repo` flag which accepts a different repo to bisect.
3rd party extensions may reuse `run-tests.py` from core to run tests. Test
failure could be caused by either a core hg change or the 3rd party
extension code itself. Having a way to specify which repo to bisect is
useful.
Differential Revision: https://phab.mercurial-scm.org/D578
--- a/tests/run-tests.py Wed Aug 02 21:01:38 2017 -0700
+++ b/tests/run-tests.py Wed Aug 02 21:24:29 2017 -0700
@@ -406,6 +406,10 @@
metavar="known_good_rev",
help=("Automatically bisect any failures using this "
"revision as a known-good revision."))
+ parser.add_option('--bisect-repo', type="string",
+ metavar='bisect_repo',
+ help=("Path of a repo to bisect. Use together with "
+ "--known-good-rev"))
for option, (envvar, default) in defaults.items():
defaults[option] = type(default)(os.environ.get(envvar, default))
@@ -458,6 +462,9 @@
sys.stderr.write('warning: --color=always ignored because '
'pygments is not installed\n')
+ if options.bisect_repo and not options.known_good_rev:
+ parser.error("--bisect-repo cannot be used without --known-good-rev")
+
global useipv6
if options.ipv6:
useipv6 = checksocketfamily('AF_INET6')
@@ -2071,6 +2078,9 @@
if failed and self._runner.options.known_good_rev:
bisectcmd = ['hg', 'bisect']
+ bisectrepo = self._runner.options.bisect_repo
+ if bisectrepo:
+ bisectcmd.extend(['-R', os.path.abspath(bisectrepo)])
def nooutput(args):
p = subprocess.Popen(args, stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
--- a/tests/test-run-tests.t Wed Aug 02 21:01:38 2017 -0700
+++ b/tests/test-run-tests.t Wed Aug 02 21:24:29 2017 -0700
@@ -1285,6 +1285,58 @@
$ cd ..
+support bisecting a separate repo
+
+ $ hg init bisect-dependent
+ $ cd bisect-dependent
+ $ cat > test-bisect-dependent.t <<EOF
+ > $ tail -1 \$TESTDIR/../bisect/test-bisect.t
+ > pass
+ > EOF
+ $ hg commit -Am dependent test-bisect-dependent.t
+
+ $ rt --known-good-rev=0 test-bisect-dependent.t
+
+ --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
+ +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
+ @@ -1,2 +1,2 @@
+ $ tail -1 $TESTDIR/../bisect/test-bisect.t
+ - pass
+ + fail
+
+ ERROR: test-bisect-dependent.t output changed
+ !
+ Failed test-bisect-dependent.t: output changed
+ Failed to identify failure point for test-bisect-dependent.t
+ # Ran 1 tests, 0 skipped, 1 failed.
+ python hash seed: * (glob)
+ [1]
+
+ $ rt --bisect-repo=../test-bisect test-bisect-dependent.t
+ Usage: run-tests.py [options] [tests]
+
+ run-tests.py: error: --bisect-repo cannot be used without --known-good-rev
+ [2]
+
+ $ rt --known-good-rev=0 --bisect-repo=../bisect test-bisect-dependent.t
+
+ --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t
+ +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err
+ @@ -1,2 +1,2 @@
+ $ tail -1 $TESTDIR/../bisect/test-bisect.t
+ - pass
+ + fail
+
+ ERROR: test-bisect-dependent.t output changed
+ !
+ Failed test-bisect-dependent.t: output changed
+ test-bisect-dependent.t broken by 72cbf122d116 (bad)
+ # Ran 1 tests, 0 skipped, 1 failed.
+ python hash seed: * (glob)
+ [1]
+
+ $ cd ..
+
Test a broken #if statement doesn't break run-tests threading.
==============================================================
$ mkdir broken