Skip to content

Commit

Permalink
Fix error output not being included in rush test/cover summaries. (#2281
Browse files Browse the repository at this point in the history
)

Also stop logging useless "Error: Command failed: ..." errors/call stacks when a test process fails.
  • Loading branch information
wgoehrig authored Sep 17, 2021
1 parent f6ba958 commit 4d1e022
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@bentley/build-tools",
"comment": "",
"type": "none"
}
],
"packageName": "@bentley/build-tools"
}
8 changes: 7 additions & 1 deletion tools/build/bin/betools.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,11 @@ function pseudolocalizeCommand(options) {
function exec(cmd) {
console.log("Running command:");
console.log(cmd.join(" "));
return child_process.execSync(cmd.join(" "), { encoding: "utf8", stdio: 'inherit' });
try {
return child_process.execSync(cmd.join(" "), { encoding: "utf8", stdio: 'inherit' });
} catch (error) {
if (error.status)
process.exit(error.status);
throw error;
}
}
6 changes: 3 additions & 3 deletions tools/build/scripts/rush/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
*--------------------------------------------------------------------------------------------*/
function logBuildWarning(msg) {
if (process.env.TF_BUILD)
console.log("##vso[task.logissue type=warning;]%s", msg);
console.error("##vso[task.logissue type=warning;]%s", msg);
else
console.error("WARNING: %s", msg);
}

function logBuildError(msg) {
if (process.env.TF_BUILD)
console.log("##vso[task.logissue type=error;]%s", msg);
console.error("##vso[task.logissue type=error;]%s", msg);
else
console.error("ERROR: %s", msg);
}

function failBuild() {
if (process.env.TF_BUILD) {
console.log("##vso[task.complete result=Failed;]DONE")
console.error("##vso[task.complete result=Failed;]DONE")
process.exit(0);
} else {
process.exit(1);
Expand Down
6 changes: 3 additions & 3 deletions tools/build/src/mocha-reporter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const Spec = require("mocha/lib/reporters/spec");
const MochaJUnitReporter = require("mocha-junit-reporter");

function withStdErr(callback: () => void) {
const originalConsoleLog = console.log;
console.log = console.error;
const originalConsoleLog = Base.consoleLog;
Base.consoleLog = console.error;
callback();
console.log = originalConsoleLog;
Base.consoleLog = originalConsoleLog;
}

declare const mocha: any;
Expand Down

0 comments on commit 4d1e022

Please sign in to comment.