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

Fixes #241 Use absolute path in output pane to support links #885

Merged
merged 3 commits into from
Mar 27, 2017

Conversation

ramya-rao-a
Copy link
Contributor

@ramya-rao-a ramya-rao-a commented Mar 26, 2017

Fixes #241

The output from go test -v in case of test failures look like this:

image

This PR is to expand the filename to its absolute path, so that it is clickable and acts as a link to the test file

@@ -191,7 +191,11 @@ export function goTest(testconfig: TestConfig): Thenable<boolean> {
outputChannel.appendLine('');

let proc = cp.spawn(goRuntimePath, args, { env: testEnvVars, cwd: testconfig.dir });
proc.stdout.on('data', chunk => outputChannel.append(chunk.toString()));
proc.stdout.on('data', chunk => {
let testOutput = expandFilePathInOutput(chunk.toString(), testconfig.dir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some option for this tool that could make it output absolute paths?

Copy link
Contributor Author

@ramya-rao-a ramya-rao-a Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I know of.

@rakyll @campoy Do you know if go test -v can print out absolute path of the test file with failing tests?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's an option for this, but if it's really needed we could try to add a PR

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it requires a proposal to merge such a feature. Have you tried the -exec flag? It allows you to intercept the go test with any program you want. You might be able to access to the test file's absolute path with a custom executable.

A sample exec program: https://github.com/golang/go/blob/master/misc/android/go_android_exec.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rakyll and @campoy

The current needs isn't worth the trouble of changing the current behavior.

We will go with expanding the file name from the extensions's side

src/goTest.ts Outdated
function expandFilePathInOutput(output: string, cwd: string): string {
let lines = output.split('\n');
for (let i = 0; i < lines.length; i++) {
let matches = lines[i].match(/^\t(\w+_test.go):(\d+):/);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might not want to use \w here because it might not match all characters that are valid in a path, like .. Maybe \S+ (non whitespace char) or just .+ because it's searching between \t and _test already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to use \S

@ramya-rao-a ramya-rao-a merged commit 90261bc into microsoft:master Mar 27, 2017
@joebehymer
Copy link

Did you ever know that you're my hero

@ramya-rao-a ramya-rao-a deleted the test-output branch April 9, 2017 17:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants