Skip to content

Commit e2b1c0b

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
cmd/go: fix TestScript/build_cwd_newline with CGO_ENABLED=0
Updates #60167. Change-Id: I3792682e80a3c48d78a3b9e647cc968a1d5c8f2b Reviewed-on: https://go-review.googlesource.com/c/go/+/501575 Auto-Submit: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent a21bb83 commit e2b1c0b

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/cmd/go/testdata/script/build_cwd_newline.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[GOOS:windows] skip 'filesystem normalizes / to \'
22
[GOOS:plan9] skip 'filesystem disallows \n in paths'
3-
[!cgo] skip 'testing cgo handling of newlines'
43

54
# If the directory path containing a package to be built includes a newline,
65
# the go command should refuse to even try to build the package.
@@ -12,24 +11,28 @@ cd $DIR
1211
exec pwd
1312
cp $WORK/go.mod ./go.mod
1413
cp $WORK/main.go ./main.go
14+
cp $WORK/main_nocgo.go ./main_nocgo.go
1515
cp $WORK/main_test.go ./main_test.go
1616

1717
! go build -o $devnull .
1818
stderr 'package example: invalid package directory .*uh-oh'
1919

20-
! go build -o $devnull main.go
20+
[cgo] ! go build -o $devnull main.go
21+
[!cgo] ! go build -o $devnull main_nocgo.go
2122
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
2223

2324
! go run .
2425
stderr 'package example: invalid package directory .*uh-oh'
2526

26-
! go run main.go
27+
[cgo] ! go run main.go
28+
[!cgo] ! go run main_nocgo.go
2729
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
2830

2931
! go test .
3032
stderr 'package example: invalid package directory .*uh-oh'
3133

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
3336
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
3437

3538
go list -compiled -e -f '{{with .CompiledGoFiles}}{{.}}{{end}}' .
@@ -47,27 +50,31 @@ go list -compiled -e -f '{{with .CompiledGoFiles}}{{.}}{{end}}' .
4750

4851
symlink $WORK${/}link -> $DIR
4952

50-
go run $WORK${/}link${/}main.go
53+
[cgo] go run $WORK${/}link${/}main.go
54+
[!cgo] go run $WORK${/}link${/}main_nocgo.go
5155
! stdout panic
5256
! stderr panic
5357
stderr '^ok$'
5458

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
5661
! stdout panic
5762
! stderr panic
5863
stdout '^ok$' # 'go test' combines the test's stdout into stderr
5964

6065
cd $WORK/link
6166

62-
! go run $DIR${/}main.go
67+
[cgo] ! go run $DIR${/}main.go
68+
[!cgo] ! go run $DIR${/}main_nocgo.go
6369
stderr 'package command-line-arguments: invalid package directory .*uh-oh'
6470

6571
go run .
6672
! stdout panic
6773
! stderr panic
6874
stderr '^ok$'
6975

70-
go run main.go
76+
[cgo] go run main.go
77+
[!cgo] go run main_nocgo.go
7178
! stdout panic
7279
! stderr panic
7380
stderr '^ok$'
@@ -91,6 +98,15 @@ package main
9198

9299
import "C"
93100

101+
func main() {
102+
/* nothing here */
103+
println("ok")
104+
}
105+
-- $WORK/main_nocgo.go --
106+
//go:build !cgo
107+
108+
package main
109+
94110
func main() {
95111
/* nothing here */
96112
println("ok")

0 commit comments

Comments
 (0)