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

Commit

Permalink
Fixes #241 Use absolute path in output pane to support links (#885)
Browse files Browse the repository at this point in the history
* Fixes #241 Use absolute path in output pane to support links

* Refactoring

* Relax the regex for filename
  • Loading branch information
ramya-rao-a authored Mar 27, 2017
1 parent 904b267 commit 90261bc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/goTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
outputChannel.append(testOutput);

});
proc.stderr.on('data', chunk => outputChannel.append(chunk.toString()));
proc.on('close', code => {
if (code) {
Expand Down Expand Up @@ -236,3 +240,14 @@ function getTestFlags(goConfig: vscode.WorkspaceConfiguration, args: any): strin
let testFlags = goConfig['testFlags'] ? goConfig['testFlags'] : goConfig['buildFlags'];
return (args && args.hasOwnProperty('flags') && Array.isArray(args['flags'])) ? args['flags'] : testFlags;
}

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(\S+_test.go):(\d+):/);
if (matches) {
lines[i] = lines[i].replace(matches[1], path.join(cwd, matches[1]));
}
}
return lines.join('\n');
}

0 comments on commit 90261bc

Please sign in to comment.