Mercurial > hg
annotate tests/check-perf-code.py @ 31971:73e9328e5307
obsolescence: add test case D-3 for obsolescence markers exchange
About 3 years ago, in August 2014, the logic to select what markers to select on
push was ported from the evolve extension to Mercurial core. However, for some
unclear reasons, the tests for that logic were not ported alongside.
I realised it a couple of weeks ago while working on another push related issue.
I've made a clean up pass on the tests and they are now ready to integrate the
core test suite. This series of changesets do not change any logic. I just adds
test for logic that has been around for about 10 versions of Mercurial.
They are a patch for each test case. It makes it easier to review and postpone
one with documentation issues without rejecting the wholes series.
This patch introduce case D3: missing prune target (prune not in "pushed set")
Each test case comes it in own test file. It help parallelism and does not
introduce a significant overhead from having a single unified giant test file.
Here are timing to support this claim.
# Multiple test files version:
# run-tests.py --local -j 1 test-exchange-*.t
53.40s user 6.82s system 85% cpu 1:10.76 total
52.79s user 6.97s system 85% cpu 1:09.97 total
52.94s user 6.82s system 85% cpu 1:09.69 total
# Single test file version:
# run-tests.py --local -j 1 test-exchange-obsmarkers.t
52.97s user 6.85s system 85% cpu 1:10.10 total
52.64s user 6.79s system 85% cpu 1:09.63 total
53.70s user 7.00s system 85% cpu 1:11.17 total
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 10 Apr 2017 16:54:43 +0200 |
parents | d8a2c536dd96 |
children | bd872f64a8ba |
rev | line source |
---|---|
29570
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
2 # |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
3 # check-perf-code - (historical) portability checker for contrib/perf.py |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
4 |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
5 from __future__ import absolute_import |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
6 |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
7 import os |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
8 import sys |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
9 |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
10 # write static check patterns here |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
11 perfpypats = [ |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
12 [ |
30144
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29571
diff
changeset
|
13 (r'(branchmap|repoview)\.subsettable', |
14031d183048
perf: get subsettable from appropriate module for Mercurial earlier than 2.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29571
diff
changeset
|
14 "use getbranchmapsubsettable() for early Mercurial"), |
30146
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
15 (r'\.(vfs|svfs|opener|sopener)', |
148ccd1d9f2f
perf: add functions to get vfs-like object for Mercurial earlier than 2.3
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30144
diff
changeset
|
16 "use getvfs()/getsvfs() for early Mercurial"), |
30149
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
17 (r'ui\.configint', |
d8a2c536dd96
perf: replace ui.configint() by getint() for Mercurial earlier than 1.9
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
30146
diff
changeset
|
18 "use getint() instead of ui.configint() for early Mercurial"), |
29570
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
19 ], |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
20 # warnings |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
21 [ |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
22 ] |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
23 ] |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
24 |
29571
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
25 def modulewhitelist(names): |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
26 replacement = [('.py', ''), ('.c', ''), # trim suffix |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
27 ('mercurial%s' % (os.sep), ''), # trim "mercurial/" path |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
28 ] |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
29 ignored = set(['__init__']) |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
30 modules = {} |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
31 |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
32 # convert from file name to module name, and count # of appearances |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
33 for name in names: |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
34 name = name.strip() |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
35 for old, new in replacement: |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
36 name = name.replace(old, new) |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
37 if name not in ignored: |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
38 modules[name] = modules.get(name, 0) + 1 |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
39 |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
40 # list up module names, which appear multiple times |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
41 whitelist = [] |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
42 for name, count in modules.items(): |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
43 if count > 1: |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
44 whitelist.append(name) |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
45 |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
46 return whitelist |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
47 |
29570
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
48 if __name__ == "__main__": |
29571
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
49 # in this case, it is assumed that result of "hg files" at |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
50 # multiple revisions is given via stdin |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
51 whitelist = modulewhitelist(sys.stdin) |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
52 assert whitelist, "module whitelist is empty" |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
53 |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
54 # build up module whitelist check from file names given at runtime |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
55 perfpypats[0].append( |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
56 # this matching pattern assumes importing modules from |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
57 # "mercurial" package in the current style below, for simplicity |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
58 # |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
59 # from mercurial import ( |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
60 # foo, |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
61 # bar, |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
62 # baz |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
63 # ) |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
64 ((r'from mercurial import [(][a-z0-9, \n#]*\n(?! *%s,|^[ #]*\n|[)])' |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
65 % ',| *'.join(whitelist)), |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
66 "import newer module separately in try clause for early Mercurial" |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
67 )) |
d1a7d9c279bb
tests: check importing modules in perf.py for historical portability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29570
diff
changeset
|
68 |
29570
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
69 # import contrib/check-code.py as checkcode |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
70 assert 'RUNTESTDIR' in os.environ, "use check-perf-code.py in *.t script" |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
71 contribpath = os.path.join(os.environ['RUNTESTDIR'], '..', 'contrib') |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
72 sys.path.insert(0, contribpath) |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
73 checkcode = __import__('check-code') |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
74 |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
75 # register perf.py specific entry with "checks" in check-code.py |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
76 checkcode.checks.append(('perf.py', r'contrib/perf.py$', '', |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
77 checkcode.pyfilters, perfpypats)) |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
78 |
cbd240188e4e
tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
79 sys.exit(checkcode.main()) |