mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
logformatter: nicer formatting for bats failures
add a new failblock style, with light red background all across the entire page, and use it for bats "FAIL" blocks. Also highlight logrus level=(debug|info|warning|error|fatal) messages in increasingly prominent styles Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -18,7 +18,7 @@ use warnings;
|
|||||||
|
|
||||||
(our $ME = $0) =~ s|.*/||;
|
(our $ME = $0) =~ s|.*/||;
|
||||||
|
|
||||||
our $VERSION = '0.1';
|
our $VERSION = '0.2';
|
||||||
|
|
||||||
# Autoflush stdout
|
# Autoflush stdout
|
||||||
$| = 1;
|
$| = 1;
|
||||||
@ -40,20 +40,20 @@ table.synopsis { border: none; border-collapse: collapse; margin-left: 2em; marg
|
|||||||
.synopsis td { font-weight: bold; font-size: 120%; font-family: monospace; }
|
.synopsis td { font-weight: bold; font-size: 120%; font-family: monospace; }
|
||||||
|
|
||||||
/* test results */
|
/* test results */
|
||||||
.testname { font-size: 125%; color: #444; }
|
.testname { font-size: 125%; color: #444; }
|
||||||
.boring { color: #999; }
|
.boring { color: #999; }
|
||||||
.timestamp { color: #999; }
|
.timestamp { color: #999; }
|
||||||
.log-debug { color: #999; }
|
.log-debug { color: #999; }
|
||||||
.log-info { color: #333; }
|
.log-info { color: #333; }
|
||||||
.log-warn { color: #f60; }
|
.log-warning { color: #f60; }
|
||||||
.log-error { color: #900; font-weight: bold; }
|
.log-error { color: #900; font-weight: bold; }
|
||||||
.log-skip { color: #F90; }
|
.log-skip { color: #F90; }
|
||||||
.log-slow { background: #FF0; color: #000; font-weight: bold; }
|
.log-slow { background: #FF0; color: #000; font-weight: bold; }
|
||||||
.subtest { background: #eee; }
|
.subtest { background: #eee; }
|
||||||
.subsubtest { color: #F39; font-weight: bold; }
|
.subsubtest { color: #F39; font-weight: bold; }
|
||||||
.string { color: #00c; }
|
.string { color: #00c; }
|
||||||
.command { font-weight: bold; color: #000; }
|
.command { font-weight: bold; color: #000; }
|
||||||
.changed { color: #000; font-weight: bold; }
|
.changed { color: #000; font-weight: bold; }
|
||||||
|
|
||||||
/* links to source files: not as prominent as links to errors */
|
/* links to source files: not as prominent as links to errors */
|
||||||
a.codelink:link { color: #000; }
|
a.codelink:link { color: #000; }
|
||||||
@ -68,8 +68,8 @@ a.timing { text-decoration: none; }
|
|||||||
.bats-passed { color: #393; }
|
.bats-passed { color: #393; }
|
||||||
.bats-failed { color: #F00; font-weight: bold; }
|
.bats-failed { color: #F00; font-weight: bold; }
|
||||||
.bats-skipped { color: #F90; }
|
.bats-skipped { color: #F90; }
|
||||||
.bats-log { color: #900; }
|
.bats-log { color: #933; }
|
||||||
.bats-log-esm { color: #b00; font-weight: bold; }
|
.bats-log-failblock { color: #b00; background-color: #fee; display: inline-flex; margin: 0 -500%; padding: 0 500% !important; }
|
||||||
|
|
||||||
.bats-summary { font-size: 150%; }
|
.bats-summary { font-size: 150%; }
|
||||||
|
|
||||||
@ -285,6 +285,13 @@ END_HTML
|
|||||||
$cirrus_task = $1;
|
$cirrus_task = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# logrus messages, always highlighted
|
||||||
|
# 1 2 2 13 34 4 5 56 6 7 78 8
|
||||||
|
if ($line =~ /^(\s*(#\s)?)(time=)(.*) (level=)(\S+) (msg=)(.*)/) {
|
||||||
|
my $span = "<span class='log-$6'>";
|
||||||
|
$line = "$1$3$span$4</span> $5$span$6</span> $7$span$8</span>";
|
||||||
|
}
|
||||||
|
|
||||||
# BATS handling. This will recognize num_tests both at start and end
|
# BATS handling. This will recognize num_tests both at start and end
|
||||||
if ($line =~ /^1\.\.(\d+)$/) {
|
if ($line =~ /^1\.\.(\d+)$/) {
|
||||||
$looks_like_bats = 1;
|
$looks_like_bats = 1;
|
||||||
@ -331,11 +338,11 @@ END_HTML
|
|||||||
$line =~ s{^(#\s+(#|\$)\s+)(\S+/)(podman\S*)(\s.*)}
|
$line =~ s{^(#\s+(#|\$)\s+)(\S+/)(podman\S*)(\s.*)}
|
||||||
{$1<b><span title="$3$4">$4</span>$5</b>};
|
{$1<b><span title="$3$4">$4</span>$5</b>};
|
||||||
|
|
||||||
if ($line =~ /^ok\s.*\s# skip/) { $css = 'skipped' }
|
if ($line =~ /^ok\s.*\s# skip/) { $css = 'skipped' }
|
||||||
elsif ($line =~ /^ok\s/) { $css = 'passed' }
|
elsif ($line =~ /^ok\s/) { $css = 'passed' }
|
||||||
elsif ($line =~ /^not\s+ok\s/) { $css = 'failed' }
|
elsif ($line =~ /^not\s+ok\s/) { $css = 'failed' }
|
||||||
elsif ($line =~ /^#\s#\|\s/) { $css = 'log-esm' }
|
elsif ($line =~ /^# #(\/v|\| |\\\^)/) { $css = 'log-failblock' }
|
||||||
elsif ($line =~ /^#\s/) { $css = 'log' }
|
elsif ($line =~ /^#\s/) { $css = 'log' }
|
||||||
|
|
||||||
# Link to source file. This is ugly: we have to hardcode 'podman'
|
# Link to source file. This is ugly: we have to hardcode 'podman'
|
||||||
# and 'test/system' because there's no way to get them from log.
|
# and 'test/system' because there's no way to get them from log.
|
||||||
@ -444,7 +451,7 @@ END_HTML
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ($line =~ /^Error:/ || $line =~ / level=(warning|error) /) {
|
elsif ($line =~ /^Error:/ || $line =~ / level=(warning|error) /) {
|
||||||
$line = "<span class='log-warn'>" . $line . "</span>";
|
$line = "<span class='log-warning'>" . $line . "</span>";
|
||||||
}
|
}
|
||||||
elsif ($line =~ /^panic:/) {
|
elsif ($line =~ /^panic:/) {
|
||||||
$line = "<span class='log-error'>" . $line . "</span>";
|
$line = "<span class='log-error'>" . $line . "</span>";
|
||||||
|
@ -95,6 +95,8 @@ not ok 3 fail
|
|||||||
# from function `expect_output' in file ./helpers.bash, line 370,
|
# from function `expect_output' in file ./helpers.bash, line 370,
|
||||||
# in test file ./run.bats, line 786)
|
# in test file ./run.bats, line 786)
|
||||||
# $ /path/to/podman foo -bar
|
# $ /path/to/podman foo -bar
|
||||||
|
# time="2023-01-05T15:15:20Z" level=debug msg="this is debug"
|
||||||
|
# time="2023-01-05T15:15:20Z" level=warning msg="this is warning"
|
||||||
# #| FAIL: exit code is 123; expected 321
|
# #| FAIL: exit code is 123; expected 321
|
||||||
ok 4 blah
|
ok 4 blah
|
||||||
>>>
|
>>>
|
||||||
@ -106,7 +108,9 @@ ok 4 blah
|
|||||||
<span class='bats-log'># from function `expect_output' in file ./<a class="codelink" href="https://github.com/containers/podman/blob/ceci-nest-pas-une-sha/test/system/helpers.bash#L370">helpers.bash, line 370</a>,</span>
|
<span class='bats-log'># from function `expect_output' in file ./<a class="codelink" href="https://github.com/containers/podman/blob/ceci-nest-pas-une-sha/test/system/helpers.bash#L370">helpers.bash, line 370</a>,</span>
|
||||||
<span class='bats-log'># in test file ./<a class="codelink" href="https://github.com/containers/podman/blob/ceci-nest-pas-une-sha/test/system/run.bats#L786">run.bats, line 786</a>)</span>
|
<span class='bats-log'># in test file ./<a class="codelink" href="https://github.com/containers/podman/blob/ceci-nest-pas-une-sha/test/system/run.bats#L786">run.bats, line 786</a>)</span>
|
||||||
<span class='bats-log'># $ <b><span title="/path/to/podman">podman</span> foo -bar</b></span>
|
<span class='bats-log'># $ <b><span title="/path/to/podman">podman</span> foo -bar</b></span>
|
||||||
<span class='bats-log-esm'># #| FAIL: exit code is 123; expected 321</span>
|
<span class='bats-log'># time=<span class='log-debug'>"2023-01-05T15:15:20Z"</span> level=<span class='log-debug'>debug</span> msg=<span class='log-debug'>"this is debug"</span></span>
|
||||||
|
<span class='bats-log'># time=<span class='log-warning'>"2023-01-05T15:15:20Z"</span> level=<span class='log-warning'>warning</span> msg=<span class='log-warning'>"this is warning"</span></span>
|
||||||
|
<span class='bats-log-failblock'># #| FAIL: exit code is 123; expected 321</span>
|
||||||
<span class='bats-passed'><a name='t--00004'>ok 4 blah</a></span>
|
<span class='bats-passed'><a name='t--00004'>ok 4 blah</a></span>
|
||||||
<hr/><span class='bats-summary'>Summary: <span class='bats-passed'>2 Passed</span>, <span class='bats-failed'>1 Failed</span>, <span class='bats-skipped'>1 Skipped</span>. Total tests: 4</span>
|
<hr/><span class='bats-summary'>Summary: <span class='bats-passed'>2 Passed</span>, <span class='bats-failed'>1 Failed</span>, <span class='bats-skipped'>1 Skipped</span>. Total tests: 4</span>
|
||||||
|
|
||||||
@ -209,7 +213,7 @@ $SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP}
|
|||||||
--tmpdir /tmp/podman_test553496330
|
--tmpdir /tmp/podman_test553496330
|
||||||
--events-backend file
|
--events-backend file
|
||||||
--storage-driver vfs">[options]</span><b> pod restart 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89</b>
|
--storage-driver vfs">[options]</span><b> pod restart 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89</b>
|
||||||
<span class="timestamp"> </span><span class='log-warn'>Error: no containers in pod 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 have no dependencies, cannot start pod: no such container</span>
|
<span class="timestamp"> </span><span class='log-warning'>Error: no containers in pod 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 have no dependencies, cannot start pod: no such container</span>
|
||||||
<span class="timestamp"> </span>output:
|
<span class="timestamp"> </span>output:
|
||||||
<span class="timestamp"> </span>[AfterEach] Podman pod restart
|
<span class="timestamp"> </span>[AfterEach] Podman pod restart
|
||||||
<span class="timestamp"> </span> /var/tmp/go/src/github.com<a class="codelink" href='https://github.com/containers/podman/blob/40f5d8b1becd381c4e8283ed3940d09193e4fe06/test/e2e/pod_restart_test.go#L28'>/containers/podman/test/e2e/pod_restart_test.go:28</a>
|
<span class="timestamp"> </span> /var/tmp/go/src/github.com<a class="codelink" href='https://github.com/containers/podman/blob/40f5d8b1becd381c4e8283ed3940d09193e4fe06/test/e2e/pod_restart_test.go#L28'>/containers/podman/test/e2e/pod_restart_test.go:28</a>
|
||||||
|
Reference in New Issue
Block a user