simplified part of imports test, move testing import path garbling in the syntax test

pull/116/head
Andrew LeFevre 5 years ago
parent 8a1c98e6d3
commit 20a81ba1e1

@ -1,13 +1,11 @@
# Note that this is the only test with a module where we rely on the detection
# of GOPRIVATE.
env GOPRIVATE='test/*,rsc.io/*'
garble build -tags buildtag
exec ./main
cmp stdout main.stdout
! binsubstr main$exe 'ImportedVar' 'ImportedConst' 'ImportedFunc' 'ImportedType' 'main.go' 'test/main' 'imported.' 'rsc.io'
! binsubstr main$exe 'ImportedVar' 'ImportedConst' 'ImportedFunc' 'ImportedType' 'main.go' 'test/main' 'imported.'
[short] stop # checking that the build is reproducible is slow
@ -51,11 +49,11 @@ func main() {
fmt.Println(imported.ImportedFunc('x'))
fmt.Println(imported.ImportedType(3))
fmt.Print(discardPackageName(fmt.Sprintf("%T\n", imported.ReflectTypeOf(2))))
fmt.Print(discardPackageName(fmt.Sprintf("%T\n", imported.ReflectTypeOfIndirect(4))))
printfWithoutPackage("%T\n", imported.ReflectTypeOf(2))
printfWithoutPackage("%T\n", imported.ReflectTypeOfIndirect(4))
v := imported.ReflectValueOfVar
fmt.Print(discardPackageName(fmt.Sprintf("%#v\n", v)))
printfWithoutPackage("%#v\n", v)
method := reflect.ValueOf(&v).MethodByName("ExportedMethodName")
if method.IsValid() {
fmt.Println(method.Call(nil))
@ -67,8 +65,8 @@ func main() {
fmt.Println(quote.Go())
}
func discardPackageName(s string) string {
return strings.Split(s, ".")[1]
func printfWithoutPackage(format string, v interface{}) {
fmt.Print(strings.Split(fmt.Sprintf(format, v), ".")[1])
}
-- notag_fail.go --
// +build !buildtag

@ -1,10 +1,10 @@
env GOPRIVATE=test/main
env GOPRIVATE='test/main,rsc.io/*'
garble -debugdir=debug build
exec ./main$exe
cmp stderr main.stderr
! binsubstr main$exe 'localName' 'globalConst' 'globalVar' 'globalType' 'valuable information'
! binsubstr main$exe 'localName' 'globalConst' 'globalVar' 'globalType' 'valuable information' 'rsc.io'
binsubstr debug/main/scopes.go 'localName' 'globalConst'
@ -26,6 +26,8 @@ package main
import (
"encoding/json"
"go/ast"
"rsc.io/quote"
)
// This comment contains valuable information. Ensure it's not in the final binary.
@ -70,6 +72,7 @@ func main() {
enc, _ := json.Marshal(EncodingT{Foo: 3})
println(string(enc))
scopesTest()
println(quote.Go())
}
-- scopes.go --
@ -107,3 +110,4 @@ nil case
{"Foo":3}
1 1 1
1 4 5 1 input
Don't communicate by sharing memory, share memory by communicating.

Loading…
Cancel
Save