diff --git a/src/goTest.ts b/src/goTest.ts index 375c94dca..b9f263f75 100644 --- a/src/goTest.ts +++ b/src/goTest.ts @@ -99,7 +99,7 @@ export function testCurrentPackage(goConfig: vscode.WorkspaceConfiguration) { * * @param goConfig Configuration for the Go extension. */ -export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration): Thenable { +export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration): Thenable { let editor = vscode.window.activeTextEditor; if (!editor) { vscode.window.showInformationMessage('No editor is active.'); @@ -113,7 +113,7 @@ export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration): Thenab }); }).then(null, err => { console.error(err); - return Promise.resolve(false); + return Promise.resolve('Something Went Wrong'); }); } @@ -136,8 +136,8 @@ export function testPrevious() { * * @param goConfig Configuration for the Go extension. */ -function goTest(testconfig: TestConfig): Thenable { - return new Promise((resolve, reject) => { +function goTest(testconfig: TestConfig): Thenable { + return new Promise((resolve, reject) => { // Remember this config as the last executed test. lastTestConfig = testconfig; outputChannel.clear(); @@ -159,16 +159,21 @@ function goTest(testconfig: TestConfig): Thenable { args.push(util.format('^%s$', testconfig.functions.join('|'))); } let proc = cp.spawn(goRuntimePath, args, { env: testEnvVars, cwd: testconfig.dir }); - proc.stdout.on('data', chunk => outputChannel.append(chunk.toString())); - proc.stderr.on('data', chunk => outputChannel.append(chunk.toString())); - proc.on('close', code => { - if (code) { - outputChannel.append('Error: Tests failed.'); - } else { - outputChannel.append('Success: Tests passed.'); - } - resolve(code === 0); - }); + let callBack = (chunk) => { + outputChannel.append(chunk.toString()); + proc.on('close', code => { + let msg = 'Success: Tests passed.'; + if (code) { + msg = 'Error: Tests failed.'; + } + outputChannel.append(msg); + msg += chunk.toString(); + resolve(msg); + }); + }; + proc.stdout.on('data', callBack); + proc.stderr.on('data', callBack); + }); } diff --git a/test/go.test.ts b/test/go.test.ts index bb761cb9c..383d3b187 100644 --- a/test/go.test.ts +++ b/test/go.test.ts @@ -366,8 +366,8 @@ encountered. let uri = vscode.Uri.file(path.join(fixturePath, 'sample_test.go')); vscode.workspace.openTextDocument(uri).then(document => { return vscode.window.showTextDocument(document).then(editor => { - return testCurrentFile(config).then((result: boolean) => { - assert.equal(result, true); + return testCurrentFile(config).then((result: string) => { + assert.equal(result.startsWith('Success'), true, `The result: ${result}`); return Promise.resolve(); }); });