diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e24dbfa..26e4cf4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,13 +32,12 @@ jobs: go test -race ./... test-gotip: - if: ${{ false }} # TODO: support Go 1.18, see https://github.com/burrowers/garble/issues/385 runs-on: ubuntu-latest - continue-on-error: true # master breaks sometimes + continue-on-error: true # master may not be as stable steps: - name: Install Go env: - GO_COMMIT: 46fd547d899286982971474b329d7a95da4f2a6b # 2021-08-11 + GO_COMMIT: 578ada410de8065dbca46bca08a5993d1307f423 # 2021-11-09 run: | cd $HOME mkdir $HOME/gotip diff --git a/main_test.go b/main_test.go index 12af7d0..c3816b0 100644 --- a/main_test.go +++ b/main_test.go @@ -91,6 +91,7 @@ func TestScripts(t *testing.T) { "binsubstr": binsubstr, "bincmp": bincmp, "generate-literals": generateLiterals, + "setenvfile": setenvfile, }, UpdateScripts: *update, } @@ -216,6 +217,17 @@ func generateLiterals(ts *testscript.TestScript, neg bool, args []string) { } } +func setenvfile(ts *testscript.TestScript, neg bool, args []string) { + if neg { + ts.Fatalf("unsupported: ! setenvfile") + } + if len(args) != 2 { + ts.Fatalf("usage: setenvfile name file") + } + + ts.Setenv(args[0], ts.ReadFile(args[1])) +} + func TestSplitFlagsFromArgs(t *testing.T) { t.Parallel() tests := []struct { diff --git a/testdata/scripts/modinfo.txt b/testdata/scripts/modinfo.txt index fe5c261..3a432fc 100644 --- a/testdata/scripts/modinfo.txt +++ b/testdata/scripts/modinfo.txt @@ -1,16 +1,31 @@ env GOPRIVATE=test/main -garble build -exec ./main -cmp stderr main.stderr -! binsubstr main$exe '(devel)' +[exec:git] exec git init -q +[exec:git] exec git config user.name "name" +[exec:git] exec git config user.email "name@email.local" +[exec:git] exec git add go.mod main.go +[exec:git] exec git commit -q -m 'very unique commit message' +[exec:git] exec git rev-parse HEAD +[exec:git] setenvfile HEAD_COMMIT_SHA stdout + +garble build -tags veryuniquebuildtag +! binsubstr main$exe '(devel)' 'veryuniquebuildtag' ${HEAD_COMMIT_SHA} + +go version -m main$exe +stdout 'main(\.exe)?: unknown' +stdout -count=1 '^.+$' # expect just one line [short] stop # no need to verify this with -short -go build -exec ./main -cmp stderr main.stderr-orig -binsubstr main$exe '(devel)' +go build -tags veryuniquebuildtag +[!go1.18] binsubstr main$exe '(devel)' +[go1.18] binsubstr main$exe '(devel)' 'veryuniquebuildtag' ${HEAD_COMMIT_SHA} + +go version -m main$exe +stdout 'path\s*test/main' +stdout 'mod\s*test/main\s*\(devel\)' +[go1.18] stdout 'build\s*tags.*veryuniquebuildtag' +[go1.18] stdout 'build\s*gitrevision.*'${HEAD_COMMIT_SHA} -- go.mod -- module test/main @@ -19,16 +34,4 @@ go 1.17 -- main.go -- package main -import "runtime/debug" - -func main() { - if info, ok := debug.ReadBuildInfo(); ok { - println("version", info.Main.Version) - } else { - println("no version") - } -} --- main.stderr-orig -- -version (devel) --- main.stderr -- -no version +func main() { println("hello world") }