Do not trim output whitespace prefix

Whitespace prefix of output lines was carried over from the old v1
version, but in some cases it removes too much whitespace. Ideally it
would detect the common prefix of all output lines for a given text and
only trim that. Until that's fixed, let's just stop removing the
whitespace.

Fixes #131
This commit is contained in:
Joël Stemmer 2022-05-13 21:01:49 +01:00
parent 4976b9b9ae
commit 7c195be87f
13 changed files with 51 additions and 51 deletions

View File

@ -259,7 +259,7 @@ func formatBenchmarkTime(d time.Duration) string {
func formatOutput(output []string, indent int) string {
var lines []string
for _, line := range output {
lines = append(lines, gtr.TrimPrefixSpaces(line, indent))
lines = append(lines, line)
}
return strings.Join(lines, "\n")
}

View File

@ -5,10 +5,10 @@
<property name="go.version" value="1.0"></property>
</properties>
<testcase name="TestOne" classname="package/name" time="0.020">
<failure message="Failed"><![CDATA[file_test.go:11: Error message
file_test.go:11: Longer
error
message.]]></failure>
<failure message="Failed"><![CDATA[ file_test.go:11: Error message
file_test.go:11: Longer
error
message.]]></failure>
</testcase>
<testcase name="TestTwo" classname="package/name" time="0.130"></testcase>
<system-out><![CDATA[exit status 1]]></system-out>

View File

@ -5,7 +5,7 @@
<property name="go.version" value="1.0"></property>
</properties>
<testcase name="TestOne" classname="package/name" time="0.020">
<skipped message="Skipped"><![CDATA[file_test.go:11: Skip message]]></skipped>
<skipped message="Skipped"><![CDATA[ file_test.go:11: Skip message]]></skipped>
</testcase>
<testcase name="TestTwo" classname="package/name" time="0.130"></testcase>
</testsuite>

View File

@ -11,10 +11,10 @@
<property name="go.version" value="1.0"></property>
</properties>
<testcase name="TestOne" classname="package/name2" time="0.020">
<failure message="Failed"><![CDATA[file_test.go:11: Error message
file_test.go:11: Longer
error
message.]]></failure>
<failure message="Failed"><![CDATA[ file_test.go:11: Error message
file_test.go:11: Longer
error
message.]]></failure>
</testcase>
<testcase name="TestTwo" classname="package/name2" time="0.130"></testcase>
<system-out><![CDATA[exit status 1]]></system-out>

View File

@ -20,19 +20,19 @@
<failure message="Failed"></failure>
</testcase>
<testcase name="TestFour/#00" classname="package/name" time="0.000">
<failure message="Failed"><![CDATA[example.go:12: Expected abc OBTAINED:
xyz
example.go:123: Expected and obtained are different.]]></failure>
<failure message="Failed"><![CDATA[ example.go:12: Expected abc OBTAINED:
xyz
example.go:123: Expected and obtained are different.]]></failure>
</testcase>
<testcase name="TestFour/#01" classname="package/name" time="0.000">
<skipped message="Skipped"><![CDATA[example.go:1234: Not supported yet.]]></skipped>
<skipped message="Skipped"><![CDATA[ example.go:1234: Not supported yet.]]></skipped>
</testcase>
<testcase name="TestFour/#02" classname="package/name" time="0.000"></testcase>
<testcase name="TestFive" classname="package/name" time="0.000">
<skipped message="Skipped"><![CDATA[example.go:1392: Not supported yet.]]></skipped>
<skipped message="Skipped"><![CDATA[ example.go:1392: Not supported yet.]]></skipped>
</testcase>
<testcase name="TestSix" classname="package/name" time="0.000">
<failure message="Failed"><![CDATA[example.go:371: This should not fail!]]></failure>
<failure message="Failed"><![CDATA[ example.go:371: This should not fail!]]></failure>
</testcase>
</testsuite>
</testsuites>

View File

@ -39,7 +39,7 @@ Goroutine 6 (running) created at:
main.main()
_test/_testmain.go:52 +0x20f
==================
testing.go:610: race detected during execution of test]]></failure>
testing.go:610: race detected during execution of test]]></failure>
</testcase>
<system-out><![CDATA[exit status 1]]></system-out>
</testsuite>

View File

@ -7,15 +7,15 @@
<testcase name="FirstTest" classname="pkg/parallel" time="2.000">
<failure message="Failed"><![CDATA[Message from first
Supplemental from first
parallel_test.go:14: FirstTest error]]></failure>
parallel_test.go:14: FirstTest error]]></failure>
</testcase>
<testcase name="SecondTest" classname="pkg/parallel" time="1.000">
<failure message="Failed"><![CDATA[Message from second
parallel_test.go:23: SecondTest error]]></failure>
parallel_test.go:23: SecondTest error]]></failure>
</testcase>
<testcase name="ThirdTest" classname="pkg/parallel" time="0.010">
<failure message="Failed"><![CDATA[Message from third
parallel_test.go:32: ThirdTest error]]></failure>
parallel_test.go:32: ThirdTest error]]></failure>
</testcase>
<system-out><![CDATA[exit status 1]]></system-out>
</testsuite>

View File

