-
Notifications
You must be signed in to change notification settings - Fork 646
Fixes #241 Use absolute path in output pane to support links #885
Conversation
@@ -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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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+):/); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to use \S
Did you ever know that you're my hero |
Fixes #241
The output from
go test -v
in case of test failures look like this: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