Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testdata: don't let tests rely on rewriting mod files #183

Merged
merged 1 commit into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestScripts(t *testing.T) {
env.Vars = append(env.Vars,
"GOPROXY="+proxyURL,
"GONOSUMDB=*",
"GOFLAGS=-mod=readonly", // TODO(mvdan): remove once we switch to Go 1.16
"gofullversion="+runtime.Version(),
)
bindir := filepath.Join(env.WorkDir, ".bin")
Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/asm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ cmp stderr main.stderr

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ binsubstr main$exe 'main.go' 'globalVar' 'globalFunc' $gofullversion

-- go.mod --
module test/mainfoo

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/cgo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ cmp stderr main.stderr

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/debugdir.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ garble -debugdir ./test1 build -v

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/goprivate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ garble build -o=out ./standalone

-- go.mod --
module test/main

go 1.15
-- standalone/main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/implement.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ cmp stderr main.stderr

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
14 changes: 14 additions & 0 deletions testdata/scripts/imports.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Note that this is the only test with a module where we rely on the detection
# of GOPRIVATE.
# Also note that, since this is the only test using "real" external modules
# fetched via GOPROXY, go.mod and go.sum should declare the dependencies.

garble build -tags buildtag
exec cat go.sum
exec ./main
cmp stdout main.stdout

Expand Down Expand Up @@ -29,6 +32,17 @@ cmp stdout main.stdout

-- go.mod --
module test/main

go 1.15

require rsc.io/quote v1.5.2
-- go.sum --
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ cmp stderr main.stderr

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/ldflags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ binsubstr main$exe 'unexportedVersion'

-- go.mod --
module domain.test/main

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/literals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ grep '^\s+type \w+ func\(byte\) \w+$' .obf-src/main/extraLiterals.go

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/modinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ binsubstr main$exe '(devel)'

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/plugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ cmp stderr main.stderr

-- go.mod --
module test/main

go 1.15
-- plugin/main.go --
package main

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/seed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ stderr .

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down
7 changes: 7 additions & 0 deletions testdata/scripts/syntax.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
env GOPRIVATE='test/main,private.source/*'

garble build -tags directives
exec cat go.mod
exec ./main$exe
cmp stderr main.stderr

Expand All @@ -19,6 +20,8 @@ binsubstr main$exe 'globalVar' # 'globalType' only matches on go < 1.15

-- extra/go.mod --
module "private.source/extra"

go 1.15
-- extra/extra.go --
package extra

Expand All @@ -28,8 +31,12 @@ func Func() string {
-- go.mod --
module test/main

go 1.15

// We include an extra module to obfuscate, included in the same original source
// code via a replace directive.
require private.source/extra v0.0.0-00010101000000-000000000000

replace private.source/extra => ./extra
-- main.go --
package main
Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ stdout 'PASS.*TestFoo'

-- go.mod --
module test/bar

go 1.15
-- bar.go --
package bar

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/tiny.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ stderr 'panic: oh noes'

-- go.mod --
module test/main

go 1.15
-- main.go --
package main

Expand Down