Mercurial > hg
changeset 35230: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 | 61ff0d7d56fd |
children | b33d4cf38666 |
files | tests/common-pattern.py tests/test-acl.t tests/test-addremove.t tests/test-annotate.t tests/test-dispatch.t tests/test-extdata.t tests/test-hgignore.t tests/test-histedit-arguments.t tests/test-hook.t tests/test-largefiles-update.t tests/test-shelve.t tests/test-status-rev.t tests/test-subrepo-git.t tests/test-subrepo-svn.t tests/test-walk.t |
diffstat | 15 files changed, 38 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/common-pattern.py Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/common-pattern.py Sat Dec 02 19:33:34 2017 -0500 @@ -37,3 +37,17 @@ br' - - [$LOGDATE$] "GET' ), ] + +# Various platform error strings, keyed on a common replacement string +_errors = { + br'$ENOENT$': ( + # strerror() + br'No such file or directory', + + # FormatMessage(ERROR_FILE_NOT_FOUND) + br'The system cannot find the file specified', + ), +} + +for replace, msgs in _errors.items(): + substitutions.extend((m, replace) for m in msgs)
--- a/tests/test-acl.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-acl.t Sat Dec 02 19:33:34 2017 -0500 @@ -925,7 +925,7 @@ bundle2-input-bundle: 4 parts total transaction abort! rollback completed - abort: No such file or directory: ../acl.config + abort: $ENOENT$: ../acl.config no rollback information available 0:6675d58eff77
--- a/tests/test-addremove.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-addremove.t Sat Dec 02 19:33:34 2017 -0500 @@ -31,8 +31,7 @@ $ hg forget foo $ hg -v addremove nonexistent - nonexistent: The system cannot find the file specified (windows !) - nonexistent: No such file or directory (no-windows !) + nonexistent: $ENOENT$ [1] $ cd .. @@ -86,8 +85,7 @@ $ rm c $ hg ci -A -m "c" nonexistent - nonexistent: The system cannot find the file specified (windows !) - nonexistent: No such file or directory (no-windows !) + nonexistent: $ENOENT$ abort: failed to mark all new/missing files as added/removed [255]
--- a/tests/test-annotate.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-annotate.t Sat Dec 02 19:33:34 2017 -0500 @@ -556,8 +556,8 @@ $ rm baz $ hg annotate -ncr "wdir()" baz - abort: $TESTTMP\repo\baz: The system cannot find the file specified (windows !) - abort: No such file or directory: $TESTTMP/repo/baz (no-windows !) + abort: $TESTTMP\repo\baz: $ENOENT$ (windows !) + abort: $ENOENT$: $TESTTMP/repo/baz (no-windows !) [255] annotate removed file @@ -565,8 +565,8 @@ $ hg rm baz $ hg annotate -ncr "wdir()" baz - abort: $TESTTMP\repo\baz: The system cannot find the file specified (windows !) - abort: No such file or directory: $TESTTMP/repo/baz (no-windows !) + abort: $TESTTMP\repo\baz: $ENOENT$ (windows !) + abort: $ENOENT$: $TESTTMP/repo/baz (no-windows !) [255] $ hg revert --all --no-backup --quiet
--- a/tests/test-dispatch.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-dispatch.t Sat Dec 02 19:33:34 2017 -0500 @@ -94,8 +94,7 @@ [255] $ hg log -b --cwd=inexistent default - abort: No such file or directory: 'inexistent' (no-windows !) - abort: The system cannot find the file specified: 'inexistent' (windows !) + abort: $ENOENT$: 'inexistent' [255] $ hg log -b '--config=ui.traceback=yes' 2>&1 | grep '^Traceback' @@ -212,7 +211,7 @@ The output could be one of the following and something else: chg: abort: failed to getcwd (errno = *) (glob) abort: error getting current working directory: * (glob) - sh: 0: getcwd() failed: No such file or directory + sh: 0: getcwd() failed: $ENOENT$ Since the exact behavior depends on the shell, only check it returns non-zero. $ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false [1]
--- a/tests/test-extdata.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-extdata.t Sat Dec 02 19:33:34 2017 -0500 @@ -88,8 +88,7 @@ $ mkdir sub $ cd sub $ hg log -qr "extdata(filedata)" - abort: error: The system cannot find the file specified (windows !) - abort: error: No such file or directory (no-windows !) + abort: error: $ENOENT$ [255] $ hg log -qr "extdata(shelldata)" 2:f6ed99a58333
--- a/tests/test-hgignore.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-hgignore.t Sat Dec 02 19:33:34 2017 -0500 @@ -265,7 +265,7 @@ $ cp otherignore goodignore $ echo "include:badignore" >> otherignore $ hg status - skipping unreadable pattern file 'badignore': No such file or directory + skipping unreadable pattern file 'badignore': $ENOENT$ A dir/b.o $ mv goodignore otherignore
--- a/tests/test-histedit-arguments.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-histedit-arguments.t Sat Dec 02 19:33:34 2017 -0500 @@ -354,7 +354,8 @@ $ mv ../corrupt-histedit .hg/histedit-state $ hg histedit --abort warning: encountered an exception during histedit --abort; the repository may not have been completely cleaned up - abort: .*(No such file or directory:|The system cannot find the file specified).* (re) + abort: $TESTTMP/foo/.hg/strip-backup/*-histedit.hg: $ENOENT$ (glob) (windows !) + abort: $ENOENT$: $TESTTMP/foo/.hg/strip-backup/*-histedit.hg (glob) (no-windows !) [255] Histedit state has been exited $ hg summary -q
--- a/tests/test-hook.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-hook.t Sat Dec 02 19:33:34 2017 -0500 @@ -685,7 +685,7 @@ $ hg up null loading update.ne hook failed: - abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py + abort: $ENOENT$: $TESTTMP/d/repo/nonexistent.py [255] $ hg id
--- a/tests/test-largefiles-update.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-largefiles-update.t Sat Dec 02 19:33:34 2017 -0500 @@ -216,8 +216,7 @@ $ hg add --large largeY $ hg status -A large1 - large1: The system cannot find the file specified (windows !) - large1: No such file or directory (no-windows !) + large1: $ENOENT$ $ hg status -A large2 ? large2 @@ -309,8 +308,7 @@ rebasing 4:07d6153b5c04 "#4" (tip) $ hg status -A large1 - large1: The system cannot find the file specified (windows !) - large1: No such file or directory (no-windows !) + large1: $ENOENT$ $ hg status -A largeX C largeX @@ -320,8 +318,7 @@ $ hg transplant -q 1 4 $ hg status -A large1 - large1: The system cannot find the file specified (windows !) - large1: No such file or directory (no-windows !) + large1: $ENOENT$ $ hg status -A largeX C largeX @@ -331,8 +328,7 @@ $ hg transplant -q --merge 1 --merge 4 $ hg status -A large1 - large1: The system cannot find the file specified (windows !) - large1: No such file or directory (no-windows !) + large1: $ENOENT$ $ hg status -A largeX C largeX
--- a/tests/test-shelve.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-shelve.t Sat Dec 02 19:33:34 2017 -0500 @@ -1271,7 +1271,7 @@ $ rm .hg/unshelverebasestate $ hg unshelve --abort unshelve of 'default' aborted - abort: (No such file or directory|The system cannot find the file specified) (re) + abort: $ENOENT$ [255] Can the user leave the current state? $ hg up -C .
--- a/tests/test-status-rev.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-status-rev.t Sat Dec 02 19:33:34 2017 -0500 @@ -83,8 +83,7 @@ ! missing_missing_missing-tracked $ hg status -A --rev 1 'glob:missing_missing_missing-untracked' - missing_missing_missing-untracked: The system cannot find the file specified (windows !) - missing_missing_missing-untracked: No such file or directory (no-windows !) + missing_missing_missing-untracked: $ENOENT$ Status between first and second commit. Should ignore dirstate status.
--- a/tests/test-subrepo-git.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-subrepo-git.t Sat Dec 02 19:33:34 2017 -0500 @@ -640,9 +640,10 @@ traceback #if no-windows $ hg forget 'notafile*' - notafile*: No such file or directory + notafile*: $ENOENT$ [1] #else +error: The filename, directory name, or volume label syntax is incorrect $ hg forget 'notafile' notafile: * (glob) [1]
--- a/tests/test-subrepo-svn.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-subrepo-svn.t Sat Dec 02 19:33:34 2017 -0500 @@ -571,15 +571,9 @@ Test forgetting files, not implemented in svn subrepo, used to traceback -#if no-windows $ hg forget 'notafile*' - notafile*: No such file or directory + notafile*: $ENOENT$ [1] -#else - $ hg forget 'notafile' - notafile: * (glob) - [1] -#endif Test a subrepo referencing a just moved svn path. Last commit rev will be different from the revision, and the path will be different as
--- a/tests/test-walk.t Sun Dec 03 20:55:35 2017 -0800 +++ b/tests/test-walk.t Sat Dec 02 19:33:34 2017 -0500 @@ -378,7 +378,7 @@ f glob:glob glob:glob $ hg debugwalk glob:glob matcher: <patternmatcher patterns='(?:glob$)'> - glob: No such file or directory + glob: $ENOENT$ $ hg debugwalk glob:glob:glob matcher: <patternmatcher patterns='(?:glob\\:glob$)'> f glob:glob glob:glob exact