##// END OF EJS Templates
bisect: avoid adding irrelevant revisions to bisect state...
bisect: avoid adding irrelevant revisions to bisect state When adding new revisions to the bisect state, it only makes sense to add information about revisions that are under consideration (i.e., those that are topologically between the known good and bad revisions). However, if the user passes in a revset (e.g., '!merge()' to exclude merge commits), hg will resolve the revset first and add all matching revisions to the bisect state (which in this case would likely be the majority of revisions in the repo). To avoid this, revisions should only be added to the bisect state if they are between the good and bad revisions (and therefore relevant to the bisection). -- Here are the results of some performance tests using the `mozilla-central` repo (since it is one of the largest freely-available hg repositories in the wild). These tests compare the performance of a locally-built `hg` before and after application of this series. Note that `--noupdate` is passed to avoid including update time (which should not vary across cases). Setup (run between each test): $ hg bisect --reset $ hg bisect --noupdate --bad 56c3ad4bde5c70714b784ccf15d099e0df0f5bde $ hg bisect --noupdate --good 57426696adaf08298af3027fa77486fee0633b13 Test using a revset that returns a very large number of revisions: $ time hg bisect --noupdate --skip '!merge()' > /dev/null Before: real 0m9.398s user 0m9.233s sys 0m0.120s After: real 0m1.513s user 0m1.425s sys 0m0.052s Test using a revset that is expensive to compute: $ time hg bisect --noupdate --skip 'desc("Bug")' > /dev/null Before: real 0m49.853s user 0m49.580s sys 0m0.243s After: real 0m4.120s user 0m4.036s sys 0m0.048s

File last commit:

r49730:6000f5b2 default
r50337:81623652 default
Show More
test-run-tests.py
118 lines | 2.9 KiB | text/x-python | PythonLexer
/ tests / test-run-tests.py
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 """test line matching with some failing examples and some which warn
run-test.t only checks positive matches and can not see warnings
(both by design)
"""
Pulkit Goyal
tests: make test-run-tests use absolute_import
r28917 import doctest
import os
import re
Augie Fackler
formatting: blacken the codebase...
r43346
Simon Heimberg
tests: fix test-run-tests.py on OS X...
r20284 # this is hack to make sure no escape characters are inserted into the output
if 'TERM' in os.environ:
del os.environ['TERM']
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 run_tests = __import__('run-tests')
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 def prn(ex):
m = ex.args[0]
if isinstance(m, str):
print(m)
else:
print(m.decode('utf-8'))
Augie Fackler
formatting: blacken the codebase...
r43346
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 def lm(expected, output):
r"""check if output matches expected
does it generally work?
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> lm(b'H*e (glob)\n', b'Here\n')
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 True
fail on bad test data
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> try: lm(b'a\n',b'a')
... except AssertionError as ex: print(ex)
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 missing newline
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> try: lm(b'single backslash\n', b'single \backslash\n')
... except AssertionError as ex: prn(ex)
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 single backslash or unknown char
"""
Augie Fackler
formatting: blacken the codebase...
r43346 assert expected.endswith(b'\n') and output.endswith(
b'\n'
), 'missing newline'
assert not re.search(
br'[^ \w\\/\r\n()*?]', expected + output
), b'single backslash or unknown char'
Augie Fackler
tests: fix up test-run-tests failures on Python 3.6...
r33676 test = run_tests.TTest(b'test-run-test.t', b'.', b'.')
Martin von Zweigbergk
tests: don't allow reodering of glob/re lines across non-glob/re lines...
r38572 match, exact = test.linematch(expected, output)
Simon Heimberg
run-tests: suggest to append glob when only path sep does not match...
r20273 if isinstance(match, str):
return 'special: ' + match
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 elif isinstance(match, bytes):
return 'special: ' + match.decode('utf-8')
Simon Heimberg
run-tests: suggest to append glob when only path sep does not match...
r20273 else:
Augie Fackler
formatting: blacken the codebase...
r43346 return bool(match) # do not return match object
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271
def wintests():
r"""test matching like running on windows
enable windows matching on any os
>>> _osaltsep = os.altsep
>>> os.altsep = True
Matt Harbison
run-tests: suggest a (glob) for os.path.sep mismatches with '\r\n' EOL too...
r35382 >>> _osname = os.name
>>> os.name = 'nt'
run-tests: use a global WINDOWS constant instead of multiple tests...
r48373 >>> _old_windows = run_tests.WINDOWS
>>> run_tests.WINDOWS = True
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271
valid match on windows
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> lm(b'g/a*/d (glob)\n', b'g\\abc/d\n')
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 True
direct matching, glob unnecessary
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> lm(b'g/b (glob)\n', b'g/b\n')
Simon Heimberg
run-tests: print more information on unnecessary glob matching...
r20274 'special: -glob'
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271
missing glob
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> lm(b'/g/c/d/fg\n', b'\\g\\c\\d/fg\n')
Matt Harbison
run-tests: accept '\' vs '/' path differences without '(glob)'...
r35383 True
Matt Harbison
run-tests: suggest a (glob) for os.path.sep mismatches with '\r\n' EOL too...
r35382 >>> lm(b'/g/c/d/fg\n', b'\\g\\c\\d\\fg\r\n')
Matt Harbison
run-tests: accept '\' vs '/' path differences without '(glob)'...
r35383 True
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271
restore os.altsep
>>> os.altsep = _osaltsep
Matt Harbison
run-tests: suggest a (glob) for os.path.sep mismatches with '\r\n' EOL too...
r35382 >>> os.name = _osname
run-tests: use a global WINDOWS constant instead of multiple tests...
r48373 >>> run_tests.WINDOWS = _old_windows
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 """
Simon Heimberg
tests: fix test-run-tests.py on OS X...
r20284 pass
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271
Augie Fackler
formatting: blacken the codebase...
r43346
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 def otherostests():
r"""test matching like running on non-windows os
disable windows matching on any os
>>> _osaltsep = os.altsep
>>> os.altsep = False
Matt Harbison
run-tests: suggest a (glob) for os.path.sep mismatches with '\r\n' EOL too...
r35382 >>> _osname = os.name
>>> os.name = 'nt'
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271
backslash does not match slash
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> lm(b'h/a* (glob)\n', b'h\\ab\n')
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 False
direct matching glob can not be recognized
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> lm(b'h/b (glob)\n', b'h/b\n')
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 True
missing glob can not not be recognized
Augie Fackler
test-run-tests: fix for Python 3.5...
r25061 >>> lm(b'/h/c/df/g/\n', b'\\h/c\\df/g\\\n')
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 False
restore os.altsep
>>> os.altsep = _osaltsep
Matt Harbison
run-tests: suggest a (glob) for os.path.sep mismatches with '\r\n' EOL too...
r35382 >>> os.name = _osname
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 """
pass
Augie Fackler
formatting: blacken the codebase...
r43346
Simon Heimberg
tests: new test for line matching functions in run-tests...
r20271 if __name__ == '__main__':
doctest.testmod()