From 4d05b2dc3f0514c5815085e5c71606f0ca450d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Fri, 13 May 2022 21:55:44 +0100 Subject: [PATCH] Regenerate testdata files Many of the testdata files were generated a long time ago with very old versions of Go. The Go test output has changed over time, and these test inputs no longer reflect the current state. The intention is to fully support the test output of the most recent Go versions. This commit also includes the source used to generate the test output, so the output can be more easily updated in the future. --- testdata/001-pass-fail-skip.txt | 27 ++++++ testdata/001-pass.txt | 6 -- testdata/001-report.xml | 30 +++++- testdata/002-fail.txt | 11 --- testdata/002-report.xml | 16 ---- testdata/003-report.xml | 12 --- testdata/003-skip.txt | 7 -- testdata/004-go_1_4.txt | 6 -- testdata/004-report.xml | 10 -- testdata/005-no-xml-header.txt | 10 ++ testdata/005-no_xml_header.txt | 6 -- testdata/005-report.xml | 6 +- testdata/006-mixed.txt | 17 ---- testdata/006-report.xml | 22 ----- testdata/008-parallel.txt | 33 +++++-- testdata/008-report.xml | 19 +++- testdata/012-go_1_7.txt | 44 --------- testdata/012-report.xml | 44 ++++----- testdata/012-subtests.txt | 31 +++++++ testdata/017-race.txt | 51 ++++++----- testdata/017-report.xml | 54 ++++++----- testdata/020-parallel.txt | 19 ---- testdata/020-report.xml | 22 ----- testdata/024-benchtests.txt | 19 ++-- testdata/024-report.xml | 16 ++-- testdata/030-report.xml | 69 +++++++------- testdata/030-stdout.txt | 101 +++++++++++---------- testdata/035-report.xml | 20 ++-- testdata/035-whitespace.txt | 70 +++++++------- testdata/generate-golden-reports.go | 2 +- testdata/src/bench/bench_test.go | 23 +++++ testdata/src/fail/fail_test.go | 8 ++ testdata/src/go.mod | 3 + testdata/src/parallel/pkg_test.go | 27 ++++++ testdata/src/pass/pass.go | 14 +++ testdata/src/pass/pass_test.go | 11 +++ testdata/src/race/race_test.go | 15 +++ testdata/src/skip/skip_test.go | 12 +++ testdata/src/stdout/stdout_test.go | 59 ++++++++++++ testdata/src/subtests/subtests_test.go | 33 +++++++ testdata/src/whitespace/whitespace_test.go | 53 +++++++++++ 41 files changed, 614 insertions(+), 444 deletions(-) create mode 100644 testdata/001-pass-fail-skip.txt delete mode 100644 testdata/001-pass.txt delete mode 100644 testdata/002-fail.txt delete mode 100644 testdata/002-report.xml delete mode 100644 testdata/003-report.xml delete mode 100644 testdata/003-skip.txt delete mode 100644 testdata/004-go_1_4.txt delete mode 100644 testdata/004-report.xml create mode 100644 testdata/005-no-xml-header.txt delete mode 100644 testdata/005-no_xml_header.txt delete mode 100644 testdata/006-mixed.txt delete mode 100644 testdata/006-report.xml delete mode 100644 testdata/012-go_1_7.txt create mode 100644 testdata/012-subtests.txt delete mode 100644 testdata/020-parallel.txt delete mode 100644 testdata/020-report.xml create mode 100644 testdata/src/bench/bench_test.go create mode 100644 testdata/src/fail/fail_test.go create mode 100644 testdata/src/go.mod create mode 100644 testdata/src/parallel/pkg_test.go create mode 100644 testdata/src/pass/pass.go create mode 100644 testdata/src/pass/pass_test.go create mode 100644 testdata/src/race/race_test.go create mode 100644 testdata/src/skip/skip_test.go create mode 100644 testdata/src/stdout/stdout_test.go create mode 100644 testdata/src/subtests/subtests_test.go create mode 100644 testdata/src/whitespace/whitespace_test.go diff --git a/testdata/001-pass-fail-skip.txt b/testdata/001-pass-fail-skip.txt new file mode 100644 index 0000000..07e8f23 --- /dev/null +++ b/testdata/001-pass-fail-skip.txt @@ -0,0 +1,27 @@ +=== RUN TestPass +--- PASS: TestPass (0.06s) +=== RUN TestPassLog + pass_test.go:9: log line + pass_test.go:10: log + multi + line +--- PASS: TestPassLog (0.10s) +PASS +ok package/pass 0.160s +=== RUN TestOne + fail_test.go:6: Error message + fail_test.go:7: Longer + error + message. +--- FAIL: TestOne (0.151s) +FAIL +FAIL package/fail 0.151s +=== RUN TestSkip + skip_test.go:6: skip message +--- SKIP: TestSkip (0.02s) +=== RUN TestSkipNow + skip_test.go:10: log message +--- SKIP: TestSkipNow (0.13s) +PASS +ok package/skip 0.150s +FAIL diff --git a/testdata/001-pass.txt b/testdata/001-pass.txt deleted file mode 100644 index 0a4eeae..0000000 --- a/testdata/001-pass.txt +++ /dev/null @@ -1,6 +0,0 @@ -=== RUN TestZ ---- PASS: TestZ (0.06 seconds) -=== RUN TestA ---- PASS: TestA (0.10 seconds) -PASS -ok package/name 0.160s diff --git a/testdata/001-report.xml b/testdata/001-report.xml index 11db67d..9f6211b 100644 --- a/testdata/001-report.xml +++ b/testdata/001-report.xml @@ -1,10 +1,32 @@ - - + + - - + + + + + + + + + + + + + + + + + + + + + diff --git a/testdata/002-fail.txt b/testdata/002-fail.txt deleted file mode 100644 index 905c4d9..0000000 --- a/testdata/002-fail.txt +++ /dev/null @@ -1,11 +0,0 @@ -=== RUN TestOne ---- FAIL: TestOne (0.02 seconds) - file_test.go:11: Error message - file_test.go:11: Longer - error - message. -=== RUN TestTwo ---- PASS: TestTwo (0.13 seconds) -FAIL -exit status 1 -FAIL package/name 0.151s diff --git a/testdata/002-report.xml b/testdata/002-report.xml deleted file mode 100644 index 89380ca..0000000 --- a/testdata/002-report.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/testdata/003-report.xml b/testdata/003-report.xml deleted file mode 100644 index 2fe012b..0000000 --- a/testdata/003-report.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/testdata/003-skip.txt b/testdata/003-skip.txt deleted file mode 100644 index 155938a..0000000 --- a/testdata/003-skip.txt +++ /dev/null @@ -1,7 +0,0 @@ -=== RUN TestOne ---- SKIP: TestOne (0.02 seconds) - file_test.go:11: Skip message -=== RUN TestTwo ---- PASS: TestTwo (0.13 seconds) -PASS -ok package/name 0.150s diff --git a/testdata/004-go_1_4.txt b/testdata/004-go_1_4.txt deleted file mode 100644 index 13fe892..0000000 --- a/testdata/004-go_1_4.txt +++ /dev/null @@ -1,6 +0,0 @@ -=== RUN TestOne ---- PASS: TestOne (0.06s) -=== RUN TestTwo ---- PASS: TestTwo (0.10s) -PASS -ok package/name 0.160s \ No newline at end of file diff --git a/testdata/004-report.xml b/testdata/004-report.xml deleted file mode 100644 index 23618ba..0000000 --- a/testdata/004-report.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/testdata/005-no-xml-header.txt b/testdata/005-no-xml-header.txt new file mode 100644 index 0000000..a3caede --- /dev/null +++ b/testdata/005-no-xml-header.txt @@ -0,0 +1,10 @@ +=== RUN TestPass +--- PASS: TestPass (0.06s) +=== RUN TestPassLog + pass_test.go:9: log line + pass_test.go:10: log + multi + line +--- PASS: TestPassLog (0.10s) +PASS +ok package/pass 0.160s diff --git a/testdata/005-no_xml_header.txt b/testdata/005-no_xml_header.txt deleted file mode 100644 index 13fe892..0000000 --- a/testdata/005-no_xml_header.txt +++ /dev/null @@ -1,6 +0,0 @@ -=== RUN TestOne ---- PASS: TestOne (0.06s) -=== RUN TestTwo ---- PASS: TestTwo (0.10s) -PASS -ok package/name 0.160s \ No newline at end of file diff --git a/testdata/005-report.xml b/testdata/005-report.xml index 6709b1d..c147077 100644 --- a/testdata/005-report.xml +++ b/testdata/005-report.xml @@ -1,9 +1,9 @@ - + - - + + diff --git a/testdata/006-mixed.txt b/testdata/006-mixed.txt deleted file mode 100644 index a2a744d..0000000 --- a/testdata/006-mixed.txt +++ /dev/null @@ -1,17 +0,0 @@ -=== RUN TestOne ---- PASS: TestOne (0.06 seconds) -=== RUN TestTwo ---- PASS: TestTwo (0.10 seconds) -PASS -ok package/name1 0.160s -=== RUN TestOne ---- FAIL: TestOne (0.02 seconds) - file_test.go:11: Error message - file_test.go:11: Longer - error - message. -=== RUN TestTwo ---- PASS: TestTwo (0.13 seconds) -FAIL -exit status 1 -FAIL package/name2 0.151s diff --git a/testdata/006-report.xml b/testdata/006-report.xml deleted file mode 100644 index fb081e2..0000000 --- a/testdata/006-report.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/testdata/008-parallel.txt b/testdata/008-parallel.txt index 6bdb8cb..f39aae8 100644 --- a/testdata/008-parallel.txt +++ b/testdata/008-parallel.txt @@ -1,10 +1,23 @@ -=== RUN TestDoFoo -=== RUN TestDoFoo2 ---- PASS: TestDoFoo (0.27s) - cov_test.go:10: DoFoo log 1 - cov_test.go:10: DoFoo log 2 ---- PASS: TestDoFoo2 (0.16s) - cov_test.go:21: DoFoo2 log 1 - cov_test.go:21: DoFoo2 log 2 -PASS -ok package/name 0.440s +=== RUN TestP1 +=== PAUSE TestP1 +=== RUN TestP2 +=== PAUSE TestP2 +=== RUN TestP3 +=== PAUSE TestP3 +=== CONT TestP1 + pkg_test.go:10: t.Log(P1) +=== CONT TestP3 + pkg_test.go:24: t.Log(P3) +=== CONT TestP2 + pkg_test.go:17: t.Log(P2) + pkg_test.go:19: P2 error +--- FAIL: TestP2 (0.05s) +=== CONT TestP3 + pkg_test.go:26: P3 error +--- FAIL: TestP3 (0.08s) +=== CONT TestP1 + pkg_test.go:12: P1 error +--- FAIL: TestP1 (0.10s) +FAIL +exit status 1 +FAIL package/parallel 0.102s diff --git a/testdata/008-report.xml b/testdata/008-report.xml index 2f5974a..4b7b7e6 100644 --- a/testdata/008-report.xml +++ b/testdata/008-report.xml @@ -1,10 +1,21 @@ - - + + - - + + + + + + + + + + diff --git a/testdata/012-go_1_7.txt b/testdata/012-go_1_7.txt deleted file mode 100644 index bbb322d..0000000 --- a/testdata/012-go_1_7.txt +++ /dev/null @@ -1,44 +0,0 @@ -=== RUN TestOne -=== RUN TestOne/Child -=== RUN TestOne/Child#01 -=== RUN TestOne/Child=02 ---- PASS: TestOne (0.01s) - --- PASS: TestOne/Child (0.02s) - --- PASS: TestOne/Child#01 (0.03s) - --- PASS: TestOne/Child=02 (0.04s) -=== RUN TestTwo -=== RUN TestTwo/Child -=== RUN TestTwo/Child#01 -=== RUN TestTwo/Child=02 ---- PASS: TestTwo (0.01s) - --- PASS: TestTwo/Child (0.02s) - --- PASS: TestTwo/Child#01 (0.03s) - --- PASS: TestTwo/Child=02 (0.04s) -=== RUN TestThree -=== RUN TestThree/a#1 -=== RUN TestThree/a#1/b#1 -=== RUN TestThree/a#1/b#1/c#1 ---- PASS: TestThree (0.01s) - --- PASS: TestThree/a#1 (0.02s) - --- PASS: TestThree/a#1/b#1 (0.03s) - --- PASS: TestThree/a#1/b#1/c#1 (0.04s) -=== RUN TestFour -=== RUN TestFour/#00 -=== RUN TestFour/#01 -=== RUN TestFour/#02 ---- FAIL: TestFour (0.02s) - --- FAIL: TestFour/#00 (0.00s) - example.go:12: Expected abc OBTAINED: - xyz - example.go:123: Expected and obtained are different. - --- SKIP: TestFour/#01 (0.00s) - example.go:1234: Not supported yet. - --- PASS: TestFour/#02 (0.00s) -=== RUN TestFive ---- SKIP: TestFive (0.00s) - example.go:1392: Not supported yet. -=== RUN TestSix ---- FAIL: TestSix (0.00s) - example.go:371: This should not fail! -FAIL -FAIL package/name 0.050s diff --git a/testdata/012-report.xml b/testdata/012-report.xml index 659b959..907e171 100644 --- a/testdata/012-report.xml +++ b/testdata/012-report.xml @@ -1,38 +1,30 @@ - - + + - - - - - - - - - - - - - + - - + + + - - + + - - - + + + + + + - - + + + + diff --git a/testdata/012-subtests.txt b/testdata/012-subtests.txt new file mode 100644 index 0000000..0c71f4e --- /dev/null +++ b/testdata/012-subtests.txt @@ -0,0 +1,31 @@ +=== RUN TestSubtests +=== RUN TestSubtests/Subtest + subtests_test.go:7: ok +=== RUN TestSubtests/Subtest#01 + subtests_test.go:10: error message +=== RUN TestSubtests/Subtest#02 + subtests_test.go:13: skip message +--- FAIL: TestSubtests (0.00s) + --- PASS: TestSubtests/Subtest (0.00s) + --- FAIL: TestSubtests/Subtest#01 (0.00s) + --- SKIP: TestSubtests/Subtest#02 (0.00s) +=== RUN TestNestedSubtests +=== RUN TestNestedSubtests/a#1 +=== RUN TestNestedSubtests/a#1/b#1 +=== RUN TestNestedSubtests/a#1/b#1/c#1 +--- PASS: TestNestedSubtests (0.00s) + --- PASS: TestNestedSubtests/a#1 (0.00s) + --- PASS: TestNestedSubtests/a#1/b#1 (0.00s) + --- PASS: TestNestedSubtests/a#1/b#1/c#1 (0.00s) +=== RUN TestFailingSubtestWithNestedSubtest +=== RUN TestFailingSubtestWithNestedSubtest/Subtest +=== RUN TestFailingSubtestWithNestedSubtest/Subtest/Subsubtest + subtests_test.go:29: ok +=== CONT TestFailingSubtestWithNestedSubtest/Subtest + subtests_test.go:31: Subtest error message +--- FAIL: TestFailingSubtestWithNestedSubtest (0.00s) + --- FAIL: TestFailingSubtestWithNestedSubtest/Subtest (0.00s) + --- PASS: TestFailingSubtestWithNestedSubtest/Subtest/Subsubtest (0.00s) +FAIL +exit status 1 +FAIL package/subtests 0.001s diff --git a/testdata/017-race.txt b/testdata/017-race.txt index 42b9728..aa3af73 100644 --- a/testdata/017-race.txt +++ b/testdata/017-race.txt @@ -1,40 +1,45 @@ === RUN TestRace -test output -2 0xc4200153d0 + race_test.go:13: x = 3 ================== WARNING: DATA RACE -Write at 0x00c4200153d0 by goroutine 7: - race_test.TestRace.func1() - race_test.go:13 +0x3b +Write at 0x00c000138168 by goroutine 8: + package/race.TestRace.func1() + /src/github.com/jstemmer/go-junit-report/testdata/src/race/race_test.go:9 +0x39 -Previous write at 0x00c4200153d0 by goroutine 6: - race_test.TestRace() - race_test.go:15 +0x136 +Previous write at 0x00c000138168 by goroutine 7: + package/race.TestRace() + /src/github.com/jstemmer/go-junit-report/testdata/src/race/race_test.go:12 +0x105 testing.tRunner() - /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107 + /go-src/go1.18/src/testing/testing.go:1439 +0x213 + testing.(*T).Run.func1() + /go-src/go1.18/src/testing/testing.go:1486 +0x47 + +Goroutine 8 (running) created at: + package/race.TestRace() + /src/github.com/jstemmer/go-junit-report/testdata/src/race/race_test.go:8 +0xfb + testing.tRunner() + /go-src/go1.18/src/testing/testing.go:1439 +0x213 + testing.(*T).Run.func1() + /go-src/go1.18/src/testing/testing.go:1486 +0x47 Goroutine 7 (running) created at: - race_test.TestRace() - race_test.go:14 +0x125 - testing.tRunner() - /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107 - -Goroutine 6 (running) created at: testing.(*T).Run() - /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x543 + /go-src/go1.18/src/testing/testing.go:1486 +0x724 testing.runTests.func1() - /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:882 +0xaa + /go-src/go1.18/src/testing/testing.go:1839 +0x99 testing.tRunner() - /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107 + /go-src/go1.18/src/testing/testing.go:1439 +0x213 testing.runTests() - /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:888 +0x4e0 + /go-src/go1.18/src/testing/testing.go:1837 +0x7e4 testing.(*M).Run() - /usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:822 +0x1c3 + /go-src/go1.18/src/testing/testing.go:1719 +0xa71 main.main() - _test/_testmain.go:52 +0x20f + _testmain.go:47 +0x2e4 ================== + testing.go:1312: race detected during execution of test --- FAIL: TestRace (0.00s) - testing.go:610: race detected during execution of test +=== CONT + testing.go:1312: race detected during execution of test FAIL exit status 1 -FAIL race_test 0.015s \ No newline at end of file +FAIL package/race 0.005s diff --git a/testdata/017-report.xml b/testdata/017-report.xml index a216621..0a6554a 100644 --- a/testdata/017-report.xml +++ b/testdata/017-report.xml @@ -1,46 +1,50 @@ - + - - + + testing.go:1312: race detected during execution of test]]> - + diff --git a/testdata/020-parallel.txt b/testdata/020-parallel.txt deleted file mode 100644 index cd675fc..0000000 --- a/testdata/020-parallel.txt +++ /dev/null @@ -1,19 +0,0 @@ -=== RUN FirstTest -Message from first -=== PAUSE FirstTest -=== RUN SecondTest -Message from second -=== PAUSE SecondTest -=== CONT FirstTest -Supplemental from first -=== RUN ThirdTest -Message from third ---- FAIL: ThirdTest (0.01s) - parallel_test.go:32: ThirdTest error ---- FAIL: FirstTest (2.00s) - parallel_test.go:14: FirstTest error ---- FAIL: SecondTest (1.00s) - parallel_test.go:23: SecondTest error -FAIL -exit status 1 -FAIL pkg/parallel 3.010s diff --git a/testdata/020-report.xml b/testdata/020-report.xml deleted file mode 100644 index 237bb6c..0000000 --- a/testdata/020-report.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/testdata/024-benchtests.txt b/testdata/024-benchtests.txt index f20b669..220d7da 100644 --- a/testdata/024-benchtests.txt +++ b/testdata/024-benchtests.txt @@ -1,15 +1,8 @@ -=== RUN TestNew -=== RUN TestNew/no -=== RUN TestNew/normal ---- PASS: TestNew (0.00s) - --- PASS: TestNew/no (0.00s) - --- PASS: TestNew/normal (0.00s) -=== RUN TestWriteThis ---- PASS: TestWriteThis (0.00s) -goos: darwin +goos: linux goarch: amd64 -pkg: package3/baz -BenchmarkDeepMerge-8 500000 2611 ns/op 1110 B/op 16 allocs/op -BenchmarkNext-8 500000 100 ns/op 100 B/op 1 allocs/op +pkg: package/bench +cpu: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz +BenchmarkOne-8 1000000000 0.2640 ns/op +BenchmarkTwo-8 39787592 33.10 ns/op PASS -ok package3/baz 1.382s \ No newline at end of file +ok package/bench 1.642s diff --git a/testdata/024-report.xml b/testdata/024-report.xml index 7c678ad..91f9cdd 100644 --- a/testdata/024-report.xml +++ b/testdata/024-report.xml @@ -1,14 +1,14 @@ - - + + - - - - - - + + + diff --git a/testdata/030-report.xml b/testdata/030-report.xml index 4a1c365..20f3375 100644 --- a/testdata/030-report.xml +++ b/testdata/030-report.xml @@ -1,69 +1,70 @@ - + - + - + - - + - + - - - - - + + + + + - - + +single-line stdout + stdout_test.go:11: single-line error + stdout_test.go:12: multi + line + error]]> - - + +single-line stdout]]> - - + + - + - - - - + + + + + diff --git a/testdata/030-stdout.txt b/testdata/030-stdout.txt index 8b494b5..bbe9eb3 100644 --- a/testdata/030-stdout.txt +++ b/testdata/030-stdout.txt @@ -3,98 +3,99 @@ multi line stdout single-line stdout ---- FAIL: TestFailWithStdoutAndTestOutput (0.10s) - example_test.go:13: single-line error - example_test.go:14: multi + stdout_test.go:11: single-line error + stdout_test.go:12: multi line error +--- FAIL: TestFailWithStdoutAndTestOutput (0.00s) === RUN TestFailWithStdoutAndNoTestOutput multi line stdout single-line stdout ---- FAIL: TestFailWithStdoutAndNoTestOutput (0.15s) +--- FAIL: TestFailWithStdoutAndNoTestOutput (0.00s) === RUN TestFailWithTestOutput ---- FAIL: TestFailWithTestOutput (0.20s) - example_test.go:26: single-line error - example_test.go:27: multi + stdout_test.go:22: single-line error + stdout_test.go:23: multi line error +--- FAIL: TestFailWithTestOutput (0.00s) === RUN TestFailWithNoTestOutput ---- FAIL: TestFailWithNoTestOutput (0.25s) +--- FAIL: TestFailWithNoTestOutput (0.00s) === RUN TestPassWithStdoutAndTestOutput multi line stdout single-line stdout ---- PASS: TestPassWithStdoutAndTestOutput (0.30s) - example_test.go:39: single-line info - example_test.go:40: multi + stdout_test.go:33: single-line info + stdout_test.go:34: multi line info +--- PASS: TestPassWithStdoutAndTestOutput (0.00s) === RUN TestPassWithStdoutAndNoTestOutput multi line stdout single-line stdout ---- PASS: TestPassWithStdoutAndNoTestOutput (0.35s) +--- PASS: TestPassWithStdoutAndNoTestOutput (0.00s) === RUN TestPassWithTestOutput ---- PASS: TestPassWithTestOutput (0.40s) - example_test.go:51: single-line info - example_test.go:52: multi + stdout_test.go:43: single-line info + stdout_test.go:44: multi line info +--- PASS: TestPassWithTestOutput (0.00s) === RUN TestPassWithNoTestOutput ---- PASS: TestPassWithNoTestOutput (0.50s) +--- PASS: TestPassWithNoTestOutput (0.00s) === RUN TestSubtests === RUN TestSubtests/TestFailWithStdoutAndTestOutput -1 multi +multi line stdout -1 single-line stdout +single-line stdout + stdout_test.go:11: single-line error + stdout_test.go:12: multi + line + error === RUN TestSubtests/TestFailWithStdoutAndNoTestOutput -2 multi +multi line stdout -2 single-line stdout +single-line stdout === RUN TestSubtests/TestFailWithTestOutput + stdout_test.go:22: single-line error + stdout_test.go:23: multi + line + error === RUN TestSubtests/TestFailWithNoTestOutput === RUN TestSubtests/TestPassWithStdoutAndTestOutput -4 multi +multi line stdout -4 single-line stdout +single-line stdout + stdout_test.go:33: single-line info + stdout_test.go:34: multi + line + info === RUN TestSubtests/TestPassWithStdoutAndNoTestOutput -5 multi +multi line stdout -5 single-line stdout +single-line stdout === RUN TestSubtests/TestPassWithTestOutput + stdout_test.go:43: single-line info + stdout_test.go:44: multi + line + info === RUN TestSubtests/TestPassWithNoTestOutput ---- FAIL: TestSubtests (2.27s) - --- FAIL: TestSubtests/TestFailWithStdoutAndTestOutput (0.10s) - example_test.go:65: 1 single-line error - example_test.go:66: 1 multi - line - error - --- FAIL: TestSubtests/TestFailWithStdoutAndNoTestOutput (0.15s) - --- FAIL: TestSubtests/TestFailWithTestOutput (0.20s) - example_test.go:78: 3 single-line error - example_test.go:79: 3 multi - line - error - --- FAIL: TestSubtests/TestFailWithNoTestOutput (0.25s) - --- PASS: TestSubtests/TestPassWithStdoutAndTestOutput (0.30s) - example_test.go:91: 4 single-line info - example_test.go:92: 4 multi - line - info - --- PASS: TestSubtests/TestPassWithStdoutAndNoTestOutput (0.35s) - --- PASS: TestSubtests/TestPassWithTestOutput (0.40s) - example_test.go:103: 6 single-line info - example_test.go:104: 6 multi - line - info - --- PASS: TestSubtests/TestPassWithNoTestOutput (0.50s) +--- FAIL: TestSubtests (0.00s) + --- FAIL: TestSubtests/TestFailWithStdoutAndTestOutput (0.00s) + --- FAIL: TestSubtests/TestFailWithStdoutAndNoTestOutput (0.00s) + --- FAIL: TestSubtests/TestFailWithTestOutput (0.00s) + --- FAIL: TestSubtests/TestFailWithNoTestOutput (0.00s) + --- PASS: TestSubtests/TestPassWithStdoutAndTestOutput (0.00s) + --- PASS: TestSubtests/TestPassWithStdoutAndNoTestOutput (0.00s) + --- PASS: TestSubtests/TestPassWithTestOutput (0.00s) + --- PASS: TestSubtests/TestPassWithNoTestOutput (0.00s) FAIL -FAIL package/name1 4.567s +exit status 1 +FAIL package/stdout 0.001s diff --git a/testdata/035-report.xml b/testdata/035-report.xml index 5256322..ccabba8 100644 --- a/testdata/035-report.xml +++ b/testdata/035-report.xml @@ -1,17 +1,17 @@ - + - - - - - - - - - + + + + + + + + + diff --git a/testdata/035-whitespace.txt b/testdata/035-whitespace.txt index 2633e56..7d6590c 100644 --- a/testdata/035-whitespace.txt +++ b/testdata/035-whitespace.txt @@ -1,10 +1,16 @@ === RUN TestFlat + whitespace_test.go:9: log 1 + whitespace_test.go:10: log 2 printf 1 printf 2 --- PASS: TestFlat (0.00s) - whitespace_test.go:9: log 1 - whitespace_test.go:10: log 2 === RUN TestWithSpace + whitespace_test.go:16: no-space + whitespace_test.go:17: one-space + whitespace_test.go:18: two-space + whitespace_test.go:19: four-space + whitespace_test.go:20: eight-space + whitespace_test.go:21: no-space no-space one-space two-space @@ -12,21 +18,21 @@ no-space eight-space no-space --- PASS: TestWithSpace (0.00s) - whitespace_test.go:16: no-space - whitespace_test.go:17: one-space - whitespace_test.go:18: two-space - whitespace_test.go:19: four-space - whitespace_test.go:20: eight-space - whitespace_test.go:21: no-space === RUN TestWithTab + whitespace_test.go:31: no-tab + whitespace_test.go:32: one-tab + whitespace_test.go:33: two-tab no-tab one-tab two-tab --- PASS: TestWithTab (0.00s) - whitespace_test.go:31: no-tab - whitespace_test.go:32: one-tab - whitespace_test.go:33: two-tab === RUN TestWithNewlinesFlat + whitespace_test.go:40: no-newline + whitespace_test.go:41: one-newline + one-newline + whitespace_test.go:42: two-newlines + two-newlines + two-newlines no-newline one-newline one-newline @@ -34,17 +40,19 @@ two-newlines two-newlines two-newlines --- PASS: TestWithNewlinesFlat (0.00s) - whitespace_test.go:40: no-newline - whitespace_test.go:41: one-newline - one-newline - whitespace_test.go:42: two-newlines - two-newlines - two-newlines === RUN TestSubTests === RUN TestSubTests/TestFlat + whitespace_test.go:9: log 1 + whitespace_test.go:10: log 2 printf 1 printf 2 === RUN TestSubTests/TestWithSpace + whitespace_test.go:16: no-space + whitespace_test.go:17: one-space + whitespace_test.go:18: two-space + whitespace_test.go:19: four-space + whitespace_test.go:20: eight-space + whitespace_test.go:21: no-space no-space one-space two-space @@ -52,10 +60,19 @@ no-space eight-space no-space === RUN TestSubTests/TestWithTab + whitespace_test.go:31: no-tab + whitespace_test.go:32: one-tab + whitespace_test.go:33: two-tab no-tab one-tab two-tab === RUN TestSubTests/TestWithNewlinesFlat + whitespace_test.go:40: no-newline + whitespace_test.go:41: one-newline + one-newline + whitespace_test.go:42: two-newlines + two-newlines + two-newlines no-newline one-newline one-newline @@ -64,25 +81,8 @@ two-newlines two-newlines --- PASS: TestSubTests (0.00s) --- PASS: TestSubTests/TestFlat (0.00s) - whitespace_test.go:9: log 1 - whitespace_test.go:10: log 2 --- PASS: TestSubTests/TestWithSpace (0.00s) - whitespace_test.go:16: no-space - whitespace_test.go:17: one-space - whitespace_test.go:18: two-space - whitespace_test.go:19: four-space - whitespace_test.go:20: eight-space - whitespace_test.go:21: no-space --- PASS: TestSubTests/TestWithTab (0.00s) - whitespace_test.go:31: no-tab - whitespace_test.go:32: one-tab - whitespace_test.go:33: two-tab --- PASS: TestSubTests/TestWithNewlinesFlat (0.00s) - whitespace_test.go:40: no-newline - whitespace_test.go:41: one-newline - one-newline - whitespace_test.go:42: two-newlines - two-newlines - two-newlines PASS -ok github.com/jstemmer/test/whitespace 0.001s +ok package/whitespace 0.001s diff --git a/testdata/generate-golden-reports.go b/testdata/generate-golden-reports.go index 68d7411..36a8424 100644 --- a/testdata/generate-golden-reports.go +++ b/testdata/generate-golden-reports.go @@ -17,7 +17,7 @@ import ( var verbose bool var configs = map[string]gojunitreport.Config{ - "005-no_xml_header.txt": {SkipXMLHeader: true}, + "005-no-xml-header.txt": {SkipXMLHeader: true}, "006-mixed.txt": {SkipXMLHeader: true}, "007-compiled_test.txt": {PackageName: "test/package"}, } diff --git a/testdata/src/bench/bench_test.go b/testdata/src/bench/bench_test.go new file mode 100644 index 0000000..827e8f4 --- /dev/null +++ b/testdata/src/bench/bench_test.go @@ -0,0 +1,23 @@ +package bench + +import ( + "strconv" + "testing" +) + +func BenchmarkOne(b *testing.B) { + for i := 0; i < b.N; i++ { + test(i) + } +} + +func BenchmarkTwo(b *testing.B) { + for i := 0; i < b.N; i++ { + n, _ := strconv.Atoi(strconv.Itoa(i)) + test(n) + } +} + +func test(x int) int { + return x + 1 +} diff --git a/testdata/src/fail/fail_test.go b/testdata/src/fail/fail_test.go new file mode 100644 index 0000000..0fe6bf6 --- /dev/null +++ b/testdata/src/fail/fail_test.go @@ -0,0 +1,8 @@ +package fail + +import "testing" + +func TestOne(t *testing.T) { + t.Errorf("Error message") + t.Errorf("Longer\nerror\nmessage.") +} diff --git a/testdata/src/go.mod b/testdata/src/go.mod new file mode 100644 index 0000000..93e4565 --- /dev/null +++ b/testdata/src/go.mod @@ -0,0 +1,3 @@ +module package + +go 1.13 diff --git a/testdata/src/parallel/pkg_test.go b/testdata/src/parallel/pkg_test.go new file mode 100644 index 0000000..64855a6 --- /dev/null +++ b/testdata/src/parallel/pkg_test.go @@ -0,0 +1,27 @@ +package pkg + +import ( + "testing" + "time" +) + +func TestP1(t *testing.T) { + t.Parallel() + t.Log("t.Log(P1)") + time.Sleep(100*time.Millisecond) + t.Errorf("P1 error") +} + +func TestP2(t *testing.T) { + t.Parallel() + t.Log("t.Log(P2)") + time.Sleep(50*time.Millisecond) + t.Errorf("P2 error") +} + +func TestP3(t *testing.T) { + t.Parallel() + t.Log("t.Log(P3)") + time.Sleep(75*time.Millisecond) + t.Errorf("P3 error") +} diff --git a/testdata/src/pass/pass.go b/testdata/src/pass/pass.go new file mode 100644 index 0000000..e81c78d --- /dev/null +++ b/testdata/src/pass/pass.go @@ -0,0 +1,14 @@ +package pass + +import "fmt" + +func message() string { + return "line" +} + +func unused(n int) string { + if n < 0 { + return "0" + } + return fmt.Sprintf("%d\n", n) +} diff --git a/testdata/src/pass/pass_test.go b/testdata/src/pass/pass_test.go new file mode 100644 index 0000000..8582a22 --- /dev/null +++ b/testdata/src/pass/pass_test.go @@ -0,0 +1,11 @@ +package pass + +import "testing" + +func TestPass(t *testing.T) { +} + +func TestPassLog(t *testing.T) { + t.Logf("log %s", message()) + t.Log("log\nmulti\nline") +} diff --git a/testdata/src/race/race_test.go b/testdata/src/race/race_test.go new file mode 100644 index 0000000..a0414bb --- /dev/null +++ b/testdata/src/race/race_test.go @@ -0,0 +1,15 @@ +package race + +import "testing" + +func TestRace(t *testing.T) { + done := make(chan bool) + x := 0 + go func() { + x = 5 + done <- true + }() + x = 3 + t.Logf("x = %d\n", x) + <-done +} diff --git a/testdata/src/skip/skip_test.go b/testdata/src/skip/skip_test.go new file mode 100644 index 0000000..3eec72d --- /dev/null +++ b/testdata/src/skip/skip_test.go @@ -0,0 +1,12 @@ +package skip + +import "testing" + +func TestSkip(t *testing.T) { + t.Skip("skip message") +} + +func TestSkipNow(t *testing.T) { + t.Log("log message") + t.SkipNow() +} diff --git a/testdata/src/stdout/stdout_test.go b/testdata/src/stdout/stdout_test.go new file mode 100644 index 0000000..6dca58b --- /dev/null +++ b/testdata/src/stdout/stdout_test.go @@ -0,0 +1,59 @@ +package stdout + +import ( + "fmt" + "testing" +) + +func TestFailWithStdoutAndTestOutput(t *testing.T) { + fmt.Print("multi\nline\nstdout\n") + fmt.Print("single-line stdout\n") + t.Errorf("single-line error") + t.Errorf("multi\nline\nerror") +} + +func TestFailWithStdoutAndNoTestOutput(t *testing.T) { + fmt.Print("multi\nline\nstdout\n") + fmt.Print("single-line stdout\n") + t.Fail() +} + +func TestFailWithTestOutput(t *testing.T) { + t.Errorf("single-line error") + t.Errorf("multi\nline\nerror") +} + +func TestFailWithNoTestOutput(t *testing.T) { + t.Fail() +} + +func TestPassWithStdoutAndTestOutput(t *testing.T) { + fmt.Print("multi\nline\nstdout\n") + fmt.Print("single-line stdout\n") + t.Log("single-line info") + t.Log("multi\nline\ninfo") +} + +func TestPassWithStdoutAndNoTestOutput(t *testing.T) { + fmt.Print("multi\nline\nstdout\n") + fmt.Print("single-line stdout\n") +} + +func TestPassWithTestOutput(t *testing.T) { + t.Log("single-line info") + t.Log("multi\nline\ninfo") +} + +func TestPassWithNoTestOutput(t *testing.T) { +} + +func TestSubtests(t *testing.T) { + t.Run("TestFailWithStdoutAndTestOutput", TestFailWithStdoutAndTestOutput) + t.Run("TestFailWithStdoutAndNoTestOutput", TestFailWithStdoutAndNoTestOutput) + t.Run("TestFailWithTestOutput", TestFailWithTestOutput) + t.Run("TestFailWithNoTestOutput", TestFailWithNoTestOutput) + t.Run("TestPassWithStdoutAndTestOutput", TestPassWithStdoutAndTestOutput) + t.Run("TestPassWithStdoutAndNoTestOutput", TestPassWithStdoutAndNoTestOutput) + t.Run("TestPassWithTestOutput", TestPassWithTestOutput) + t.Run("TestPassWithNoTestOutput", TestPassWithNoTestOutput) +} diff --git a/testdata/src/subtests/subtests_test.go b/testdata/src/subtests/subtests_test.go new file mode 100644 index 0000000..6a09ffb --- /dev/null +++ b/testdata/src/subtests/subtests_test.go @@ -0,0 +1,33 @@ +package subtests + +import "testing" + +func TestSubtests(t *testing.T) { + t.Run("Subtest", func(t *testing.T) { + t.Log("ok") + }) + t.Run("Subtest", func(t *testing.T) { + t.Error("error message") + }) + t.Run("Subtest", func(t *testing.T) { + t.Skip("skip message") + }) +} + +func TestNestedSubtests(t *testing.T) { + t.Run("a#1", func(t *testing.T) { + t.Run("b#1", func(t *testing.T) { + t.Run("c#1", func(t *testing.T) { + }) + }) + }) +} + +func TestFailingSubtestWithNestedSubtest(t *testing.T) { + t.Run("Subtest", func(t *testing.T) { + t.Run("Subsubtest", func(t *testing.T) { + t.Log("ok") + }) + t.Errorf("Subtest error message") + }) +} diff --git a/testdata/src/whitespace/whitespace_test.go b/testdata/src/whitespace/whitespace_test.go new file mode 100644 index 0000000..36639bc --- /dev/null +++ b/testdata/src/whitespace/whitespace_test.go @@ -0,0 +1,53 @@ +package main + +import ( + "fmt" + "testing" +) + +func TestFlat(t *testing.T) { + t.Logf("log 1") + t.Logf("log 2") + fmt.Printf("printf 1\n") + fmt.Printf("printf 2\n") +} + +func TestWithSpace(t *testing.T) { + t.Logf("no-space") + t.Logf(" one-space") + t.Logf(" two-space") + t.Logf(" four-space") + t.Logf(" eight-space") + t.Logf("no-space") + fmt.Printf("no-space\n") + fmt.Printf(" one-space\n") + fmt.Printf(" two-space\n") + fmt.Printf(" four-space\n") + fmt.Printf(" eight-space\n") + fmt.Printf("no-space\n") +} + +func TestWithTab(t *testing.T) { + t.Logf("no-tab") + t.Logf("\tone-tab") + t.Logf("\t\ttwo-tab") + fmt.Printf("no-tab\n") + fmt.Printf("\tone-tab\n") + fmt.Printf("\t\ttwo-tab\n") +} + +func TestWithNewlinesFlat(t *testing.T) { + t.Logf("no-newline") + t.Logf("one-newline\none-newline") + t.Logf("two-newlines\ntwo-newlines\ntwo-newlines") + fmt.Println("no-newline") + fmt.Println("one-newline\none-newline") + fmt.Println("two-newlines\ntwo-newlines\ntwo-newlines") +} + +func TestSubTests(t *testing.T) { + t.Run("TestFlat", TestFlat) + t.Run("TestWithSpace", TestWithSpace) + t.Run("TestWithTab", TestWithTab) + t.Run("TestWithNewlinesFlat", TestWithNewlinesFlat) +}