@ -9,10 +9,10 @@
line
stdout
single-line stdout
example_test.go:13: single-line error
example_test.go:14: multi
line
error]]></failure>
example_test.go:13: single-line error
example_test.go:14: multi
line
error]]></failure>
</testcase>
<testcase name="TestFailWithStdoutAndNoTestOutput" classname="package/name1" time="0.150">
<failure message="Failed"><![CDATA[multi
@ -21,10 +21,10 @@ stdout
single-line stdout]]></failure>
</testcase>
<testcase name="TestFailWithTestOutput" classname="package/name1" time="0.200">
<failure message="Failed"><![CDATA[example_test.go:26: single-line error
example_test.go:27: multi
line
error]]></failure>
<failure message="Failed"><![CDATA[ example_test.go:26: single-line error
example_test.go:27: multi
line
error]]></failure>
</testcase>
<testcase name="TestFailWithNoTestOutput" classname="package/name1" time="0.250">
<failure message="Failed"></failure>
@ -41,10 +41,10 @@ example_test.go:27: multi
line
stdout
1 single-line stdout
example_test.go:65: 1 single-line error
example_test.go:66: 1 multi
line
error]]></failure>
example_test.go:65: 1 single-line error
example_test.go:66: 1 multi
line
error]]></failure>
</testcase>
<testcase name="TestSubtests/TestFailWithStdoutAndNoTestOutput" classname="package/name1" time="0.150">
<failure message="Failed"><![CDATA[2 multi
@ -53,10 +53,10 @@ stdout
2 single-line stdout]]></failure>
</testcase>
<testcase name="TestSubtests/TestFailWithTestOutput" classname="package/name1" time="0.200">
<failure message="Failed"><![CDATA[example_test.go:78: 3 single-line error
example_test.go:79: 3 multi
line
error]]></failure>
<failure message="Failed"><![CDATA[ example_test.go:78: 3 single-line error
example_test.go:79: 3 multi
line
error]]></failure>
</testcase>
<testcase name="TestSubtests/TestFailWithNoTestOutput" classname="package/name1" time="0.250">
<failure message="Failed"></failure>

View File

@ -5,10 +5,10 @@
<property name="go.version" value="1.0"></property>
</properties>
<testcase name="TestOne" classname="package/name/fail" time="0.000">
<failure message="Failed"><![CDATA[main_test.go:6: Error message
main_test.go:7: Longer
error
message.]]></failure>
<failure message="Failed"><![CDATA[ main_test.go:6: Error message
main_test.go:7: Longer
error
message.]]></failure>
</testcase>
<testcase name="TestTwo" classname="package/name/fail" time="0.000"></testcase>
<system-out><![CDATA[exit status 1]]></system-out>

View File

@ -9,7 +9,7 @@
</testcase>
<testcase name="TestMultiple/Empty_string" classname="package/name/subtest" time="0.000"></testcase>
<testcase name="TestMultiple/Single" classname="package/name/subtest" time="0.000">
<failure message="Failed"><![CDATA[pkg_test.go:20: Do("a"): got aaaaaaaaaa, want a]]></failure>
<failure message="Failed"><![CDATA[ pkg_test.go:20: Do("a"): got aaaaaaaaaa, want a]]></failure>
</testcase>
<testcase name="TestMultiple/Multi" classname="package/name/subtest" time="0.000"></testcase>
<system-out><![CDATA[exit status 1]]></system-out>

View File

@ -45,9 +45,9 @@ Goroutine 7 (running) created at:
main.main()
_testmain.go:47 +0x2e4
==================
testing.go:1312: race detected during execution of test]]></failure>
testing.go:1312: race detected during execution of test]]></failure>
</testcase>
<system-out><![CDATA[testing.go:1312: race detected during execution of test
<system-out><![CDATA[ testing.go:1312: race detected during execution of test
exit status 1]]></system-out>
</testsuite>
</testsuites>

View File

@ -5,10 +5,10 @@
<property name="go.version" value="1.0"></property>
</properties>
<testcase name="TestSkip" classname="package/name/skip" time="0.000">
<skipped message="Skipped"><![CDATA[skip_test.go:6: skip message]]></skipped>
<skipped message="Skipped"><![CDATA[ skip_test.go:6: skip message]]></skipped>
</testcase>
<testcase name="TestSkipNow" classname="package/name/skip" time="0.000">
<skipped message="Skipped"><![CDATA[skip_test.go:10: log message]]></skipped>
<skipped message="Skipped"><![CDATA[ skip_test.go:10: log message]]></skipped>
</testcase>
</testsuite>
</testsuites>

View File

@ -5,19 +5,19 @@
<property name="go.version" value="1.0"></property>
</properties>
<testcase name="TestP1" classname="package/name/parallel" time="0.000">
<failure message="Failed"><![CDATA[pkg_test.go:10: t.Log(P1)
<failure message="Failed"><![CDATA[ pkg_test.go:10: t.Log(P1)
fmt.Printf(P1)
pkg_test.go:14: P1 error]]></failure>
pkg_test.go:14: P1 error]]></failure>
</testcase>
<testcase name="TestP2" classname="package/name/parallel" time="0.000">
<failure message="Failed"><![CDATA[pkg_test.go:19: t.Log(P2)
<failure message="Failed"><![CDATA[ pkg_test.go:19: t.Log(P2)
fmt.Printf(P2)
pkg_test.go:23: P2 error]]></failure>
pkg_test.go:23: P2 error]]></failure>
</testcase>
<testcase name="TestP3" classname="package/name/parallel" time="0.000">
<failure message="Failed"><![CDATA[pkg_test.go:28: t.Log(P3)
<failure message="Failed"><![CDATA[ pkg_test.go:28: t.Log(P3)
fmt.Printf(P3)
pkg_test.go:32: P3 error]]></failure>
pkg_test.go:32: P3 error]]></failure>
</testcase>
<system-out><![CDATA[exit status 1]]></system-out>
</testsuite>