Use the correct Babylon plugins for Test262 tests (#7916)

This commit is contained in:
Nicolò Ribaudo 2018-05-13 10:52:19 +02:00 committed by GitHub
parent ac5d2ba984
commit 0a8367c979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 1558 deletions

View File

@ -6,7 +6,6 @@ const utils = require("./run_babylon_test262_utils");
const testDir = path.join(__dirname, "../../../build/test262"); const testDir = path.join(__dirname, "../../../build/test262");
const whitelistFile = path.join(__dirname, "test262_whitelist.txt"); const whitelistFile = path.join(__dirname, "test262_whitelist.txt");
const plugins = ["asyncGenerators", "objectRestSpread", "optionalCatchBinding"];
const shouldUpdate = process.argv.indexOf("--update-whitelist") > -1; const shouldUpdate = process.argv.indexOf("--update-whitelist") > -1;
Promise.all([utils.getTests(testDir), utils.getWhitelist(whitelistFile)]) Promise.all([utils.getTests(testDir), utils.getWhitelist(whitelistFile)])
@ -21,7 +20,7 @@ Promise.all([utils.getTests(testDir), utils.getWhitelist(whitelistFile)])
console.log(`> ${Math.round(100 * idx / total)}% complete`); console.log(`> ${Math.round(100 * idx / total)}% complete`);
} }
return utils.runTest(test, plugins); return utils.runTest(test);
}); });
return utils.interpret(results, whitelist); return utils.interpret(results, whitelist);

View File

@ -12,6 +12,21 @@ const pfs = {
const parse = require("../../../packages/babylon").parse; const parse = require("../../../packages/babylon").parse;
const featuresToPlugins = {
BigInt: "bigInt",
"class-fields-public": "classProperties",
"class-fields-private": "classPrivateProperties",
"async-iteration": "asyncGenerators",
"object-rest": "objectRestSpread",
"object-spread": "objectRestSpread",
"optional-catch-binding": "optionalCatchBinding",
"numeric-separator-literal": "numericSeparator",
};
function getPlugins(features) {
return features && features.map(f => featuresToPlugins[f]).filter(Boolean);
}
exports.getTests = function(testDir) { exports.getTests = function(testDir) {
const stream = new TestStream(testDir, { omitRuntime: true }); const stream = new TestStream(testDir, { omitRuntime: true });
const tests = []; const tests = [];
@ -25,6 +40,7 @@ exports.getTests = function(testDir) {
fileName, fileName,
id: `${fileName}(${test.scenario})`, id: `${fileName}(${test.scenario})`,
sourceType: test.attrs.flags.module ? "module" : "script", sourceType: test.attrs.flags.module ? "module" : "script",
plugins: getPlugins(test.attrs.features),
expectedError: expectedError:
!!test.attrs.negative && !!test.attrs.negative &&
(test.attrs.negative.phase === "parse" || (test.attrs.negative.phase === "parse" ||
@ -38,9 +54,12 @@ exports.getTests = function(testDir) {
}); });
}; };
exports.runTest = function(test, plugins) { exports.runTest = function(test) {
try { try {
parse(test.contents, { sourceType: test.sourceType, plugins: plugins }); parse(test.contents, {
sourceType: test.sourceType,
plugins: test.plugins,
});
test.actualError = false; test.actualError = false;
} catch (err) { } catch (err) {
test.actualError = true; test.actualError = true;

File diff suppressed because it is too large Load Diff