| 1 |
[short] skip |
| 2 |
|
| 3 |
# In package list mode, output is buffered. |
| 4 |
# Check that a newline is printed after the buffer's contents. |
| 5 |
cd fail |
| 6 |
! go test . |
| 7 |
! stderr . |
| 8 |
stdout '^exitcode=1\n' |
| 9 |
stdout '^FAIL\s+example/fail' |
| 10 |
|
| 11 |
# In local directory mode output is streamed, so we don't know |
| 12 |
# whether the test printed anything at all, so we print the exit code |
| 13 |
# (just in case it failed without emitting any output at all), |
| 14 |
# and that happens to add the needed newline as well. |
| 15 |
! go test |
| 16 |
! stderr . |
| 17 |
stdout '^exitcode=1exit status 1\n' |
| 18 |
stdout '^FAIL\s+example/fail' |
| 19 |
|
| 20 |
# In package list mode, if the test passes the 'ok' message appears |
| 21 |
# on its own line. |
| 22 |
cd ../skip |
| 23 |
go test -v . |
| 24 |
! stderr . |
| 25 |
stdout '^skipping\n' |
| 26 |
stdout '^ok\s+example/skip' |
| 27 |
|
| 28 |
# If the output is streamed and the test passes, we can't tell whether it ended |
| 29 |
# in a partial line, and don't want to emit any extra output in the |
| 30 |
# overwhelmingly common case that it did not. |
| 31 |
# (In theory we could hook the 'os' package to report whether output |
| 32 |
# was emitted and whether it ended in a newline, but that seems too invasive.) |
| 33 |
go test |
| 34 |
! stderr . |
| 35 |
stdout '^skippingok\s+example/skip' |
| 36 |
|
| 37 |
|
| 38 |
-- go.mod -- |
| 39 |
module example |
| 40 |
|
| 41 |
go 1.18 |
| 42 |
-- fail/fail_test.go -- |
| 43 |
package fail |
| 44 |
|
| 45 |
import ( |
| 46 |
"os" |
| 47 |
"testing" |
| 48 |
) |
| 49 |
|
| 50 |
func TestMain(m *testing.M) { |
| 51 |
os.Stderr.WriteString("exitcode=1") |
| 52 |
os.Exit(1) |
| 53 |
} |
| 54 |
-- skip/skip_test.go -- |
| 55 |
package skip |
| 56 |
|
| 57 |
import ( |
| 58 |
"os" |
| 59 |
"testing" |
| 60 |
) |
| 61 |
|
| 62 |
func TestMain(m *testing.M) { |
| 63 |
os.Stderr.WriteString("skipping") |
| 64 |
os.Exit(0) |
| 65 |
} |