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