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

How to specify go test to build and run executable in exact folder but not random folder #49238

Closed
szmcdull opened this issue Oct 30, 2021 · 5 comments

Comments

@szmcdull
Copy link

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

$ go version
go version go1.17 windows/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\EDZ\AppData\Local\go-build
set GOENV=C:\Users\EDZ\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=d:\golibs\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=d:\golibs
set GOPRIVATE=
set GOPROXY=direct
set GOROOT=D:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\code\digifinex\acts\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\EDZ\AppData\Local\Temp\go-build2790652590=/tmp/go-build -gno-record-gcc-switches

What did you do?

D:\Go\bin\go.exe test -timeout 1m -tags debug -run ^TestActs$ acts/util -o test -count=1

What did you expect to see?

build the test to the file test and then run it

What did you see instead?

built the test to the file test but then run it in a random temp folder.
Each time I go test a new file in a new random folder is created and run. And Windows Firewall warn me to add a rule to allow it to listen on a local port (because in the test I must listen on a local port)

@szmcdull
Copy link
Author

Please help I don't want to garbage my firewall rules

@ALTree
Copy link
Member

ALTree commented Oct 30, 2021

Hi,

the Go project does not use its bug tracker for general discussion or asking questions about the language. The Github bug tracker is only used for tracking bugs and proposals going through the Proposal Process.

Please see the Questions wiki page; it has a list of good places for asking questions. Thanks!

Closing here, since this is not a bug.

@ALTree ALTree closed this as completed Oct 30, 2021
@szmcdull
Copy link
Author

szmcdull commented Nov 5, 2021

It is not a question. I just tried to be polite.

        -o file
            Compile the test binary to the named file.
            The test still runs (unless -c or -i is specified).

In fact it still compiles to random folder/file.test but then copies it to file. The test still runs in the temporary folder which is non-sense.

@ALTree
Copy link
Member

ALTree commented Nov 5, 2021

-c will generate a binary for the test that you can then run from your folder. Doesn't that work?

@szmcdull
Copy link
Author

szmcdull commented Nov 5, 2021

-c will generate a binary for the test that you can then run from your folder. Doesn't that work?

I'm not sure how to reproduce a bug. I need to mock the server and debug the use case. Theoretically -c will work. But it needs extra commands and is not that convenience.

@golang golang locked and limited conversation to collaborators Nov 5, 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

3 participants