Files
garble/testdata/scripts/test.txt
Daniel Martí 511779d8ff testdata: set GOPRIVATE in all but two tests (#104)
basic.txt just builds main.go without a module. Similarly, we leave
imports.txt without a GOPRIVATE, to test the 'go list -m' fallback.

For all other tests, explicitly set GOPRIVATE, to avoid two exec calls -
both 'go env GOPRIVATE' as well as 'go list -m'. Each of those calls
takes in the order of 10ms, so saving ~26 exec calls should easily add
to 200-300ms saved from 'go test -short'.
2020-08-20 11:51:55 +02:00

65 lines
982 B
Plaintext

# Note that we need bar_test too.
env GOPRIVATE=test/bar,test/bar_test
# build the test binary
garble test -c
binsubstr bar.test$exe 'TestFoo' 'TestSeparateFoo'
! binsubstr bar.test$exe 'ImportedVar'
# run the tests
exec ./bar.test -test.v
stdout 'PASS.*TestFoo'
stdout 'PASS.*TestSeparateFoo'
[short] stop # no need to verify this with -short
# verify with regular cmd/go
exec go test -v
stdout 'PASS.*TestFoo'
-- go.mod --
module test/bar
-- bar.go --
package bar
func Foo() string { return "Foo" }
var ImportedVar = "imported var value"
-- bar_test.go --
package bar
import "testing"
func TestFoo(t *testing.T) {
t.Log(ImportedVar)
if Foo() != "Foo" {
t.FailNow()
}
}
-- bar_separate_test.go --
package bar_test
import (
"testing"
"test/bar"
)
func TestSeparateFoo(t *testing.T) {
t.Log(bar.ImportedVar)
if bar.Foo() != "Foo" {
t.FailNow()
}
}
-- main_test.go --
package bar
import (
"os"
"testing"
)
func TestMain(m *testing.M) {
os.Exit(m.Run())
}