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

cmd/go: go list -json -compiled -test -e upspin.io/test fails with non-zero exit status #27097

Closed
dominikh opened this issue Aug 20, 2018 · 9 comments

Comments

@dominikh
Copy link
Member

What version of Go are you using (go version)?

go version devel +88aa208 Mon Aug 20 08:01:43 2018 +0000 linux/amd64

What did you do?

conf := &packages.Config{
	Tests: true,
}
pkgs, err := packages.Load(conf, "upspin.io/test")
fmt.Println(pkgs, err)

What did you expect to see?

No error; the test package(s) to be returned

What did you see instead?

[] go list: exit status 1: go build upspin.io/test: no non-test Go files in /home/dominikh/prj/src/upspin.io/test

/cc @alandonovan @ianthehat @rsc

@gopherbot gopherbot added this to the Unreleased milestone Aug 20, 2018
@dominikh
Copy link
Member Author

Furthermore, this happens even for "upspin.io/...".

When running go list -json -compiled -test upspin.io/test, this is the abridged output:

go build upspin.io/test: no non-test Go files in /home/dominikh/prj/src/upspin.io/test
{
        "Dir": "/home/dominikh/prj/src/upspin.io/test",
        "ImportPath": "upspin.io/test",
        "Name": "test",
        "Target": "/home/dominikh/prj/pkg/linux_amd64/upspin.io/test.a",
        "Root": "/home/dominikh/prj/",
        "Match": [
                "upspin.io/test"
        ],
        "Stale": true,
        "StaleReason": "build ID mismatch",
        "TestGoFiles": [
                "access_test.go",
                "all_test.go",
                "copy_test.go",
                "error_test.go",
                "group_test.go",
                "integration_test.go",
                "snapshot_test.go",
                "watch_test.go"
        ],

and the exit status is 1.

@matloob
Copy link
Contributor

matloob commented Aug 20, 2018

Even worse, go list -json -compiled -test -e upspin.io/test (with -e) fails. This should be fixed

@matloob matloob modified the milestones: Unreleased, Go1.11 Aug 20, 2018
@matloob matloob changed the title x/tools/go/packages: cannot load packages consisting of only tests cmd/go: go list -json -compiled -test -e upspin.io/test fails with non-zero exit status Aug 20, 2018
@andybons
Copy link
Member

@alandonovan
Copy link
Contributor

The result is independent of the -json flag; it's the -compiled flag that causes go list to attempt a build, and a build of a tests-only package fails ("no non-test Go files"). For golang.org/x/tools/go/packages, the desired outcome is that go list succeeds, reporting an empty Package.Target field and no errors.

(Ignoring the needs of go/packages, there would be a certain consistency if go list and go list -test were to pass and fail, respectively, on a tests-only package, but currently even go list -test fails where go test succeeds.)

Related: #27101

@gopherbot
Copy link

Change https://golang.org/cl/130135 mentions this issue: cmd/go: ignore empty gofiles when running list

@matloob matloob self-assigned this Aug 20, 2018
@andybons
Copy link
Member

@gopherbot please open a backport for 1.11

@gopherbot
Copy link

gopherbot commented Aug 20, 2018

Backport issue(s) opened: #27104 (for 1.11)

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@gopherbot
Copy link

Change https://golang.org/cl/130139 mentions this issue: cmd/go: fix list -compiled of package with only tests

@gopherbot
Copy link

Change https://golang.org/cl/130617 mentions this issue: [release-branch.go1.11] cmd/go: fix list -compiled of package with only tests

gopherbot pushed a commit that referenced this issue Aug 22, 2018
…ly tests

Fixes #27097.

Change-Id: I6aa48a1c58a21fd320b0e9dcd1f86c90172f0182
Reviewed-on: https://go-review.googlesource.com/130139
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit df6aedb)
Reviewed-on: https://go-review.googlesource.com/130617
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Aug 21, 2019
@rsc rsc unassigned matloob Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants