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

Go test prints out all logs from the code without verbose option #528

Closed
leguminosa opened this issue Aug 14, 2020 · 14 comments
Closed

Go test prints out all logs from the code without verbose option #528

leguminosa opened this issue Aug 14, 2020 · 14 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@leguminosa
Copy link

Please direct general questions to:

Please review the documentation before filing an issue.
Helpful pages include:

Please answer these questions before submitting your issue. Thanks!

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go

    • go version go1.13 linux/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders

    • 1.48.0
      db40434f562994116e5b21c24015a2e40b2504e6
      x64
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.16.1
  • Run go env to get the go development environment details

    • GO111MODULE="auto"
      GOARCH="amd64"
      GOBIN=""
      GOCACHE="/home/nakama/.cache/go-build"
      GOENV="/home/nakama/.config/go/env"
      GOEXE=""
      GOFLAGS=""
      GOHOSTARCH="amd64"
      GOHOSTOS="linux"
      GONOPROXY=""
      GONOSUMDB=""
      GOOS="linux"
      GOPATH="/home/nakama/.gvm/pkgsets/go1.13/global"
      GOPRIVATE=""
      GOPROXY="https://proxy.golang.org,direct"
      GOROOT="/home/nakama/.gvm/gos/go1.13"
      GOSUMDB="sum.golang.org"
      GOTMPDIR=""
      GOTOOLDIR="/home/nakama/.gvm/gos/go1.13/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-build061898164=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

"go.lintTool": "golangci-lint",
"go.lintFlags": [
    "--fast",
    "--enable=gocyclo",
    "--enable=goconst",
    "--enable=gocognit",
    "--disable=errcheck",
    "--disable=staticcheck",
    "--disable=govet"
],
"go.vetFlags": [
    "-composites=false"
],
"go.coverageDecorator": {
    "type": "highlight",
    "coveredHighlightColor": "rgba(64,128,128,0.5)",
    "uncoveredHighlightColor": "rgba(128,64,64,0.25)",
    "coveredGutterStyle": "blockgreen",
    "uncoveredGutterStyle": "blockred"
},
// "go.testOnSave": true,
"go.coverOnSave": true,
"go.coverOnSingleTest": true,
"go.coverOnSingleTestFile": true,
"go.testFlags": [],
"go.formatTool": "goimports",
"go.gopath": "/home/nakama/.gvm/pkgsets/go1.13/global",
"go.goroot": "/home/nakama/.gvm/gos/go1.13",
"go.useLanguageServer": true,
"go.languageServerFlags": [
    "-rpc.trace",
    "serve",
    "--debug=localhost:6060",
],

Describe the bug

A clear and concise description of what the bug.
A clear and concise description of what you expected to happen.
I don't put verbose flag in go test, but in output go test tab, the logs from the code all appears even if the tests are all succeed

Steps to reproduce the behavior:

  1. With cover on save set to true, just save the code anywhere, and vscode shall run go test for that package.
    image

  2. I tried running the go test via terminal as a comparison, and it clearly is verboseless, so it's not the problem from the code.
    image

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

@hyangah
Copy link
Contributor

hyangah commented Aug 14, 2020

Strangely the output is different from the verbose output either. Can you try the exact same command the extension is running (no target arg) from the package directory?

/home/nakama/.gvm/gos/go1.13/bin/go test -timeout 30s

@leguminosa
Copy link
Author

Strangely the output is different from the verbose output either. Can you try the exact same command the extension is running (no target arg) from the package directory?

/home/nakama/.gvm/gos/go1.13/bin/go test -timeout 30s

I did, the screenshot is attached above

@hyangah
Copy link
Contributor

hyangah commented Aug 14, 2020

@leguminosa From the screenshot, I see you specified the target (the package path).
Based on the log output, I guess the output is printed outside of the testing package.
https://user-images.githubusercontent.com/38403278/90266485-47332080-de7e-11ea-8e53-02fc05ed29be.png

Not sure what utilities you are using to generate the log, but if they are using the standard log or fmt packages, they appear in non-verbose go test output. See below.

$ cat quote_test.go
... 
func TestGlass(t *testing.T) {
	fmt.Println("here is fmt.Println(`fmt msg`)")
	log.Println("here is log.Println(`log msg`)")
}
...

$ go test
here is fmt.Println(`fmt msg`)
2020/08/14 13:43:17 here is log.Println(`log msg`)
PASS
ok      rsc.io/quote    0.075s

@leguminosa
Copy link
Author

It wasn't logged out at all before, and the logging tools hasn't changed since. We're using custom logger (not standard fmt nor log.logger instance).

I will try again without specifying the package,

But even if the command shown in the output doesn't include package, the command runs package test (as in, not a whole packages test, but only one package in whichever I press save - with cover on save option enabled)

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/248738 mentions this issue: src/testUtils.ts: always run test in package list mode

@hyangah
Copy link
Contributor

hyangah commented Aug 15, 2020

@leguminosa Thanks for providing more info. I hope the cl/248738 to address the regression.

@hyangah hyangah added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 15, 2020
@hyangah hyangah added this to the v0.16.2 milestone Aug 15, 2020
@leguminosa
Copy link
Author

leguminosa commented Aug 16, 2020

Thank you @hyangah so much for your assistance, do you still need me to reproduce or do anything?

@hyangah
Copy link
Contributor

hyangah commented Aug 17, 2020

@leguminosa Once this is released as Go Nightly, would be nice if you have time to test it. Thanks!

@leguminosa
Copy link
Author

Thank you very much for your help @hyangah !

I tried installing older version (before 0.16) and yes it is returning to previous state (clean output for success test), so all changes mentioned in this issue is in 0.16 cycles...

btw what is Go Nightly? like beta / pre-release version?

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/252119 mentions this issue: [release] src/testUtils.ts: always run test in package list mode

gopherbot pushed a commit that referenced this issue Sep 1, 2020
During v0.16 dev cycle, we switched tests to run in local directory
mode by not specifying the target package path to be tested.

This has two unintended side-effects:

1) prints all stderr/stdout from the tested target when tests succeed.
2) disables test caching.

Whether `Go: Test Package` should run the tests in local directory
mode or in package list mode is debatable.
https://golang.org/cmd/go/#hdr-Test_packages
But, we've been using the package list mode for a long time without
complaint. So, this is a regression that needs to be fixed.

Fixes #528

Change-Id: Ied06130db1ab6e53b2fb3a3b19ab13b0985fc779
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/248738
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
(cherry picked from commit a357893e7b5c24c1443deaca629584e47b4e22c2)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/252119
@leguminosa
Copy link
Author

what should I do right now? @hyangah
0.16.2 hasn't released yet, but there is pre-release, should I try download the .vsix https://github.com/golang/vscode-go/releases/tag/v0.16.2-rc.1 and install it on my vscode?

@hyangah
Copy link
Contributor

hyangah commented Sep 2, 2020

@leguminosa Yes, please. The prerelease vsix loading instruction is here (https://github.com/golang/vscode-go/blob/master/docs/nightly.md#testing-pre-releases).

@hyangah
Copy link
Contributor

hyangah commented Sep 2, 2020

I manually tested it and made it 0.16.2.

@leguminosa
Copy link
Author

I just updated my vscode-go to 0.16.2, and the go test works like it used to do, it solved this issue.

Thank you very much @hyangah
FB_IMG_1597807776896

@golang golang locked and limited conversation to collaborators Sep 3, 2021
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

3 participants