Skip to content

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

Open
@bcmills

Description

@bcmills

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.TestingAn issue that has been verified to require only test changes, not just a test failure.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions