Mercurial > hg
annotate tests/md5sum.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 | 8d1cdee372e6 |
children | 3a64ac39b893 |
rev | line source |
---|---|
4122
306055f5b65c
Unified #! paths for python scripts and removed them for test modules.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3223
diff
changeset
|
1 #!/usr/bin/env python |
1928
50e1c90b0fcf
clarify license on md5sum.py
Peter van Dijk <peter@dataloss.nl>
parents:
1924
diff
changeset
|
2 # |
50e1c90b0fcf
clarify license on md5sum.py
Peter van Dijk <peter@dataloss.nl>
parents:
1924
diff
changeset
|
3 # Based on python's Tools/scripts/md5sum.py |
50e1c90b0fcf
clarify license on md5sum.py
Peter van Dijk <peter@dataloss.nl>
parents:
1924
diff
changeset
|
4 # |
50e1c90b0fcf
clarify license on md5sum.py
Peter van Dijk <peter@dataloss.nl>
parents:
1924
diff
changeset
|
5 # This software may be used and distributed according to the terms |
50e1c90b0fcf
clarify license on md5sum.py
Peter van Dijk <peter@dataloss.nl>
parents:
1924
diff
changeset
|
6 # of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, which is |
50e1c90b0fcf
clarify license on md5sum.py
Peter van Dijk <peter@dataloss.nl>
parents:
1924
diff
changeset
|
7 # GPL-compatible. |
50e1c90b0fcf
clarify license on md5sum.py
Peter van Dijk <peter@dataloss.nl>
parents:
1924
diff
changeset
|
8 |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
9 from __future__ import absolute_import |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
10 |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
11 import os |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
12 import sys |
6470
ac0bcd951c2c
python 2.6 compatibility: compatibility wrappers for hash functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6212
diff
changeset
|
13 |
ac0bcd951c2c
python 2.6 compatibility: compatibility wrappers for hash functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6212
diff
changeset
|
14 try: |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
15 import hashlib |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
16 md5 = hashlib.md5 |
6470
ac0bcd951c2c
python 2.6 compatibility: compatibility wrappers for hash functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6212
diff
changeset
|
17 except ImportError: |
29485
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
18 import md5 |
6a98f9408a50
py3: make files use absolute_import and print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
25660
diff
changeset
|
19 md5 = md5.md5 |
1924
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
20 |
7080
a6477aa893b8
tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents:
6470
diff
changeset
|
21 try: |
a6477aa893b8
tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents:
6470
diff
changeset
|
22 import msvcrt |
a6477aa893b8
tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents:
6470
diff
changeset
|
23 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
a6477aa893b8
tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents:
6470
diff
changeset
|
24 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
a6477aa893b8
tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents:
6470
diff
changeset
|
25 except ImportError: |
a6477aa893b8
tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents:
6470
diff
changeset
|
26 pass |
a6477aa893b8
tests: Windows compatibility fixes
Patrick Mezard <pmezard@gmail.com>
parents:
6470
diff
changeset
|
27 |
1924
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
28 for filename in sys.argv[1:]: |
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
29 try: |
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
30 fp = open(filename, 'rb') |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14494
diff
changeset
|
31 except IOError as msg: |
1924
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
32 sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) |
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
33 sys.exit(1) |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1928
diff
changeset
|
34 |
6470
ac0bcd951c2c
python 2.6 compatibility: compatibility wrappers for hash functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6212
diff
changeset
|
35 m = md5() |
1924
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
36 try: |
29731
8d1cdee372e6
md5sum: use `iter(callable, sentinel)` instead of while True
Augie Fackler <augie@google.com>
parents:
29485
diff
changeset
|
37 for data in iter(lambda: fp.read(8192), ''): |
1924
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
38 m.update(data) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
14494
diff
changeset
|
39 except IOError as msg: |
1924
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
40 sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) |
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
41 sys.exit(1) |
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
42 sys.stdout.write('%s %s\n' % (m.hexdigest(), filename)) |
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
43 |
46fb38ef9a91
add md5sum.py required by fix in previous changeset
Peter van Dijk <peter@dataloss.nl>
parents:
diff
changeset
|
44 sys.exit(0) |