jstemmer / go-junit-report

Convert Go test output to JUnit XML
MIT License
763 stars 222 forks source link

[no test files] Not handled well by set-exit-code #163

Open mqw opened 1 year ago

mqw commented 1 year ago

When I run my tests with gotest output and have [no test files] in one of the directories - it's fine - exit code 0 Whe I run same tests with gojson output and import with -parser gojson - the exit code is 1

joschi commented 1 week ago

Doesn't seem to be an issue with go-junit-report 2.1.0.

❯ go test -v ./foo
testing: warning: no tests to run
PASS
ok      github.com/joschi/go-junit-report/v2/foo    (cached) [no tests to run]

❯ go test -v -json ./foo | build/go-junit-report -parser gojson -set-exit-code
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
    <testsuite name="github.com/joschi/go-junit-report/v2/foo" tests="0" failures="0" errors="0" id="0" hostname="joschi-dash0.lan" time="0.000" timestamp="2024-06-28T14:28:19+02:00">
        <system-out><![CDATA[testing: warning: no tests to run]]></system-out>
    </testsuite>
</testsuites>

❯ echo $status
0

❯ go test -v ./foo | build/go-junit-report -parser gotest -set-exit-code
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
    <testsuite name="github.com/joschi/go-junit-report/v2/foo" tests="0" failures="0" errors="0" id="0" hostname="joschi-dash0.lan" time="0.000" timestamp="2024-06-28T14:29:22+02:00">
        <system-out><![CDATA[testing: warning: no tests to run]]></system-out>
    </testsuite>
</testsuites>

❯ echo $status
0