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

Commit

Permalink
Tweaking test to find issue with travis
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Nov 9, 2016
1 parent 4406ed2 commit 482b219
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
33 changes: 19 additions & 14 deletions src/goTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function testCurrentPackage(goConfig: vscode.WorkspaceConfiguration) {
*
* @param goConfig Configuration for the Go extension.
*/
export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration): Thenable<boolean> {
export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration): Thenable<string> {
let editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showInformationMessage('No editor is active.');
Expand All @@ -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');
});
}

Expand All @@ -136,8 +136,8 @@ export function testPrevious() {
*
* @param goConfig Configuration for the Go extension.
*/
function goTest(testconfig: TestConfig): Thenable<boolean> {
return new Promise<boolean>((resolve, reject) => {
function goTest(testconfig: TestConfig): Thenable<string> {
return new Promise<string>((resolve, reject) => {
// Remember this config as the last executed test.
lastTestConfig = testconfig;
outputChannel.clear();
Expand All @@ -159,16 +159,21 @@ function goTest(testconfig: TestConfig): Thenable<boolean> {
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);

});
}

Expand Down
4 changes: 2 additions & 2 deletions test/go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down

0 comments on commit 482b219

Please sign in to comment.