Mercurial > public > mercurial-scm > hg-stable
annotate tests/common-pattern.py @ 35239:feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Automatic replacement seems better than trying to figure out a check-code rule.
I didn't bother looking to see why the error message and file name is reversed
in the annotate and histedit tests, based on Windows or not.
I originally had this as a list of tuples, conditional on the platform. But
there are a couple of 'No such file or directory' messages emitted by Mercurial
itself, so unconditional is required for stability. There are also several
variants of what I assume is 'connection refused' and 'unknown host' in
test-clone.t and test-clonebundles.t for Docker, FreeBSD jails, etc. Yes, these
are handled by (re) tags, but maybe it would be better to capture those strings
in order to avoid whack-a-mole in future tests. All of this points to using a
dictionary containing one or more strings-to-be-replaced values.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 02 Dec 2017 19:33:34 -0500 |
parents | 7f0c9e28a816 |
children | b33d4cf38666 |
rev | line source |
---|---|
35093
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
1 # common patterns in test at can safely be replaced |
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
2 from __future__ import absolute_import |
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
3 |
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
4 substitutions = [ |
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
5 # list of possible compressions |
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
6 (br'zstd,zlib,none,bzip2', |
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
7 br'$USUAL_COMPRESSIONS$' |
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
8 ), |
35094
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
9 # capabilities sent through http |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
10 (br'bundlecaps=HG20%2Cbundle2%3DHG20%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
11 br'changegroup%253D01%252C02%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
12 br'digests%253Dmd5%252Csha1%252Csha512%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
13 br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
14 br'hgtagsfnodes%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
15 br'listkeys%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
16 br'phases%253Dheads%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
17 br'pushkey%250A' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
18 br'remote-changegroup%253Dhttp%252Chttps', |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
19 # (the replacement patterns) |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
20 br'$USUAL_BUNDLE_CAPS$' |
b4767ae63b32
test-pattern: register current the bundlecaps string
Boris Feld <boris.feld@octobus.net>
parents:
35093
diff
changeset
|
21 ), |
35095
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
22 # bundle2 capabilities sent through ssh |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
23 (br'bundle2=HG20%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
24 br'changegroup%3D01%2C02%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
25 br'digests%3Dmd5%2Csha1%2Csha512%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
26 br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
27 br'hgtagsfnodes%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
28 br'listkeys%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
29 br'phases%3Dheads%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
30 br'pushkey%0A' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
31 br'remote-changegroup%3Dhttp%2Chttps', |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
32 # (replacement patterns) |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
33 br'$USUAL_BUNDLE2_CAPS$' |
c4ec72a10798
test-pattern: register the current the bundle2 capabilities string
Boris Feld <boris.feld@octobus.net>
parents:
35094
diff
changeset
|
34 ), |
35096
7f0c9e28a816
test-pattern: substitute the HTTP log timestamp too
Boris Feld <boris.feld@octobus.net>
parents:
35095
diff
changeset
|
35 # HTTP log dates |
7f0c9e28a816
test-pattern: substitute the HTTP log timestamp too
Boris Feld <boris.feld@octobus.net>
parents:
35095
diff
changeset
|
36 (br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] "GET', |
7f0c9e28a816
test-pattern: substitute the HTTP log timestamp too
Boris Feld <boris.feld@octobus.net>
parents:
35095
diff
changeset
|
37 br' - - [$LOGDATE$] "GET' |
7f0c9e28a816
test-pattern: substitute the HTTP log timestamp too
Boris Feld <boris.feld@octobus.net>
parents:
35095
diff
changeset
|
38 ), |
35093
3abdd7da33bd
test-pattern: substitute common compression list
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
39 ] |
35239
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
40 |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
41 # Various platform error strings, keyed on a common replacement string |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
42 _errors = { |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
43 br'$ENOENT$': ( |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
44 # strerror() |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
45 br'No such file or directory', |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
46 |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
47 # FormatMessage(ERROR_FILE_NOT_FOUND) |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
48 br'The system cannot find the file specified', |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
49 ), |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
50 } |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
51 |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
52 for replace, msgs in _errors.items(): |
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
35096
diff
changeset
|
53 substitutions.extend((m, replace) for m in msgs) |