Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test output is assumed to be tab-prefixed #18

Closed
kylec1 opened this issue Aug 26, 2015 · 5 comments
Closed

Test output is assumed to be tab-prefixed #18

kylec1 opened this issue Aug 26, 2015 · 5 comments

Comments

@kylec1
Copy link

kylec1 commented Aug 26, 2015

It may be true for test output coming from the testing package's Log methods, but I have some tests with meaning log output and failures generated by gocheck that aren't included in the XML because they don't start with a tab.
Where did the assumption of tab-prefixed console output come from?
Could we just remove that check in the parser?

@jstemmer
Copy link
Owner

jstemmer commented Sep 3, 2015

The go test -v output prefixes all logged output with tabs. This is the only output I've considered so far. It was a convenient way to detect the log output and ignore other lines, I'm not sure if it's as easy as removing the check for a prefixed tab. Do you have any example output?

@kylec1
Copy link
Author

kylec1 commented Sep 4, 2015

Sure.
After some spec-reading, I think the actual request here is support for the system-out field in testcase. system-err would be nice too, but that seems less practical.

So for example output:

machine:bugdemo user$ go test -v
=== RUN TestProcess
Warning: a is negative
Processing -4 3
--- FAIL: TestProcess (0.00s)
    demo_test.go:8: testing
    demo_test.go:10: Incorrect result!
FAIL
exit status 1
FAIL    bugdemo 0.004s

I'd expect output like

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
    <testsuite tests="1" failures="1" time="0.004" name="bugdemo">
        <properties>
            <property name="go.version" value="go1.4.1"></property>
        </properties>
        <testcase classname="bugdemo" name="TestProcess" time="0.000">
            <failure message="Failed" type="">demo_test.go:8: testing&#xA;demo_test.go:10: Incorrect result!</failure>
            <system-out>Warning: a is negative&#xA;Processing -4 3</system-out>
        </testcase>
    </testsuite>
</testsuites>

Then, if you have tests (as I do) that execute code with meaningful stderr logging statements, just redirecting that to stdout would allow those log messages to be captured in the XML for later examination on a per-test basis.

So, from looking at the output, it doesn't seem to be about the tab prefixing, but until there is structured go test output, I don't think we can avoid the risk of some test generating output that will confuse the parser.

@wknapik
Copy link

wknapik commented Jun 7, 2018

Ran into this too.

Input:

=== RUN   TestSomething
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
coverage: 0.0% of statements
panic: test timed out after 30m0s

goroutine 1593 [running]:
testing.(*M).startAlarm.func1()
        /usr/local/go/src/testing/testing.go:1240 +0xfc
created by time.goFunc
        /usr/local/go/src/time/sleep.go:172 +0x44

goroutine 1 [chan receive, 5 minutes]:
testing.(*T).Run(0xc42013a1e0, 0x89fa08, 0x1e, 0x8b6000, 0x488201)
        /usr/local/go/src/testing/testing.go:825 +0x301
testing.runTests.func1(0xc42013a0f0)
        /usr/local/go/src/testing/testing.go:1063 +0x64
testing.tRunner(0xc42013a0f0, 0xc4201c9d68)
        /usr/local/go/src/testing/testing.go:777 +0xd0
testing.runTests(0xc420112e00, 0xb306c0, 0xc, 0xc, 0xc4201c9e80)
        /usr/local/go/src/testing/testing.go:1061 +0x2c4
testing.(*M).Run(0xc420150080, 0x0)
        /usr/local/go/src/testing/testing.go:978 +0x171
soooooooooooooomething.TestMain(0xc420150080)
        /some/path/file.go:122 +0x30
main.main()
        _testmain.go:102 +0x208
FAIL    some/test/suite 1800.013s

Output:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
        <testsuite tests="1" failures="1" time="1800.013" name="some/test/suite">
                <properties>
                        <property name="go.version" value="go1.10"></property>
                        <property name="coverage.statements.pct" value="0.0"></property>
                </properties>
                <testcase classname="suite" name="TestSomething" time="0.000">
                        <failure message="Failed" type="">/usr/local/go/src/testing/testing.go:1240 +0xfc&#xA;/usr/local/go/src/time/sleep.go:172 +0x44&#xA;/usr/local/go/src/testing/testing.go:825 +0x301&#xA;/usr/local/go/src/testing/testing.go:1063 +0x64&#xA;/usr/local/go/src/testing/testing.go:777 +0xd0&#xA;/usr/local/go/src/testing/testing.go:1061 +0x2c4&#xA;/usr/local/go/src/testing/testing.go:978 +0x171&#xA;/some/path/file.go:122 +0x30&#xA;_testmain.go:102 +0x208</failure>
                </testcase>
        </testsuite>
</testsuites>

It's forcing users to look at console output in Jenkins, instead of the parsed report ;/

go2xunit handles this correctly.

@nightlyone
Copy link

nightlyone commented Oct 26, 2018

@jstemmer Please use go test -json as this is the documented and canonical way to support machine readable output since go1.10 and above as documented in https://golang.org/doc/go1.10#test

The textual output is more intended for humans.

@jstemmer
Copy link
Owner

jstemmer commented Jul 2, 2022

This has been fixed in v2.0.0.

@jstemmer jstemmer closed this as completed Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants