gtr: Handle end_test events without corresponding run_test event

When running `go test` without the `-v` flag, the output may not contain
everything that we expect. For example, no output is generated for
passing tests. Even for a failing test the output does not contain a
`=== RUN` line.

Currently, this resulted in us ignoring the test result since we
couldn't find an existing test to assign this result to. We should
however handle this situation gracefully, and just assume a test exists
when only encountering a test result line.

References #109
This commit is contained in:
Joël Stemmer
2022-02-27 22:08:50 +00:00
parent 014828bef4
commit 817a23b10d
6 changed files with 41 additions and 31 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="5" failures="3">
<testsuites tests="5" errors="3">
<testsuite tests="1" failures="0" errors="0" time="0.100" name="package/name/passing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
@ -12,28 +12,28 @@
</properties>
<testcase classname="passing2" name="TestB" time="0.100"></testcase>
</testsuite>
<testsuite tests="1" failures="1" errors="0" time="0.000" name="package/name/failing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuite tests="1" failures="0" errors="1" time="0.000" name="package/name/failing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="failing1" name="[build failed]" time="0.000">
<failure message="Failed" type="">failing1/failing_test.go:15: undefined: x</failure>
<error message="Build error" type="">failing1/failing_test.go:15: undefined: x</error>
</testcase>
</testsuite>
<testsuite tests="1" failures="1" errors="0" time="0.000" name="package/name/failing2" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuite tests="1" failures="0" errors="1" time="0.000" name="package/name/failing2" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="failing2" name="[build failed]" time="0.000">
<failure message="Failed" type="">failing2/another_failing_test.go:20: undefined: y</failure>
<error message="Build error" type="">failing2/another_failing_test.go:20: undefined: y</error>
</testcase>
</testsuite>
<testsuite tests="1" failures="1" errors="0" time="0.000" name="package/name/setupfailing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuite tests="1" failures="0" errors="1" time="0.000" name="package/name/setupfailing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="setupfailing1" name="[setup failed]" time="0.000">
<failure message="Failed" type="">setupfailing1/failing_test.go:4: cannot find package &#34;other/package&#34; in any of:&#xA;&#x9;/path/vendor (vendor tree)&#xA;&#x9;/path/go/root (from $GOROOT)&#xA;&#x9;/path/go/path (from $GOPATH)</failure>
<error message="Build error" type="">setupfailing1/failing_test.go:4: cannot find package &#34;other/package&#34; in any of:&#xA;&#x9;/path/vendor (vendor tree)&#xA;&#x9;/path/go/root (from $GOROOT)&#xA;&#x9;/path/go/path (from $GOPATH)</error>
</testcase>
</testsuite>
</testsuites>

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="2" failures="2">
<testsuite tests="1" failures="1" errors="0" time="0.003" name="package/panic" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuites tests="2" errors="2">
<testsuite tests="1" failures="0" errors="1" time="0.003" name="package/panic" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="panic" name="Failure" time="0.000">
<failure message="Failed" type="">panic: init&#xA;stacktrace</failure>
<error message="Run error" type="">panic: init&#xA;stacktrace</error>
</testcase>
</testsuite>
<testsuite tests="1" failures="1" errors="0" time="0.003" name="package/panic2" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuite tests="1" failures="0" errors="1" time="0.003" name="package/panic2" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="panic2" name="Failure" time="0.000">
<failure message="Failed" type="">panic: init&#xA;stacktrace</failure>
<error message="Run error" type="">panic: init&#xA;stacktrace</error>
</testcase>
</testsuite>
</testsuites>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="5" failures="3">
<testsuites tests="5" errors="3">
<testsuite tests="1" failures="0" errors="0" time="0.100" name="package/name/passing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
@ -12,28 +12,28 @@
</properties>
<testcase classname="passing2" name="TestB" time="0.100"></testcase>
</testsuite>
<testsuite tests="1" failures="1" errors="0" time="0.000" name="package/name/failing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuite tests="1" failures="0" errors="1" time="0.000" name="package/name/failing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="failing1" name="[build failed]" time="0.000">
<failure message="Failed" type="">failing1/failing_test.go:15: undefined: x</failure>
<error message="Build error" type="">failing1/failing_test.go:15: undefined: x</error>
</testcase>
</testsuite>
<testsuite tests="1" failures="1" errors="0" time="0.000" name="package/name/failing2" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuite tests="1" failures="0" errors="1" time="0.000" name="package/name/failing2" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="failing2" name="[build failed]" time="0.000">
<failure message="Failed" type="">failing2/another_failing_test.go:20: undefined: y</failure>
<error message="Build error" type="">failing2/another_failing_test.go:20: undefined: y</error>
</testcase>
</testsuite>
<testsuite tests="1" failures="1" errors="0" time="0.000" name="package/name/setupfailing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuite tests="1" failures="0" errors="1" time="0.000" name="package/name/setupfailing1" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="setupfailing1" name="[setup failed]" time="0.000">
<failure message="Failed" type="">setupfailing1/failing_test.go:4: cannot find package &#34;other/package&#34; in any of:&#xA;&#x9;/path/vendor (vendor tree)&#xA;&#x9;/path/go/root (from $GOROOT)&#xA;&#x9;/path/go/path (from $GOPATH)</failure>
<error message="Build error" type="">setupfailing1/failing_test.go:4: cannot find package &#34;other/package&#34; in any of:&#xA;&#x9;/path/vendor (vendor tree)&#xA;&#x9;/path/go/root (from $GOROOT)&#xA;&#x9;/path/go/path (from $GOPATH)</error>
</testcase>
</testsuite>
</testsuites>

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="2" failures="1">
<testsuite tests="2" failures="1" errors="0" time="0.005" name="github.com/jstemmer/test/failedsummary" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<testsuites tests="2" errors="1">
<testsuite tests="2" failures="0" errors="1" time="0.005" name="github.com/jstemmer/test/failedsummary" hostname="hostname" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
<testcase classname="failedsummary" name="TestOne" time="0.000"></testcase>
<testcase classname="failedsummary" name="Failure" time="0.000">
<failure message="Failed" type="">panic: panic</failure>
<error message="Run error" type="">panic: panic</error>
</testcase>
</testsuite>
</testsuites>