Skip to content

cmd/go: cache not invalidated if testdata files are changed while the test is running #26790

@bcmills

Description

@bcmills

I was editing cmd/go/testdata/mod_test.txt for #26722, and saw an unexpected (cached) test result.

I run tests pretty aggressively while editing, so I suspect that I saved the file while a previous test run was in progress. We appear to have cached the result based on the contents of the testdata directory after the run completed, not the contents at the start of the run.

~/go/src$ go test cmd/go -run=TestScript
ok      cmd/go  (cached)

~/go/src$ GODEBUG=gocacheverify=1 go test cmd/go -run=TestScript
go test proxy starting
go test proxy running at GOPROXY=http://127.0.0.1:38657/mod
go proxy: no archive w.1 v1.2.0
go proxy: no archive x.1 v1.0.0
go proxy: no archive z.1 v1.2.0
go proxy: no archive golang.org/x/text/language 14c0d48
go proxy: no archive golang.org/x/text/language 14c0d48
go proxy: no archive golang.org/x/text/language 14c0d48
go proxy: no archive golang.org/x/text/foo 14c0d48
go proxy: no archive sub.1 v1.0.0
go proxy: no archive badsub.1 v1.0.0
go proxy: no archive versioned.1 v1.0.0
go proxy: no archive versioned.1 v1.1.0
--- FAIL: TestScript (0.00s)
    --- FAIL: TestScript/mod_test (1.28s)
        script_test.go:150:
            # A test in the module's root package should work. (1.107s)
            # A test with the "_test" suffix in the module root should also work. (0.171s)
            > cd ../b/
            $WORK/gopath/src/b
            > go test
            [stderr]
            build github.com/user/b_test: cannot find module for path github.com/user/b_test
            [exit status 1]
            FAIL: testdata/script/mod_test.txt:10: unexpected command failure

FAIL
FAIL    cmd/go  9.231s

~/go/src$ go test cmd/go -run=TestScript
ok      cmd/go  (cached)

~/go/src$ go version
go version devel +fc1a18c452 Fri Aug 3 11:36:32 2018 -0400 linux/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions