diff --git a/testdata/scripts/asm.txt b/testdata/scripts/asm.txt index 65ee650..05b842b 100644 --- a/testdata/scripts/asm.txt +++ b/testdata/scripts/asm.txt @@ -1,13 +1,13 @@ garble build exec ./main -cmp stdout main.stdout +cmp stderr main.stderr binsubstr main$exe 'privateAdd' 'PublicAdd' [short] stop # no need to verify this with -short go build exec ./main -cmp stdout main.stdout +cmp stderr main.stderr -- go.mod -- module test/main @@ -15,16 +15,14 @@ module test/main package main import ( - "fmt" - "test/main/imported" ) func privateAdd(x, y int64) int64 func main() { - fmt.Println(privateAdd(1, 2)) - fmt.Println(imported.PublicAdd(3, 4)) + println(privateAdd(1, 2)) + println(imported.PublicAdd(3, 4)) } -- main.s -- TEXT ·privateAdd(SB),$0-24 @@ -44,6 +42,6 @@ TEXT ·PublicAdd(SB),$0-24 ADDQ BP, BX MOVQ BX, ret+16(FP) RET --- main.stdout -- +-- main.stderr -- 3 7 diff --git a/testdata/scripts/cgo.txt b/testdata/scripts/cgo.txt index 2d41ea2..370a410 100644 --- a/testdata/scripts/cgo.txt +++ b/testdata/scripts/cgo.txt @@ -1,13 +1,13 @@ garble build exec ./main -cmp stdout main.stdout +cmp stderr main.stderr binsubstr main$exe 'privateAdd' [short] stop # no need to verify this with -short go build exec ./main -cmp stdout main.stdout +cmp stderr main.stderr -- go.mod -- module test/main @@ -21,10 +21,8 @@ static int privateAdd(int a, int b) { */ import "C" -import "fmt" - func main() { - fmt.Println(C.privateAdd(C.int(1), C.int(2))) + println(C.privateAdd(C.int(1), C.int(2))) } --- main.stdout -- +-- main.stderr -- 3 diff --git a/testdata/scripts/ldflags.txt b/testdata/scripts/ldflags.txt index 370ee2e..170b3be 100644 --- a/testdata/scripts/ldflags.txt +++ b/testdata/scripts/ldflags.txt @@ -1,13 +1,13 @@ garble build -ldflags='-X=main.unexportedVersion=v1.0.0 -X=test/main/imported.ExportedVar=replaced' exec ./main -cmp stdout main.stdout +cmp stderr main.stderr ! binsubstr main$exe 'unexportedVersion' [short] stop # no need to verify this with -short exec go build -ldflags='-X=main.unexportedVersion=v1.0.0 -X=test/main/imported.ExportedVar=replaced' exec ./main -cmp stdout main.stdout +cmp stderr main.stderr binsubstr main$exe 'unexportedVersion' -- go.mod -- @@ -16,21 +16,19 @@ module test/main package main import ( - "fmt" - "test/main/imported" ) var unexportedVersion = "unknown" func main() { - fmt.Println("version:", unexportedVersion) - fmt.Println("var:", imported.ExportedVar) + println("version:", unexportedVersion) + println("var:", imported.ExportedVar) } -- imported/imported.go -- package imported var ExportedVar = "original" --- main.stdout -- +-- main.stderr -- version: v1.0.0 var: replaced diff --git a/testdata/scripts/modinfo.txt b/testdata/scripts/modinfo.txt index f99e963..91d58d4 100644 --- a/testdata/scripts/modinfo.txt +++ b/testdata/scripts/modinfo.txt @@ -1,13 +1,13 @@ garble build exec ./main -cmp stdout main.stdout +cmp stderr main.stderr ! binsubstr main$exe '(devel)' [short] stop # no need to verify this with -short exec go build exec ./main -cmp stdout main.stdout-orig +cmp stderr main.stderr-orig binsubstr main$exe '(devel)' -- go.mod -- @@ -15,15 +15,16 @@ module test/main -- main.go -- package main -import ( - "fmt" - "runtime/debug" -) +import "runtime/debug" func main() { - fmt.Println(debug.ReadBuildInfo()) + if info, ok := debug.ReadBuildInfo(); ok { + println("version", info.Main.Version) + } else { + println("no version") + } } --- main.stdout-orig -- -&{test/main {test/main (devel) } []} true --- main.stdout -- - false +-- main.stderr-orig -- +version (devel) +-- main.stderr -- +no version diff --git a/testdata/scripts/plugin.txt b/testdata/scripts/plugin.txt index 9d31966..4bf782d 100644 --- a/testdata/scripts/plugin.txt +++ b/testdata/scripts/plugin.txt @@ -7,7 +7,7 @@ binsubstr plugin.so 'PublicVar' 'PublicFunc' # Note that we need -trimpath; see the caveat section in the README. go build -trimpath exec ./main -cmp stdout main.stdout +cmp stderr main.stderr binsubstr main$exe 'PublicVar' 'PublicFunc' ! binsubstr plugin.so 'privateFunc' @@ -17,18 +17,16 @@ go build -buildmode=plugin ./plugin binsubstr plugin.so 'PublicVar' 'PublicFunc' 'privateFunc' go build exec ./main -cmp stdout main.stdout +cmp stderr main.stderr -- go.mod -- module test/main -- plugin/main.go -- package main -import "fmt" - var PublicVar int -func privateFunc(n int) { fmt.Printf("Hello, number %d\n", n) } +func privateFunc(n int) { println("Hello, number", n) } func PublicFunc() { privateFunc(PublicVar) } -- main.go -- @@ -52,5 +50,5 @@ func main() { *v.(*int) = 7 f.(func())() } --- main.stdout -- +-- main.stderr -- Hello, number 7