main: use emulator exit code instead of parsing test output

This commit changes `tinygo test` to always look at the exit code of the
running test, instead of looking for a "PASS" string at the end of the
output. This is possible now that the binaries running under
qemu-system-arm or qemu-system-riscv32 will signal the correct exit code
when they exit.

As a side effect, this also makes it possible to avoid the "PASS" line
between successful tests. Before:

    $ tinygo test container/heap container/list
    PASS
    ok  	container/heap	0.001s
    PASS
    ok  	container/list	0.001s

After:

    $ tinygo test container/heap container/list
    ok  	container/heap	0.001s
    ok  	container/list	0.001s

The new behavior is more in line with upstream Go:

    go test container/heap container/list
    ok  	container/heap	0.004s
    ok  	container/list	0.004s
This commit is contained in:
Ayke van Laethem
2021-08-14 01:46:40 +02:00
committed by Ron Evans
parent 98f84a497d
commit 4d5ec6c57b
3 changed files with 16 additions and 37 deletions
+3 -1
View File
@@ -285,7 +285,9 @@ func (m *M) Run() int {
if failures > 0 {
fmt.Println("FAIL")
} else {
fmt.Println("PASS")
if flagVerbose {
fmt.Println("PASS")
}
}
return failures
}