Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Testing tool doesn't show output #1120

Closed
mileusna opened this issue Jul 28, 2017 · 16 comments
Closed

Testing tool doesn't show output #1120

mileusna opened this issue Jul 28, 2017 · 16 comments

Comments

@mileusna
Copy link

mileusna commented Jul 28, 2017

I love "run test" option in test files.

However, after VS Code update on 1.14.2 on MacOS executing tests inside Code doesn't show up any log output. So if I have log.Println(err) it won't be printed, however, fmt.Println(err) will be printed.

@ramya-rao-a
Copy link
Contributor

I am able to see the log.Println output

screen shot 2017-07-28 at 2 31 33 pm

Can you share sample code?

@mileusna
Copy link
Author

Sure, anything. Same testing works OK in terminal window.

It just started to happen after the VS Code upgrade.
screen shot 2017-07-29 at 01 16 13

@ramya-rao-a
Copy link
Contributor

Ah! Looks like the log part is going to stderr and the fmt one goes to stdout

screen shot 2017-07-28 at 4 34 09 pm

And in a recent commit stderr is not shown unless there is a test failure 94dadaa

@uudashr Can you take a look at this?

@ramya-rao-a ramya-rao-a changed the title Testing tool doesn't show log output after updating to VS Code 1.14.2 Testing tool doesn't show log output unless there is a test failure Jul 28, 2017
@mileusna
Copy link
Author

mileusna commented Jul 29, 2017

Sorry, but this new description is incorrect, I don't see log.* output, failure or no failure. It has nothing to do with the test's outcome.

screen shot 2017-07-29 at 05 37 28

@mileusna mileusna changed the title Testing tool doesn't show log output unless there is a test failure Testing tool doesn't show log output Jul 29, 2017
@ramya-rao-a
Copy link
Contributor

@mileusna Its right there.... look at the line which has the file path... In the end it says "Failed, but no Hello"

@ramya-rao-a
Copy link
Contributor

I have pushed a fix. But even with the fix the log will appear after the rest of the output. This is because like I said earlier, log is going to stderr. And while running the go test the extension can only fetch stdout and stderr separately.

@ramya-rao-a ramya-rao-a changed the title Testing tool doesn't show log output Testing tool doesn't show log output unless there is a test failure Jul 29, 2017
@uudashr
Copy link
Contributor

uudashr commented Jul 29, 2017

@ramya-rao-a your changes on the master?

@mileusna
Copy link
Author

mileusna commented Jul 29, 2017

@ramya-rao-a Yes, the t.Error is there but not the log.Println. That is why I wrote no Hello, there is no Hello on the screen from log.Println("Hello")

This is the same code on macOS with VS Code. 1.14.0 and vscode-go v0.6.62.
28744691-a61fb76e-7466-11e7-8281-38e2bdbce1a3

And this is with upgraded VS Code 1.14.2 and vscode-go v0.6.63
28744695-c392c7aa-7466-11e7-92b0-68a88d28ae89

In both cases t.Error makes test fail, but there is no log.Println output.

I thought that it was the version of the VS Code that is problematic with vscode-go, but now I realised that the vscode-go is also different version 0.6.63 vs 0.6.62 so I guess it is the vscode-go 0.6.63 issue, not related to the VS Code upgrade.

@mileusna mileusna changed the title Testing tool doesn't show log output unless there is a test failure Testing tool doesn't show log output Jul 29, 2017
@uudashr
Copy link
Contributor

uudashr commented Jul 29, 2017

Fixed on #1124 cc @ramya-rao-a

@ramya-rao-a
Copy link
Contributor

This fix is now out in the latest update to the Go extension 0.6.64

@mileusna
Copy link
Author

mileusna commented Oct 5, 2017

Latest update, with VS Code 1.17.0 and vscode-go 0.6.66 neither stderr nor stdout is printed with testing tool. Only if there is t.Error("x"), then I see the output of fmt.Println() and log.Println()

@mileusna mileusna changed the title Testing tool doesn't show log output Testing tool doesn't show output Oct 5, 2017
@uudashr
Copy link
Contributor

uudashr commented Oct 5, 2017

To print to stderr or stdout, you need to add-v to the go test command. Add test flag to the settings

{
"go.testFlags": ["-v"]
}

@mileusna
Copy link
Author

mileusna commented Oct 6, 2017

OK. It is not the same behavior as go test which gives output even without -v, but verbose will do the trick. Thanks.

@ramya-rao-a
Copy link
Contributor

@mileusna You are right, previously, we were running a simple go test which gives the output even without -v

We moved to using go test package which does not give such output unless -v is passed.

The move was made to support running tests in symlinked folders. See #1164

I'll look into documenting this better

@martinlindhe
Copy link

The move was made to support running tests in symlinked folders. See #1164

symlinks are not mentioned in #1164 and this change seem to have degraded the experience of vscode, what gives? (See also #1381)

@ramya-rao-a
Copy link
Contributor

@martinlindhe #1164 is a PR which is linked to #846 (comment) which in turn talks about the symlinks

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants