Mercurial > public > mercurial-scm > hg
changeset 52429:a4889a91713d
tests: replace ersatz Traceback filtering with test utility
I wasn't aware of this utility until recently, but it seems to be used a lot in
tests that expect tracebacks.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 30 Nov 2024 17:43:06 -0500 |
parents | 8431296a93e8 |
children | 31c4987034b9 |
files | tests/test-bad-extension.t tests/test-dispatch.t tests/test-hook.t |
diffstat | 3 files changed, 61 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-bad-extension.t Mon Dec 02 10:52:35 2024 -0500 +++ b/tests/test-bad-extension.t Sat Nov 30 17:43:06 2024 -0500 @@ -58,17 +58,26 @@ show traceback - $ hg -q help help --traceback 2>&1 | grep -E ' extension|^Exception|Traceback|ImportError|ModuleNotFound' + $ hg -q help help --traceback 2>&1 | "$PYTHON" "$TESTDIR/filtertraceback.py" *** failed to import extension "badext" from $TESTTMP/badext.py: bit bucket overflow Traceback (most recent call last): Exception: bit bucket overflow *** failed to import extension "badext2": No module named 'badext2' Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext.badext2' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext3rd.badext2' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'badext2' + hg help [-eck] [-s PLATFORM] [TOPIC] + + show help for a given topic or a help overview names of extensions failed to load can be accessed via extensions.notloaded() @@ -89,7 +98,7 @@ $ (hg help help --traceback --debug --config devel.debug.extensions=yes 2>&1) \ > | grep -v '^ ' \ > | filterlog \ - > | grep -E 'extension..[^p]|^Exception|Traceback|ImportError|^YYYY|not import|ModuleNotFound' + > | "$PYTHON" "$TESTDIR/filtertraceback.py" YYYY/MM/DD HH:MM:SS (PID)> loading extensions YYYY/MM/DD HH:MM:SS (PID)> - processing 5 entries YYYY/MM/DD HH:MM:SS (PID)> - loading extension: gpg @@ -113,13 +122,22 @@ YYYY/MM/DD HH:MM:SS (PID)> - could not import hgext3rd.badext2 (No module named *badext2*): trying badext2 (glob) Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext.badext2' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext3rd.badext2' *** failed to import extension "badext2": No module named 'badext2' Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext.badext2' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext3rd.badext2' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'badext2' YYYY/MM/DD HH:MM:SS (PID)> > loaded 2 extensions, total time * (glob) @@ -143,7 +161,21 @@ YYYY/MM/DD HH:MM:SS (PID)> > extension baddocext take a total of * to load (glob) YYYY/MM/DD HH:MM:SS (PID)> > extension gpg take a total of * to load (glob) YYYY/MM/DD HH:MM:SS (PID)> extension loading complete + hg help [-eck] [-s PLATFORM] [TOPIC] + + show help for a given topic or a help overview + + With no arguments, print a list of commands with short help messages. + Given a topic, extension, or command name, print help for that topic. + + Returns 0 if successful. + + options ([+] can be repeated): + + + global options ([+] can be repeated): + #endif confirm that there's no crash when an extension's documentation is bad
--- a/tests/test-dispatch.t Mon Dec 02 10:52:35 2024 -0500 +++ b/tests/test-dispatch.t Sat Nov 30 17:43:06 2024 -0500 @@ -98,8 +98,10 @@ abort: $ENOENT$: 'inexistent' [255] - $ hg log -b '--config=ui.traceback=yes' 2>&1 | grep '^Traceback' + $ hg log -b '--config=ui.traceback=yes' 2>&1 | "$PYTHON" "$TESTDIR/filtertraceback.py" Traceback (most recent call last): + mercurial.error.InputError: option --config may not be abbreviated + abort: option --config may not be abbreviated $ hg log -b '--config=profiling.enabled=yes' 2>&1 | grep -i sample Sample count: .*|No samples recorded\. (re)
--- a/tests/test-hook.t Mon Dec 02 10:52:35 2024 -0500 +++ b/tests/test-hook.t Sat Nov 30 17:43:06 2024 -0500 @@ -979,7 +979,7 @@ (run with --traceback for stack trace) [255] - $ hg pull ../a --traceback 2>&1 | grep -E 'pulling|searching|^exception|Traceback|SyntaxError|ImportError|ModuleNotFoundError|HookLoadError|abort' + $ hg pull ../a --traceback 2>&1 | "$PYTHON" "$TESTDIR/filtertraceback.py" pulling from ../a searching for changes exception from first failed import attempt: @@ -988,14 +988,22 @@ exception from second failed import attempt: Traceback (most recent call last): SyntaxError: * (glob) + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext_syntaxerror' Traceback (most recent call last): SyntaxError: * (glob) + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext_syntaxerror' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): - raise error.HookLoadError(msg, hint=tracebackhint) mercurial.error.HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed @@ -1061,8 +1069,11 @@ $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc $ echo aa > a - $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback' + $ hg --traceback commit -d '0 0' -ma 2>&1 | "$PYTHON" "$TESTDIR/filtertraceback.py" + created new head + error: commit.abort hook failed: raise abort from hook Traceback (most recent call last): + mercurial.error.Abort: raise abort from hook $ cd .. $ hg init c @@ -1146,21 +1157,29 @@ $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc $ echo a >> a - $ hg --traceback commit -ma 2>&1 | grep -E '^exception|ImportError|ModuleNotFoundError|Traceback|HookLoadError|abort' + $ hg --traceback commit -ma 2>&1 | "$PYTHON" "$TESTDIR/filtertraceback.py" exception from first failed import attempt: Traceback (most recent call last): ModuleNotFoundError: No module named 'somebogusmodule' exception from second failed import attempt: Traceback (most recent call last): ModuleNotFoundError: No module named 'somebogusmodule' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext_importfail' Traceback (most recent call last): ModuleNotFoundError: No module named 'somebogusmodule' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): ModuleNotFoundError: No module named 'hgext_importfail' + + During handling of the above exception, another exception occurred: + Traceback (most recent call last): - raise error.HookLoadError(msg, hint=tracebackhint) mercurial.error.HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed abort: precommit.importfail hook is invalid: import of "importfail" failed