tests/test-check-pyflakes.t
author Simon Sapin <simon.sapin@octobus.net>
Tue, 27 Apr 2021 12:42:21 +0200
changeset 47130 04bcba539c96
parent 44995 78cafd48b9b2
child 47032 1d075b857c90
permissions -rw-r--r--
dirstate-tree: Avoid BTreeMap double-lookup when inserting a dirstate entry The child nodes of a given node in the tree-shaped dirstate are kept in a `BTreeMap` where keys are file names as strings. Finding or inserting a value in the map takes `O(log(n))` string comparisons, which adds up when constructing the tree. The `entry` API allows finding a "spot" in the map that may or may not be occupied and then access that value or insert a new one without doing map lookup again. However the current API is limited in that calling `entry` requires an owned key (and so a memory allocation), even if it ends up not being used in the case where the map already has a value with an equal key. This is still a win, with 4% better end-to-end time for `hg status` measured here with hyperfine: ``` Benchmark #1: ../hg2/hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1 Time (mean ± σ): 1.337 s ± 0.018 s [User: 892.9 ms, System: 437.5 ms] Range (min … max): 1.316 s … 1.373 s 10 runs Benchmark #2: ./hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1 Time (mean ± σ): 1.291 s ± 0.008 s [User: 853.4 ms, System: 431.1 ms] Range (min … max): 1.283 s … 1.309 s 10 runs Summary './hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1' ran 1.04 ± 0.02 times faster than '../hg2/hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1' ``` * ./hg is this revision * ../hg2/hg is its parent * $REPO is an old snapshot of mozilla-central Differential Revision: https://phab.mercurial-scm.org/D10550
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29138
a29f071751df tests: mark test-check-pyflakes.t as requiring hg1.0+
timeless <timeless@mozdev.org>
parents: 27285
diff changeset
     1
#require test-repo pyflakes hg10
21208
0e1cbd3d52f7 tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents: 20644
diff changeset
     2
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents: 29138
diff changeset
     3
  $ . "$TESTDIR/helpers-testrepo.sh"
19377
0cb996ee8c6d tests: run pyflakes on files from manifest which could be python files
Simon Heimberg <simohe@besonet.ch>
parents: 16350
diff changeset
     4
0cb996ee8c6d tests: run pyflakes on files from manifest which could be python files
Simon Heimberg <simohe@besonet.ch>
parents: 16350
diff changeset
     5
run pyflakes on all tracked files ending in .py or without a file ending
0cb996ee8c6d tests: run pyflakes on files from manifest which could be python files
Simon Heimberg <simohe@besonet.ch>
parents: 16350
diff changeset
     6
(skipping binary file random-seed)
21208
0e1cbd3d52f7 tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents: 20644
diff changeset
     7
33367
6029939f7e98 filterpyflakes: move self-test into test file
Augie Fackler <raf@durin42.com>
parents: 33204
diff changeset
     8
  $ cat > test.py <<EOF
6029939f7e98 filterpyflakes: move self-test into test file
Augie Fackler <raf@durin42.com>
parents: 33204
diff changeset
     9
  > print(undefinedname)
6029939f7e98 filterpyflakes: move self-test into test file
Augie Fackler <raf@durin42.com>
parents: 33204
diff changeset
    10
  > EOF
44807
f9099e210c57 tests: consistently use pyflakes as a Python module
Anton Shestakov <av6@dwimlabs.net>
parents: 44806
diff changeset
    11
  $ $PYTHON -m pyflakes test.py 2>/dev/null | "$TESTDIR/filterpyflakes.py"
44808
170f8a43b5b8 tests: adjust to the new format in pyflakes output
Anton Shestakov <av6@dwimlabs.net>
parents: 44807
diff changeset
    12
  test.py:1:* undefined name 'undefinedname' (glob)
33367
6029939f7e98 filterpyflakes: move self-test into test file
Augie Fackler <raf@durin42.com>
parents: 33204
diff changeset
    13
  
33418
1f3b54f392b0 test-check-pyflakes: do not leave test.py in the repo
Jun Wu <quark@fb.com>
parents: 33367
diff changeset
    14
  $ cd "`dirname "$TESTDIR"`"
33367
6029939f7e98 filterpyflakes: move self-test into test file
Augie Fackler <raf@durin42.com>
parents: 33204
diff changeset
    15
33204
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33128
diff changeset
    16
  $ testrepohg locate 'set:**.py or grep("^#!.*python")' \
33128
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 32543
diff changeset
    17
  > -X hgext/fsmonitor/pywatchman \
30923
5b60464efbde tests: exclude python-zstandard from pyflakes analysis
Augie Fackler <augie@google.com>
parents: 30658
diff changeset
    18
  > -X mercurial/pycompat.py -X contrib/python-zstandard \
44806
1ca0d5cae9bc tests: skip pyflakes for mercurial/thirdparty/
Anton Shestakov <av6@dwimlabs.net>
parents: 44479
diff changeset
    19
  > -X mercurial/thirdparty \
29584
06587edd1233 pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29232
diff changeset
    20
  > 2>/dev/null \
44479
e397c6d74652 tests: use pyflakes module instead of pyflakes executable
Manuel Jacob <me@manueljacob.de>
parents: 43544
diff changeset
    21
  > | xargs $PYTHON -m pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
44808
170f8a43b5b8 tests: adjust to the new format in pyflakes output
Anton Shestakov <av6@dwimlabs.net>
parents: 44807
diff changeset
    22
  contrib/perf.py:*:* undefined name 'xrange' (glob) (?)
170f8a43b5b8 tests: adjust to the new format in pyflakes output
Anton Shestakov <av6@dwimlabs.net>
parents: 44807
diff changeset
    23
  mercurial/hgweb/server.py:*:* undefined name 'reload' (glob) (?)
170f8a43b5b8 tests: adjust to the new format in pyflakes output
Anton Shestakov <av6@dwimlabs.net>
parents: 44807
diff changeset
    24
  mercurial/util.py:*:* undefined name 'file' (glob) (?)
170f8a43b5b8 tests: adjust to the new format in pyflakes output
Anton Shestakov <av6@dwimlabs.net>
parents: 44807
diff changeset
    25
  mercurial/encoding.py:*:* undefined name 'localstr' (glob) (?)
22053
4354b1e35f53 tests: fix pyflakes test whitespace breakage
Matt Mackall <mpm@selenic.com>
parents: 22047
diff changeset
    26