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

x/tools/go/expect: test fails when run from the module cache #40309

Open
bcmills opened this issue Jul 20, 2020 · 1 comment
Open

x/tools/go/expect: test fails when run from the module cache #40309

bcmills opened this issue Jul 20, 2020 · 1 comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jul 20, 2020

The test for golang.org/x/tools/go/expect fails when run from another module.

A go.mod file was added to the package's testdata directory in CL 216838. However, that cuts off the testdata directory from the rest of the module: there is no special handling for go.mod files in testdata directories (see #27852). The missing testdata directory causes the test to fail when it is run from anywhere other than a clone of the tools repository — notably, including when it is run from the module cache, including as a dependency of any other module.

$ go version
go version devel +0951939f Fri Jul 17 19:09:40 2020 +0000 linux/amd64

$ go test golang.org/x/tools/go/expect
--- FAIL: TestMarker (0.00s)
    --- FAIL: TestMarker/testdata/test.go (0.00s)
        expect_test.go:57: open testdata/test.go: no such file or directory
    --- FAIL: TestMarker/testdata/go.mod (0.00s)
        expect_test.go:57: open testdata/go.mod: no such file or directory
FAIL
FAIL    golang.org/x/tools/go/expect    0.012s
FAIL

-- go.mod --
module example.com

go 1.15

require golang.org/x/tools v0.0.0-20200720150256-cf97b7f4a4c1 // indirect

CC @stamblerre @ridersofrohan @ianthehat

@bcmills bcmills added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsFix The path to resolution is known, but the work has not been done. labels Jul 20, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 20, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jul 20, 2020
@stamblerre
Copy link
Contributor

Probably the correct fix for this and for #40310 will be to have go.mod.in files in the testdata directories, and then just write them out to the temporary directories during the actual tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants