aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/build_cwd_newline.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/go/testdata/script/build_cwd_newline.txt')
-rw-r--r--src/cmd/go/testdata/script/build_cwd_newline.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/build_cwd_newline.txt b/src/cmd/go/testdata/script/build_cwd_newline.txt
index 8f74c01c81..e80235698a 100644
--- a/src/cmd/go/testdata/script/build_cwd_newline.txt
+++ b/src/cmd/go/testdata/script/build_cwd_newline.txt
@@ -43,6 +43,19 @@ stderr 'package example: invalid package directory .*uh-oh'
! stdout .
! exists obj_
+# The cgo tool should only accept the source file if the working directory
+# is not written in line directives in the resulting files.
+
+[cgo] ! go tool cgo main.go
+[cgo] stderr 'cgo: input path contains newline character: .*uh-oh'
+[cgo] ! exists _obj
+
+[cgo] go tool cgo -trimpath=$PWD main.go
+[cgo] grep '//line main\.go:1:1' _obj/main.cgo1.go
+[cgo] ! grep 'uh-oh' _obj/main.cgo1.go
+[cgo] rm _obj
+
+
# Since we do preserve $PWD (or set it appropriately) for commands, and we do
# not resolve symlinks unnecessarily, referring to the contents of the unsafe
# directory via a safe symlink should be ok, and should not inject the data from
@@ -92,6 +105,9 @@ go test -v .
! stderr panic
stdout '^ok$' # 'go test' combines the test's stdout into stderr
+[cgo] go tool cgo main.go
+[cgo] grep '//line .*'${/}'link'${/}'main\.go:1:1' _obj/main.cgo1.go
+[cgo] ! grep 'uh-oh' _obj/main.cgo1.go
-- $WORK/go.mod --
module example