aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorLasse Folger <lassefolger@google.com>2022-04-05 09:19:57 +0200
committerLasse Folger <lassefolger@google.com>2022-04-05 18:53:15 +0200
commit4739b353bb878f29ee78e1cd7eaf3d8f32199798 (patch)
tree40bb8ba155a8dc87b4794a4fcf224d03f555502c /misc
parent9d6ab825f6fe125f7ce630e103b887e580403802 (diff)
parentc18f398f32c45afe2e9a81a6d885a4e0183cd649 (diff)
downloadgo-4739b353bb878f29ee78e1cd7eaf3d8f32199798.tar.xz
[dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: Iaf618444dd2d99721c19708df9ce2c1f35854efd
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/testgodefs/testgodefs_test.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/misc/cgo/testgodefs/testgodefs_test.go b/misc/cgo/testgodefs/testgodefs_test.go
index 7628ffc595..d03769ea87 100644
--- a/misc/cgo/testgodefs/testgodefs_test.go
+++ b/misc/cgo/testgodefs/testgodefs_test.go
@@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "runtime"
"strings"
"testing"
)
@@ -58,9 +59,32 @@ func TestGoDefs(t *testing.T) {
t.Fatalf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, cmd.Stderr)
}
- if err := os.WriteFile(filepath.Join(dir, fp+"_defs.go"), out, 0644); err != nil {
+ fn := fp + "_defs.go"
+ if err := os.WriteFile(filepath.Join(dir, fn), out, 0644); err != nil {
t.Fatal(err)
}
+
+ // Verify that command line arguments are not rewritten in the generated comment,
+ // see go.dev/issue/52063
+ hasGeneratedByComment := false
+ for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") {
+ cgoExe := "cgo"
+ if runtime.GOOS == "windows" {
+ cgoExe = "cgo.exe"
+ }
+ if !strings.HasPrefix(line, "// "+cgoExe+" -godefs") {
+ continue
+ }
+ if want := "// " + cgoExe + " " + strings.Join(cmd.Args[3:], " "); line != want {
+ t.Errorf("%s: got generated comment %q, want %q", fn, line, want)
+ }
+ hasGeneratedByComment = true
+ break
+ }
+
+ if !hasGeneratedByComment {
+ t.Errorf("%s: comment with generating cgo -godefs command not found", fn)
+ }
}
main, err := os.ReadFile(filepath.Join("testdata", "main.go"))