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: test -v flag changes behavior of bogus attempt to test a filename? #8111

Closed
bradfitz opened this issue May 27, 2014 · 2 comments
Closed

Comments

@bradfitz
Copy link
Contributor

A user tried to use go test with a filename here
(https://github.com/bradfitz/docker/pull/31) and was presumably misled by the go tool's
behavior.

I notice that its behavior differs when using -v:

With -v it appears to work, but shouldn't?

bradfitz@bradfitz:~/src/github.com/dotcloud/docker$ go test -v vfuse/all_test.go
=== RUN TestStatRegular
--- PASS: TestStatRegular (4.30 seconds)
=== RUN TestStatNoExist
--- PASS: TestStatNoExist (0.00 seconds)
=== RUN TestStatDir
--- PASS: TestStatDir (0.00 seconds)
=== RUN TestStatSymlink
--- PASS: TestStatSymlink (0.00 seconds)
=== RUN TestReadlink
--- PASS: TestReadlink (0.00 seconds)
=== RUN TestReaddirnamesEmpty
--- PASS: TestReaddirnamesEmpty (0.00 seconds)
=== RUN TestReaddirnames
--- PASS: TestReaddirnames (0.00 seconds)
=== RUN TestReaddirWalk
--- PASS: TestReaddirWalk (0.00 seconds)
=== RUN TestChmod
--- PASS: TestChmod (0.00 seconds)
=== RUN TestOpenRead
--- SKIP: TestOpenRead (0.07 seconds)
    all_test.go:31: skipping known-broken test
    all_test.go:236: (end of all tests; shutting down world)
PASS
ok      command-line-arguments  4.387s



And without -v, it does something, but what?

bradfitz@bradfitz:~/src/github.com/dotcloud/docker$ go test vfuse/all_test.go
ok      command-line-arguments  2.315s
@robpike
Copy link
Contributor

robpike commented May 28, 2014

Comment 1:

It runs the tests and they passed. Nothing to see here.
If all tests pass and you say -v or give no arguments, the go command hides the output.
If you ran the binary directly, or gave it a package name, you'd see the PASS. It's
slightly odd behavior but it is what it does.
% cd fmt
% go test -c
% ./fmt.test
PASS
% go test
PASS
ok      fmt 0.045s
% go test fmt
ok      fmt 0.058s
%
There may be something to report here, and you can complain about the secret rules about
test output, but I don't see a problem.

Status changed to WorkingAsIntended.

@bradfitz
Copy link
Contributor Author

Comment 2:

go help test says:
"usage: go test [-c] [-i] [build and test flags] [packages] [flags for test binary]"
It implies it takes packages, and not filenames.
But then what does this line mean:
ok      command-line-arguments  2.315s
Why does it say "command-line-arguments" ?
Note that in my case above, I was running the go tool from the parent directory of where
the tests were, so if vfuse/all_test.go was actually treated as a command-line argument,
then it would've tried to run tests in the parent directory where no tests exist.
I guess I just don't know what's going on, and if any of this is by design.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

3 participants