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 test' adds test.timeout flag after positional arguments #34072

Closed
juliusmh opened this issue Sep 4, 2019 · 5 comments
Closed

cmd/go: 'go test' adds test.timeout flag after positional arguments #34072

juliusmh opened this issue Sep 4, 2019 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@juliusmh
Copy link

juliusmh commented Sep 4, 2019

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

$ go version
go version go1.13 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/juliusmh/.cache/go-build"
GOENV="/home/juliusmh/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/juliusmh/go/"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build898241332=/tmp/go-build -gno-record-gcc-switches"

What did you do?

In a module test we have named flags as well as positional arguments. When we run the tests using go test ... -flag 1 positional the -test.timeout is appended resulting in go test ... -flag 1 positional -test.timeout=10m. Flags after positional arguments are not parsed anymore which makes -test.timeout=10m a positional argument as well.

What did you expect to see?

The tests should run as in 1.12, no timeout flag specified.

What did you see instead?

The timeout flag -test.timeout=10m was not parsed correctly but ends up as a positional argument.

Possible fix?

Add the -test.timeout=10m flag at the very beginning, making it immune to breaking positional arguments. Updated docs mentioning that behavior would be highly appreciated too. The line causing that behavior is /src/cmd/go/internal/test/test.go.

@juliusmh juliusmh changed the title go test adds test.timeout flag after positional arguments go test adds test.timeout flag after positional arguments (go 1.13) Sep 4, 2019
@bcmills bcmills changed the title go test adds test.timeout flag after positional arguments (go 1.13) cmd/go: 'go test' adds test.timeout flag after positional arguments Sep 4, 2019
@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 4, 2019
@bcmills bcmills added this to the Go1.14 milestone Sep 4, 2019
@bcmills bcmills self-assigned this Sep 4, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 4, 2019

@gopherbot, please backport to Go 1.13: this is a regression and the fix is trivial.

@gopherbot
Copy link

Change https://golang.org/cl/193297 mentions this issue: cmd/go/internal/test: prepend -test.timeout rather than appending

@gopherbot
Copy link

Backport issue(s) opened: #34083 (for 1.13).

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/193269 mentions this issue: [release-branch.go1.13] cmd/go/internal/test: prepend -test.timeout rather than appending

@mjl-
Copy link

mjl- commented Sep 5, 2019

To run tests with go1.13 add "-timeout 0" to prevent the -test.timeout flag from being appended:

go1.13 test -timeout 0 -args ...

gopherbot pushed a commit that referenced this issue Sep 5, 2019
…ather than appending

Tests may accept positional arguments, in which case the -test.timeout
flag must be passed before those arguments.

Updates #34072
Fixes #34083

Change-Id: I5b92d7c0edc4f9e1efb63b0733937b76236c0eff
Reviewed-on: https://go-review.googlesource.com/c/go/+/193297
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit d21953d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/193269
t4n6a1ka pushed a commit to t4n6a1ka/go that referenced this issue Sep 5, 2019
Tests may accept positional arguments, in which case the -test.timeout
flag must be passed before those arguments.

Fixes golang#34072

Change-Id: I5b92d7c0edc4f9e1efb63b0733937b76236c0eff
Reviewed-on: https://go-review.googlesource.com/c/go/+/193297
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Sep 4, 2020
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants