From 53bce3913f2f8f146d9678c582ac549d1a53a928 Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 25 May 2020 14:34:01 -0400 Subject: [PATCH] TestHelpers: report Python errors If web.py (or other program) prints the name of a log file, log the contents of that file. Also, turn up verbosity in t/400-web.t. --- t/400-web.t | 4 ++-- t/TestHelpers.pm | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/t/400-web.t b/t/400-web.t index 5cf7018..be5a915 100644 --- a/t/400-web.t +++ b/t/400-web.t @@ -40,14 +40,14 @@ diag $tenv->report; http_request_ok 'index query', $tenv, '/testproj/latest/source', [ qr{^Content-Type:\s*text/html}, qr{href="latest/source/issue102.c"}, - qr{href="latest/source/arch"} ]; + qr{href="latest/source/arch"} ], 1; http_request_ok 'identifier query', $tenv, '/testproj/v5.4/ident/gsb_buffer', [ qr{^Content-Type:\s*text/html}, qr{\bgsb_buffer\b}, qr{"v5.4/source/drivers/i2c/i2c-core-acpi.c\#L23".+? drivers/i2c/i2c-core-acpi.c.+? line[ ]23.+? - \bstruct\b}x ]; + \bstruct\b}x ], 1; # Doc comments: testcases pulled from t/300 http_request_ok 'doc-comment query (nonexistent)', $tenv, diff --git a/t/TestHelpers.pm b/t/TestHelpers.pm index fb196fc..ccaaeb6 100644 --- a/t/TestHelpers.pm +++ b/t/TestHelpers.pm @@ -304,6 +304,22 @@ sub _check_queries { diag "@outlines"; } + # Check for and report Python errors + foreach(@outlines, @errlines) { + if (/^.*?(\S+)\s+contains the description of this error/) { + my $logfn = $1; + + no autodie; + open my $logfh, '<', $logfn + or warn("Could not open Python log file $logfn: $!"), last; + my $logtext = do { local $/; <$logfh> }; + close $logfh; + + diag "Python error log $logfn:\n$logtext"; + last; + } + } + # Basic checks if($mustSucceed) { eval line_mark_string 2, <<'EOT'; @@ -335,7 +351,6 @@ EOT $test .= ($negated ? ' excludes ' : ' includes ') . "\Q$re\E" . '");'; # Run it - #diag "Running $test"; eval line_mark_string 2, $test; die $@ if $@; } #foreach $entry