Skip to content

Commit 08ab287

Browse files
check for failed tasks (#9205)
1 parent 3c98246 commit 08ab287

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class CustomBuildTaskTerminal implements Pseudoterminal {
405405
let error: string = "";
406406
let stdout: string = "";
407407
let stderr: string = "";
408-
const result: number = await new Promise<number>(resolve => {
408+
const spawnResult: number = await new Promise<number>(resolve => {
409409
if (child) {
410410
child.on('error', err => {
411411
splitWriteEmitter(err.message);
@@ -427,29 +427,36 @@ class CustomBuildTaskTerminal implements Pseudoterminal {
427427
if (result === null) {
428428
this.writeEmitter.fire(localize("build.run.terminated", "Build run was terminated.") + this.endOfLine);
429429
resolve(-1);
430+
} else {
431+
resolve(0);
430432
}
431-
resolve(0);
432433
});
433434
}
434435
});
435-
this.printBuildSummary(error, stdout, stderr);
436+
let result: number = this.printBuildSummary(error, stdout, stderr);
437+
if (spawnResult === -1) {
438+
result = -1;
439+
}
436440
this.closeEmitter.fire(result);
437441
} catch {
438442
this.closeEmitter.fire(-1);
439443
}
440444
}
441445

442-
private printBuildSummary(error: string, stdout: string, stderr: string): void {
446+
private printBuildSummary(error: string, stdout: string, stderr: string): number {
443447
if (error || (!stdout && stderr && stderr.includes("error")) ||
444448
(stdout && stdout.includes("error C"))) { // cl.exe compiler errors
445449
telemetry.logLanguageServerEvent("cppBuildTaskError");
446450
this.writeEmitter.fire(localize("build.finished.with.error", "Build finished with error(s).") + this.endOfLine);
451+
return -1;
447452
} else if ((!stdout && stderr) || // gcc/clang
448453
(stdout && stdout.includes("warning C"))) { // cl.exe compiler warnings
449454
telemetry.logLanguageServerEvent("cppBuildTaskWarnings");
450455
this.writeEmitter.fire(localize("build.finished.with.warnings", "Build finished with warning(s).") + this.endOfLine);
456+
return 0;
451457
} else {
452458
this.writeEmitter.fire(localize("build.finished.successfully", "Build finished successfully.") + this.endOfLine);
459+
return 0;
453460
}
454461
}
455462
}

0 commit comments

Comments
 (0)