mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
Changed wrong use of console.log in the codebase to console.error
Summary: Release note: Changed some erroneous console.log statements to console.error This addresses issue https://github.com/facebook/prepack/issues/1201. Went through all uses of console.log in the codebase and converted them to console.error if that's what they're supposed to be. Closes https://github.com/facebook/prepack/pull/1253 Reviewed By: hermanventer Differential Revision: D6550963 Pulled By: jhalley fbshipit-source-id: aec0f2f9a0e5745f563628b849fde110388b12cd
This commit is contained in:
parent
b935e80316
commit
8c7b508162
@ -37,14 +37,14 @@ exec("flow check --profile", function(error, stdout, stderr) {
|
||||
found_realm = found_realm || line.includes("/realm.js");
|
||||
}
|
||||
if (found_ecma && found_realm) {
|
||||
console.log("Invalid Dependencies: ecma262/ is in a circular dependency with realm.js");
|
||||
console.error("Invalid Dependencies: ecma262/ is in a circular dependency with realm.js");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("Biggest cycle: " + cycle_len);
|
||||
let MAX_CYCLE_LEN = 56; // NEVER EVER increase this value
|
||||
if (cycle_len > MAX_CYCLE_LEN) {
|
||||
console.log("Error: You increased cycle length from the previous high of " + MAX_CYCLE_LEN);
|
||||
console.log("This is never OK.");
|
||||
console.error("Error: You increased cycle length from the previous high of " + MAX_CYCLE_LEN);
|
||||
console.error("This is never OK.");
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
@ -56,7 +56,7 @@ madge("./lib/").then(res => {
|
||||
let deps = res.obj();
|
||||
let idx_deps = res.depends("intrinsics/index");
|
||||
if (idx_deps.length !== 1 || idx_deps[0] !== "construct_realm") {
|
||||
console.log("Invalid Dependency: Intrinsics index depends on " + idx_deps[0]);
|
||||
console.error("Invalid Dependency: Intrinsics index depends on " + idx_deps[0]);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ madge("./lib/").then(res => {
|
||||
.depends(dep)
|
||||
.filter(depend => depend !== "intrinsics/index" && !depend.startsWith("intrinsics/ecma262"));
|
||||
if (ext_deps.length > 0) {
|
||||
console.log("Invalid Dependency: " + dep + " depends on " + ext_deps);
|
||||
console.error("Invalid Dependency: " + dep + " depends on " + ext_deps);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -77,16 +77,16 @@ function runTest(name: string, code: string): boolean {
|
||||
if (additionalFunctions) (options: any).additionalFunctions = ["global.additional1", "global['additional2']"];
|
||||
prepackFileSync([name], options);
|
||||
if (!recover) {
|
||||
console.log(chalk.red("Serialization succeeded though it should have failed"));
|
||||
console.error(chalk.red("Serialization succeeded though it should have failed"));
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
if (!(e instanceof FatalError)) {
|
||||
console.log(chalk.red(`Unexpected error: ${e.message}`));
|
||||
console.error(chalk.red(`Unexpected error: ${e.message}`));
|
||||
}
|
||||
}
|
||||
if (errors.length !== expectedErrors.length) {
|
||||
console.log(chalk.red(`Expected ${expectedErrors.length} errors, but found ${errors.length}`));
|
||||
console.error(chalk.red(`Expected ${expectedErrors.length} errors, but found ${errors.length}`));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ function runTest(name: string, code: string): boolean {
|
||||
expected = JSON.stringify(expected);
|
||||
}
|
||||
if (expected !== actual) {
|
||||
console.log(chalk.red(`Error ${i + 1}: Expected ${expected} errors, but found ${actual}`));
|
||||
console.error(chalk.red(`Error ${i + 1}: Expected ${expected} errors, but found ${actual}`));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -89,25 +89,25 @@ function runTest(name: string, code: string): boolean {
|
||||
if (name.endsWith("/bundle.js~")) (options: any).additionalFunctions = ["global.WildeBundle.prepareReact"];
|
||||
let serialized = prepackSources(sources, options);
|
||||
let new_map = serialized.map; // force source maps to get computed
|
||||
if (!new_map) console.log(chalk.red("No source map"));
|
||||
if (!new_map) console.error(chalk.red("No source map"));
|
||||
if (!serialized) {
|
||||
console.log(chalk.red("Error during serialization"));
|
||||
console.error(chalk.red("Error during serialization"));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
if (!(e instanceof FatalError)) console.log(e);
|
||||
if (!(e instanceof FatalError)) console.error(e);
|
||||
return false;
|
||||
} finally {
|
||||
for (let [loc, error] of errors) {
|
||||
console.log(
|
||||
console.error(
|
||||
`${error.severity}: ${loc.source || ""} ${loc.start.line}:${loc.start.column +
|
||||
1} ${error.errorCode} ${error.message}`
|
||||
);
|
||||
}
|
||||
for (let error of errorList) {
|
||||
console.log(`${error.severity}: ${error.errorCode} ${error.message}`);
|
||||
console.error(`${error.severity}: ${error.errorCode} ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ function runSource(source) {
|
||||
// $FlowFixMe flow doesn't new Function
|
||||
fn(requireShim, moduleShim);
|
||||
} catch (e) {
|
||||
console.log(codeAfterBabel);
|
||||
console.error(codeAfterBabel);
|
||||
throw e;
|
||||
}
|
||||
return moduleShim.exports;
|
||||
|
@ -91,7 +91,7 @@ function runTest(name, code) {
|
||||
if (result instanceof ThrowCompletion) throw result.value;
|
||||
} catch (err) {
|
||||
if (err instanceof FatalError) return true;
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
@ -124,7 +124,7 @@ return __result; }).call(this);`);
|
||||
for (let { positive, value, start } of markersToFind) {
|
||||
let found = newCode.indexOf(value, start) !== -1;
|
||||
if (found !== positive) {
|
||||
console.log(chalk.red(`Output ${positive ? "does not contain" : "contains"} forbidden string: ${value}`));
|
||||
console.error(chalk.red(`Output ${positive ? "does not contain" : "contains"} forbidden string: ${value}`));
|
||||
markersIssue = true;
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ return __result; }).call(this);`);
|
||||
actual = exec(`(function () { ${newCode}; // keep newline here as code may end with comment
|
||||
return __result; }).call(this);`);
|
||||
if (expected !== actual) {
|
||||
console.log(chalk.red("Output mismatch!"));
|
||||
console.error(chalk.red("Output mismatch!"));
|
||||
break;
|
||||
}
|
||||
if (oldCode === newCode) {
|
||||
@ -142,10 +142,10 @@ return __result; }).call(this);`);
|
||||
oldCode = newCode;
|
||||
}
|
||||
if (i === max) {
|
||||
console.log(chalk.red(`Code generation did not reach fixed point after ${max} iterations!`));
|
||||
console.error(chalk.red(`Code generation did not reach fixed point after ${max} iterations!`));
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
console.log(chalk.underline("original code"));
|
||||
console.log(code);
|
||||
|
@ -247,7 +247,7 @@ function verifyFunctionOrderings(code: string): boolean {
|
||||
for (let i = 1; i < orders.length; ++i) {
|
||||
invariant(orders[i] !== orders[i - 1]);
|
||||
if (orders[i] < orders[i - 1]) {
|
||||
console.log(chalk.red(`Funtion ordering is not preserved: function ${orders[i - 1]} is before ${orders[i]}`));
|
||||
console.error(chalk.red(`Funtion ordering is not preserved: function ${orders[i - 1]} is before ${orders[i]}`));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -300,14 +300,14 @@ function runTest(name, code, options, args) {
|
||||
let sources = [{ filePath: name, fileContents: code }];
|
||||
let serialized = serializer.init(sources, false);
|
||||
if (!serialized) {
|
||||
console.log(chalk.red("Error during serialization"));
|
||||
console.error(chalk.red("Error during serialization"));
|
||||
} else {
|
||||
console.log(chalk.red("Test should have caused introspection error!"));
|
||||
console.error(chalk.red("Test should have caused introspection error!"));
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof FatalError) return true;
|
||||
console.log("Test should have caused introspection error, but instead caused a different internal error!");
|
||||
console.log(err);
|
||||
console.error("Test should have caused introspection error, but instead caused a different internal error!");
|
||||
console.error(err);
|
||||
}
|
||||
return false;
|
||||
} else if (code.includes("// cannot serialize")) {
|
||||
@ -318,25 +318,25 @@ function runTest(name, code, options, args) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
console.log(chalk.red("Test should have caused error during serialization!"));
|
||||
console.error(chalk.red("Test should have caused error during serialization!"));
|
||||
return false;
|
||||
} else if (code.includes("// no effect")) {
|
||||
try {
|
||||
let serialized = prepackSources([{ filePath: name, fileContents: code, sourceMapContents: "" }], options);
|
||||
if (!serialized) {
|
||||
console.log(chalk.red("Error during serialization!"));
|
||||
console.error(chalk.red("Error during serialization!"));
|
||||
return false;
|
||||
}
|
||||
if (!serialized.code.trim()) {
|
||||
return true;
|
||||
}
|
||||
console.log(chalk.red("Generated code should be empty but isn't!"));
|
||||
console.log(chalk.underline("original code"));
|
||||
console.log(code);
|
||||
console.log(chalk.underline(`generated code`));
|
||||
console.log(serialized.code);
|
||||
console.error(chalk.red("Generated code should be empty but isn't!"));
|
||||
console.error(chalk.underline("original code"));
|
||||
console.error(code);
|
||||
console.error(chalk.underline(`generated code`));
|
||||
console.error(serialized.code);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
return false;
|
||||
} else if (code.includes("// Copies of ")) {
|
||||
@ -348,19 +348,19 @@ function runTest(name, code, options, args) {
|
||||
try {
|
||||
let serialized = prepackSources([{ filePath: name, fileContents: code, sourceMapContents: "" }], options);
|
||||
if (!serialized) {
|
||||
console.log(chalk.red("Error during serialization!"));
|
||||
console.error(chalk.red("Error during serialization!"));
|
||||
return false;
|
||||
}
|
||||
let regex = new RegExp(value, "gi");
|
||||
let matches = serialized.code.match(regex);
|
||||
if (!matches || matches.length !== count) {
|
||||
console.log(
|
||||
console.error(
|
||||
chalk.red(`Wrong number of occurrances of ${value} got ${matches ? matches.length : 0} instead of ${count}`)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -408,7 +408,7 @@ function runTest(name, code, options, args) {
|
||||
let serialized = prepackSources([{ filePath: name, fileContents: code, sourceMapContents: "" }], options);
|
||||
if (serialized.statistics && serialized.statistics.delayedValues > 0) anyDelayedValues = true;
|
||||
if (!serialized) {
|
||||
console.log(chalk.red("Error during serialization!"));
|
||||
console.error(chalk.red("Error during serialization!"));
|
||||
break;
|
||||
}
|
||||
let newCode = serialized.code;
|
||||
@ -419,7 +419,7 @@ function runTest(name, code, options, args) {
|
||||
for (let { positive, value, start } of markersToFind) {
|
||||
let found = newCode.indexOf(value, start) !== -1;
|
||||
if (found !== positive) {
|
||||
console.log(chalk.red(`Output ${positive ? "does not contain" : "contains"} forbidden string: ${value}`));
|
||||
console.error(chalk.red(`Output ${positive ? "does not contain" : "contains"} forbidden string: ${value}`));
|
||||
markersIssue = true;
|
||||
}
|
||||
}
|
||||
@ -444,7 +444,7 @@ function runTest(name, code, options, args) {
|
||||
actual = "" + e;
|
||||
}
|
||||
if (expected !== actual) {
|
||||
console.log(chalk.red("Output mismatch!"));
|
||||
console.error(chalk.red("Output mismatch!"));
|
||||
break;
|
||||
}
|
||||
if (!verifyFunctionOrderings(codeToRun)) {
|
||||
@ -454,7 +454,7 @@ function runTest(name, code, options, args) {
|
||||
if (i === 0 && functionCloneCountMatch) {
|
||||
let functionCount = parseInt(functionCloneCountMatch[1], 10);
|
||||
if (serialized.statistics && functionCount !== serialized.statistics.functionClones) {
|
||||
console.log(
|
||||
console.error(
|
||||
chalk.red(
|
||||
`Code generation serialized an unexpected number of clone functions. Expected: ${functionCount}, Got: ${serialized
|
||||
.statistics.functionClones}`
|
||||
@ -480,10 +480,10 @@ function runTest(name, code, options, args) {
|
||||
// TODO #835: Make delayed initializations logic more sophisticated in order to still reach a fixed point.
|
||||
return true;
|
||||
}
|
||||
console.log(chalk.red(`Code generation did not reach fixed point after ${max} iterations!`));
|
||||
console.error(chalk.red(`Code generation did not reach fixed point after ${max} iterations!`));
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
console.log(chalk.underline("original code"));
|
||||
console.log(code);
|
||||
@ -599,9 +599,9 @@ function main(): number {
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof ArgsParseError) {
|
||||
console.log("Illegal argument: %s.\n%s", e.message, usage());
|
||||
console.error("Illegal argument: %s.\n%s", e.message, usage());
|
||||
} else {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -307,9 +307,9 @@ function main(): number {
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof ArgsParseError) {
|
||||
console.log("Illegal argument: %s.\n%s", e.message, usage());
|
||||
console.error("Illegal argument: %s.\n%s", e.message, usage());
|
||||
} else {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
@ -429,7 +429,7 @@ function masterRunSingleProcess(
|
||||
handleTest(t, harnesses, args.timeout, (err, results) => {
|
||||
if (err) {
|
||||
if (args.verbose) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
} else {
|
||||
let ok = handleTestResults(groups, t, results);
|
||||
@ -493,8 +493,8 @@ function masterRunMultiProcess(
|
||||
let errMsg = ErrorMessage.fromObject(message);
|
||||
// just skip the error, thus skipping that test
|
||||
if (args.verbose) {
|
||||
console.log(`An error occurred in worker #${worker.process.pid}:`);
|
||||
console.log(errMsg.err);
|
||||
console.error(`An error occurred in worker #${worker.process.pid}:`);
|
||||
console.error(errMsg.err);
|
||||
}
|
||||
giveTask(worker);
|
||||
break;
|
||||
@ -594,7 +594,7 @@ function handleFinished(args: MasterProgramArgs, groups: GroupsMap, earlierNumSk
|
||||
if (args.verbose) {
|
||||
console.log(msg);
|
||||
if (errmsg) {
|
||||
console.log(errmsg);
|
||||
console.error(errmsg);
|
||||
}
|
||||
}
|
||||
if (group_es5_failed + group_es6_failed > 0) {
|
||||
@ -637,7 +637,7 @@ function handleFinished(args: MasterProgramArgs, groups: GroupsMap, earlierNumSk
|
||||
|
||||
// exit status
|
||||
if (!args.filterString && (numPassedES5 < 11738 || numPassedES6 < 3981 || numTimeouts > 0)) {
|
||||
console.log(chalk.red("Overall failure. Expected more tests to pass!"));
|
||||
console.error(chalk.red("Overall failure. Expected more tests to pass!"));
|
||||
return 1;
|
||||
} else {
|
||||
// use 0 to avoid the npm error messages
|
||||
|
@ -322,10 +322,10 @@ export class UISession {
|
||||
this._invalidCount++;
|
||||
//prevent stack overflow from recursion
|
||||
if (this._invalidCount >= 10) {
|
||||
console.log("Too many invalid commands, shutting down...");
|
||||
console.error("Too many invalid commands, shutting down...");
|
||||
this.shutdown();
|
||||
}
|
||||
console.log("Invalid command: " + input);
|
||||
console.error("Invalid command: " + input);
|
||||
this._reader.question("(dbg) ", (line: string) => {
|
||||
this._dispatch(line);
|
||||
});
|
||||
|
@ -251,7 +251,7 @@ function run(
|
||||
process.exit(1);
|
||||
}
|
||||
if (errors.size > 0) {
|
||||
console.log("Errors found while prepacking");
|
||||
console.error("Errors found while prepacking");
|
||||
let foundFatal = false;
|
||||
for (let [loc, error] of errors) {
|
||||
foundFatal = foundFatal || error.severity === "FatalError";
|
||||
|
@ -65,7 +65,7 @@ repl.start({
|
||||
callback(null, res);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
callback(err);
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user