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

Extra whitespace in running test output #1381

Closed
martinlindhe opened this issue Nov 29, 2017 · 9 comments
Closed

Extra whitespace in running test output #1381

martinlindhe opened this issue Nov 29, 2017 · 9 comments

Comments

@martinlindhe
Copy link

martinlindhe commented Nov 29, 2017

When I click "run test" on a single test function in vscode, the output looks like this:

in_vscode

If I instead copy the command line that vscode claims to have used and run it in the terminal,

$ /usr/local/bin/go test -timeout 30s github.com/martinlindhe/XXXX-tests -run ^TestXXXXXXX$

I get the following output:

in_terminal

First, there are a bunch of whitespace taking up space in my output window.

Secondly, the line "assertions.go:239" is confusing, since it is not present when running from terminal.

@ramya-rao-a
Copy link
Contributor

When you run the test command separately, you only see the stdout
When running test in VS Code, it shows both stdout and stderr
Please follow the discussion in #1120 where we talk about this.

Can you run the same test command and see what you get in stderr?

@martinlindhe
Copy link
Author

martinlindhe commented Nov 30, 2017

When you run the test command separately, you only see the stdout

This can't be right. I am quite sure my terminal is showing both stderr and stdout, and as you can see in the command I used, I didn't redirect any streams.

The "terminal" i am talking about is iTerm, not the one you built into vscode.

Will look at the odiscussion in #1120

Can you run the same test command and see what you get in stderr?

The output i showed in post 1 includes stdout and stderr.

@martinlindhe
Copy link
Author

martinlindhe commented Nov 30, 2017

@ramya-rao-a #1120 is unrelated to this issue.

in #1120, there is talk about stdout/stderr not showing up in test run output.

This issue however, is, as you can see in post 1 about extra stuff showing up in test output.

@martinlindhe
Copy link
Author

martinlindhe commented Nov 30, 2017

So, according to #1120 you no longer actually run "go test", so the command line you are showing is indeed not really what was run. That could explain the mysterious appearance of "assertions.go:239" as I mentioned in post 1.

So, is this "go test package" also the one adding the whitespace?

I am referrring to #1120 (comment)

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 30, 2017

We dont literally run go test package, we run go test <import-path-to your-package>
What is being printed in the output channel is exactly what is being run.

If you are up for it, I can help you debug this by running the extension code from source

@martinlindhe
Copy link
Author

martinlindhe commented Dec 1, 2017

Dear @ramya-rao-a

Thanks for your patience and clarifications!

I made another observation that I think is relevant.

When using go/testing, the internal testing system, vscode test output looks as expected.

I only get these extra whitespace as in screenshot when using github.com/stretchr/testify/assert, a very popular third-party testing framework for go.

Mini reproducable tiny_test.go:

package tiny

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestInternal(t *testing.T) {
	if 1 != 2 {
		t.Error("TestInternal marked failed")
	}
}

func TestTestify(t *testing.T) {
	assert.Equal(t, 1, 2, "TestTestify marked failed")
}

Output from running file tests in vscode:
screen shot 2017-12-01 at 11 31 27

Output from running the same command in zsh:

screen shot 2017-12-01 at 11 32 05

And output from running the same command in zsh, with -v flag:

screen shot 2017-12-01 at 12 05 06

@ramya-rao-a
Copy link
Contributor

Append 2>&1 | tee output to the end of the test command when you run from zsh and then open the "output" file.

stdout and stderr both are redirected to the "output" file

You will see the blank lines

@martinlindhe
Copy link
Author

martinlindhe commented Dec 4, 2017

@ramya-rao-a
You are fully right.

with 2>&1 | tee output i can confirm the extra stuff is there, but that is not a vscode issue

Thanks again

@ramya-rao-a
Copy link
Contributor

No problem, Happy Coding!

@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

2 participants