| 1 |
[short] skip |
| 2 |
|
| 3 |
# Test that a loading error in a test file is reported as a "setup failed" error |
| 4 |
# and doesn't prevent running other tests. |
| 5 |
! go test -o=$devnull ./t1/p ./t |
| 6 |
stderr '# m/t1/p\n.*package x is not in std' |
| 7 |
stdout 'FAIL m/t1/p \[setup failed\]' |
| 8 |
stdout 'ok m/t' |
| 9 |
|
| 10 |
# Test a loading error in a test package, but not in the test file |
| 11 |
! go test -o=$devnull ./t2/p ./t |
| 12 |
stderr '# m/t2/p\n.*package x is not in std' |
| 13 |
stdout 'FAIL m/t2/p \[setup failed\]' |
| 14 |
stdout 'ok m/t' |
| 15 |
|
| 16 |
# Test a loading error in a package imported by a test file |
| 17 |
! go test -o=$devnull ./t3/p ./t |
| 18 |
stderr '# m/t3/p\n.*package x is not in std' |
| 19 |
stdout 'FAIL m/t3/p \[setup failed\]' |
| 20 |
stdout 'ok m/t' |
| 21 |
|
| 22 |
# Test a loading error in a package imported by a test package |
| 23 |
! go test -o=$devnull ./t4/p ./t |
| 24 |
stderr '# m/t4/p\n.*package x is not in std' |
| 25 |
stdout 'FAIL m/t4/p \[setup failed\]' |
| 26 |
stdout 'ok m/t' |
| 27 |
|
| 28 |
# Test that two loading errors are both reported. |
| 29 |
! go test -o=$devnull ./t1/p ./t2/p ./t |
| 30 |
stderr '# m/t1/p\n.*package x is not in std' |
| 31 |
stdout 'FAIL m/t1/p \[setup failed\]' |
| 32 |
stderr '# m/t2/p\n.*package x is not in std' |
| 33 |
stdout 'FAIL m/t2/p \[setup failed\]' |
| 34 |
stdout 'ok m/t' |
| 35 |
|
| 36 |
# Test that an import cycle error is reported. Test for #70820 |
| 37 |
! go test -o=$devnull ./cycle/p ./t |
| 38 |
stderr '# m/cycle/p\n.*package m/cycle/p\n\timports m/cycle/p from p\.go: import cycle not allowed' |
| 39 |
stdout 'FAIL m/cycle/p \[setup failed\]' |
| 40 |
stdout 'ok m/t' |
| 41 |
|
| 42 |
# Test that multiple errors for the same package under test are reported. |
| 43 |
! go test -o=$devnull ./cycle/q ./t |
| 44 |
stderr '# m/cycle/q\n.*package m/cycle/q\n\timports m/cycle/p from q\.go\n\timports m/cycle/p from p\.go: import cycle not allowed' |
| 45 |
stdout 'FAIL m/cycle/q \[setup failed\]' |
| 46 |
stdout 'ok m/t' |
| 47 |
|
| 48 |
# Finally, this one is a non-import-cycle load error that |
| 49 |
# is produced for the package under test. |
| 50 |
! go test -o=$devnull . ./t |
| 51 |
stderr '# \.\n.*no Go files in '$PWD'$' |
| 52 |
stdout 'FAIL . \[setup failed\]' |
| 53 |
stdout 'ok m/t' |
| 54 |
|
| 55 |
-- go.mod -- |
| 56 |
module m |
| 57 |
go 1.21 |
| 58 |
-- t/t_test.go -- |
| 59 |
package t |
| 60 |
|
| 61 |
import "testing" |
| 62 |
|
| 63 |
func TestGood(t *testing.T) {} |
| 64 |
-- t1/p/p_test.go -- |
| 65 |
package p |
| 66 |
|
| 67 |
import "x" |
| 68 |
-- t2/p/p_test.go -- |
| 69 |
package p |
| 70 |
-- t2/p/p.go -- |
| 71 |
package p |
| 72 |
|
| 73 |
import "x" |
| 74 |
-- t3/p/p_test.go -- |
| 75 |
package p |
| 76 |
|
| 77 |
import "m/bad" |
| 78 |
-- t4/p/p_test.go -- |
| 79 |
package p |
| 80 |
-- t4/p/p.go -- |
| 81 |
package p |
| 82 |
|
| 83 |
import "m/bad" |
| 84 |
-- cycle/p/p.go -- |
| 85 |
package p |
| 86 |
|
| 87 |
import "m/cycle/p" |
| 88 |
-- cycle/q/q.go -- |
| 89 |
package q |
| 90 |
|
| 91 |
import ( |
| 92 |
"m/bad" |
| 93 |
"m/cycle/p" |
| 94 |
) |
| 95 |
-- bad/bad.go -- |
| 96 |
package bad |
| 97 |
|
| 98 |
import "x" |