1
1
[GOOS:windows] skip 'filesystem normalizes / to \'
2
2
[GOOS:plan9] skip 'filesystem disallows \n in paths'
3
- [!cgo] skip 'testing cgo handling of newlines'
4
3
5
4
# If the directory path containing a package to be built includes a newline,
6
5
# the go command should refuse to even try to build the package.
@@ -12,24 +11,28 @@ cd $DIR
12
11
exec pwd
13
12
cp $WORK/go.mod ./go.mod
14
13
cp $WORK/main.go ./main.go
14
+ cp $WORK/main_nocgo.go ./main_nocgo.go
15
15
cp $WORK/main_test.go ./main_test.go
16
16
17
17
! go build -o $devnull .
18
18
stderr 'package example: invalid package directory .*uh-oh'
19
19
20
- ! go build -o $devnull main.go
20
+ [cgo] ! go build -o $devnull main.go
21
+ [!cgo] ! go build -o $devnull main_nocgo.go
21
22
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
22
23
23
24
! go run .
24
25
stderr 'package example: invalid package directory .*uh-oh'
25
26
26
- ! go run main.go
27
+ [cgo] ! go run main.go
28
+ [!cgo] ! go run main_nocgo.go
27
29
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
28
30
29
31
! go test .
30
32
stderr 'package example: invalid package directory .*uh-oh'
31
33
32
- ! go test -v main.go main_test.go
34
+ [cgo] ! go test -v main.go main_test.go
35
+ [!cgo] ! go test -v main_nocgo.go main_test.go
33
36
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
34
37
35
38
go list -compiled -e -f '{{with .CompiledGoFiles}}{{.}}{{end}}' .
@@ -47,27 +50,31 @@ go list -compiled -e -f '{{with .CompiledGoFiles}}{{.}}{{end}}' .
47
50
48
51
symlink $WORK${/}link -> $DIR
49
52
50
- go run $WORK${/}link${/}main.go
53
+ [cgo] go run $WORK${/}link${/}main.go
54
+ [!cgo] go run $WORK${/}link${/}main_nocgo.go
51
55
! stdout panic
52
56
! stderr panic
53
57
stderr '^ok$'
54
58
55
- go test -v $WORK${/}link${/}main.go $WORK${/}link${/}main_test.go
59
+ [cgo] go test -v $WORK${/}link${/}main.go $WORK${/}link${/}main_test.go
60
+ [!cgo] go test -v $WORK${/}link${/}main_nocgo.go $WORK${/}link${/}main_test.go
56
61
! stdout panic
57
62
! stderr panic
58
63
stdout '^ok$' # 'go test' combines the test's stdout into stderr
59
64
60
65
cd $WORK/link
61
66
62
- ! go run $DIR${/}main.go
67
+ [cgo] ! go run $DIR${/}main.go
68
+ [!cgo] ! go run $DIR${/}main_nocgo.go
63
69
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
64
70
65
71
go run .
66
72
! stdout panic
67
73
! stderr panic
68
74
stderr '^ok$'
69
75
70
- go run main.go
76
+ [cgo] go run main.go
77
+ [!cgo] go run main_nocgo.go
71
78
! stdout panic
72
79
! stderr panic
73
80
stderr '^ok$'
@@ -91,6 +98,15 @@ package main
91
98
92
99
import "C"
93
100
101
+ func main() {
102
+ /* nothing here */
103
+ println("ok")
104
+ }
105
+ -- $WORK/main_nocgo.go --
106
+ //go:build !cgo
107
+
108
+ package main
109
+
94
110
func main() {
95
111
/* nothing here */
96
112
println("ok")
0 commit comments