mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
There's no option to output the results of the test262 harness in silent mode so
every pass and failure outputs multiple lines to stdout. Since there are many
thousands of tests this results in unusable log files that are over 200k lines
long. This PR redirects stdout to a tmp file and then we reformat the result
into a small JSON object, grouped by the failure message with count.
Example:
```json [ { "pass": false, "data": { "message": "Expected no
error, got Error: TODO: Support complex object assignment", "count": 66
} }, { "pass": false, "data": { "message": "Expected no
error, got Error: TODO: lowerExpression(FunctionExpression)", "count": 4
} }, { "pass": false, "data": { "message": "Expected no
error, got Error: TODO: lowerExpression(UnaryExpression)", "count": 6
} }, { "pass": false, "data": { "message": "Expected no error,
got Error: todo: lower initializer in ForStatement", "count": 28 }
}, { "pass": false, "data": { "message": "Expected no error, got
Invariant Violation: Expected value for identifier `15` to be initialized.",
"count": 14 } }, { "pass": false, "data": { "message":
"Expected no error, got Invariant Violation: `var` declarations are not
supported, use let or const", "count": 76 } }, { "pass": true,
"data": { "message": null, "count": 1 } } ] ```
63 lines
2.0 KiB
JavaScript
63 lines
2.0 KiB
JavaScript
const { argv } = require("node:process");
|
|
const generate = require("@babel/generator").default;
|
|
const parser = require("@babel/parser");
|
|
const traverse = require("@babel/traverse").default;
|
|
const { Environment } = require("../dist/HIR/HIRBuilder");
|
|
const { lower } = require("../dist/HIR/BuildHIR");
|
|
const codegen = require("../dist/HIR/Codegen").default;
|
|
const enterSSA = require("../dist/HIR/EnterSSA").default;
|
|
const { eliminateRedundantPhi } = require("../dist/HIR/EliminateRedundantPhi");
|
|
const inferReferenceEffects =
|
|
require("../dist/HIR/InferReferenceEffects").default;
|
|
const { inferMutableRanges } = require("../dist/HIR/InferMutableLifetimes");
|
|
const leaveSSA = require("../dist/HIR/LeaveSSA").default;
|
|
const prettier = require("prettier");
|
|
|
|
// Preprocessor that runs Forget on the test262 test prior to execution. Compilation errors short
|
|
// circuit test execution and report an error immediately.
|
|
module.exports = (test) => {
|
|
try {
|
|
let codegenText = null;
|
|
// todo: replace with a better entrypoint
|
|
const sourceAst = parser.parse(test.contents, {
|
|
sourceFilename: test.file,
|
|
plugins: ["jsx"],
|
|
});
|
|
traverse(sourceAst, {
|
|
FunctionDeclaration: {
|
|
enter(nodePath) {
|
|
const env = new Environment();
|
|
const ir = lower(nodePath, env);
|
|
enterSSA(ir, env);
|
|
eliminateRedundantPhi(ir);
|
|
inferReferenceEffects(ir);
|
|
inferMutableRanges(ir);
|
|
leaveSSA(ir);
|
|
const ast = codegen(ir);
|
|
codegenText = prettier.format(
|
|
generate(ast).code.replace("\n\n", "\n"),
|
|
{
|
|
semi: true,
|
|
parser: "babel-ts",
|
|
}
|
|
);
|
|
},
|
|
},
|
|
});
|
|
if (codegenText != null) {
|
|
test.contents = codegenText;
|
|
} else {
|
|
throw new Error("Codegen returned an empty string");
|
|
}
|
|
} catch (error) {
|
|
error.message = error.message.replace(/ \(\d+:\d+\)/, "");
|
|
test.result = {
|
|
stderr: `${error.name}: ${error.message}\n`,
|
|
stdout: "",
|
|
error,
|
|
};
|
|
}
|
|
|
|
return test;
|
|
};
|