...
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
6stderr '# m/t1/p\n.*package x is not in std'
7stdout 'FAIL m/t1/p \[setup failed\]'
8stdout '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
12stderr '# m/t2/p\n.*package x is not in std'
13stdout 'FAIL m/t2/p \[setup failed\]'
14stdout '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
18stderr '# m/t3/p\n.*package x is not in std'
19stdout 'FAIL m/t3/p \[setup failed\]'
20stdout '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
24stderr '# m/t4/p\n.*package x is not in std'
25stdout 'FAIL m/t4/p \[setup failed\]'
26stdout 'ok m/t'
27
28# Test that two loading errors are both reported.
29! go test -o=$devnull ./t1/p ./t2/p ./t
30stderr '# m/t1/p\n.*package x is not in std'
31stdout 'FAIL m/t1/p \[setup failed\]'
32stderr '# m/t2/p\n.*package x is not in std'
33stdout 'FAIL m/t2/p \[setup failed\]'
34stdout 'ok m/t'
35
36# Test that an import cycle error is reported. Test for #70820
37! go test -o=$devnull ./cycle/p ./t
38stderr '# m/cycle/p\n.*package m/cycle/p\n\timports m/cycle/p from p\.go: import cycle not allowed'
39stdout 'FAIL m/cycle/p \[setup failed\]'
40stdout '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
44stderr '# 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'
45stdout 'FAIL m/cycle/q \[setup failed\]'
46stdout '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
51stderr '# \.\n.*no Go files in '$PWD'$'
52stdout 'FAIL . \[setup failed\]'
53stdout 'ok m/t'
54
55-- go.mod --
56module m
57go 1.21
58-- t/t_test.go --
59package t
60
61import "testing"
62
63func TestGood(t *testing.T) {}
64-- t1/p/p_test.go --
65package p
66
67import "x"
68-- t2/p/p_test.go --
69package p
70-- t2/p/p.go --
71package p
72
73import "x"
74-- t3/p/p_test.go --
75package p
76
77import "m/bad"
78-- t4/p/p_test.go --
79package p
80-- t4/p/p.go --
81package p
82
83import "m/bad"
84-- cycle/p/p.go --
85package p
86
87import "m/cycle/p"
88-- cycle/q/q.go --
89package q
90
91import (
92 "m/bad"
93 "m/cycle/p"
94)
95-- bad/bad.go --
96package bad
97
98import "x"
View as plain text