Mercurial > hg
view tests/test-run-tests.py @ 32334:6e0d1043e8fc
fsmonitor: acquire localrepo.wlock prior to emitting hg.update state
we see some weird things in the watchman logs where the mercurial
process is seemingly confused about which hg.update state it is publishing
through watchman.
On closer examination, we're seeing conflicting pids for the clients involved
and this implies a race.
To resolve this, we extend the wlock around the state-enter/state-leave
events that are emitted to watchman.
Test Plan:
Some manual testing:
In one window, run this, and then checkout a different rev:
```
$ watchman -p -j <<<'["subscribe", "/data/users/wez/fbsource", "wez", {"expression": ["name", ".hg/updatestate"]}]'
{
"version": "4.9.0",
"subscribe": "wez",
"clock": "c:1495034090:814028:1:312576"
}
{
"state-enter": "hg.update",
"version": "4.9.0",
"clock": "c:1495034090:814028:1:312596",
"unilateral": true,
"subscription": "wez",
"metadata": {
"status": "ok",
"distance": 125,
"rev": "a1275d79ffa6c58b53116c8ec401c275ca6c1e2a",
"partial": false
},
"root": "/data/users/wez/fbsource"
}
{
"root": "/data/users/wez/fbsource",
"metadata": {
"status": "ok",
"distance": 125,
"rev": "a1275d79ffa6c58b53116c8ec401c275ca6c1e2a",
"partial": false
},
"subscription": "wez",
"unilateral": true,
"version": "4.9.0",
"clock": "c:1495034090:814028:1:312627",
"state-leave": "hg.update"
}
```
Tailed the watchman log file and looked for invalid state assertion errors,
then ran my `rebase-all` script to update/rebase all of my heads.
Didn't trigger the error condition (but couldn't reliably trigger it previously
anyway), and the output captured above shows that the states are being emitted
correctly.
author | Wez Furlong <wez@fb.com> |
---|---|
date | Thu, 18 May 2017 12:48:07 -0700 |
parents | f798ffe7cb08 |
children | eeed23508383 |
line wrap: on
line source
"""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) """ from __future__ import absolute_import, print_function import doctest import os import re # this is hack to make sure no escape characters are inserted into the output if 'TERM' in os.environ: del os.environ['TERM'] run_tests = __import__('run-tests') def prn(ex): m = ex.args[0] if isinstance(m, str): print(m) else: print(m.decode('utf-8')) def lm(expected, output): r"""check if output matches expected does it generally work? >>> lm(b'H*e (glob)\n', b'Here\n') True fail on bad test data >>> try: lm(b'a\n',b'a') ... except AssertionError as ex: print(ex) missing newline >>> try: lm(b'single backslash\n', b'single \backslash\n') ... except AssertionError as ex: prn(ex) single backslash or unknown char """ 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' match = run_tests.TTest.linematch(expected, output) if isinstance(match, str): return 'special: ' + match elif isinstance(match, bytes): return 'special: ' + match.decode('utf-8') else: return bool(match) # do not return match object def wintests(): r"""test matching like running on windows enable windows matching on any os >>> _osaltsep = os.altsep >>> os.altsep = True valid match on windows >>> lm(b'g/a*/d (glob)\n', b'g\\abc/d\n') True direct matching, glob unnecessary >>> lm(b'g/b (glob)\n', b'g/b\n') 'special: -glob' missing glob >>> lm(b'/g/c/d/fg\n', b'\\g\\c\\d/fg\n') 'special: +glob' restore os.altsep >>> os.altsep = _osaltsep """ pass def otherostests(): r"""test matching like running on non-windows os disable windows matching on any os >>> _osaltsep = os.altsep >>> os.altsep = False backslash does not match slash >>> lm(b'h/a* (glob)\n', b'h\\ab\n') False direct matching glob can not be recognized >>> lm(b'h/b (glob)\n', b'h/b\n') True missing glob can not not be recognized >>> lm(b'/h/c/df/g/\n', b'\\h/c\\df/g\\\n') False restore os.altsep >>> os.altsep = _osaltsep """ pass if __name__ == '__main__': doctest.testmod()