-
-
Notifications
You must be signed in to change notification settings - Fork 258
Conversation
Introduce a GNU Make target for retrieving TC-39's Test262 suite and validating parsing of the files it contains. Interpret each file as a parser test in accordance with that project's `INTERPRETING.md` document. Allow for the specification of allowed failures via a "whitelist" file so that the test suite may help prevent regressions in this project in situations where this project has known bugs. Initialize the "whitelist" file with a listing of all tests that are currently failing. Extend the continuous integration environment's configuration to automatically run these tests.
Travis reported this error:
Is it intended? |
scripts/run_test262.js
Outdated
}) | ||
.catch(function(err) { | ||
console.error(err); | ||
process.statusCode = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be process.exitCode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This is critical--thank you for spotting it.
scripts/test262_whitelist.txt
Outdated
@@ -0,0 +1,7972 @@ | |||
# This file lists tests that are known to produce incorrect results when parsed | |||
# with Babyline: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Babylon
I see there are a lot of failing tests which babylon actually supports via plugins, for example |
I'd be open to try that, but at some point, I think we should consider |
Alternatively, we could unconditionally enable all plugins for all tests. This is certainly less precision, but since Test262 generally doesn't include any "future hostile" tests, it may be an acceptable compromise. |
We just did something like this for our printer tests (generator) babel/babel#6018 with explicit flags. We could do unconditional for all tests though for now, if someone runs the stage 0 preset, it would be the same thing and none of the plugins should be incompatible. |
scripts/run_test262_utils.js
Outdated
const sourceType = test.isModule ? "module" : "script"; | ||
|
||
try { | ||
parse(test.content, { sourceType: sourceType }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to add the ones in https://github.com/babel/babylon#plugins (excluding flow/jsx/typescript/estree)
is there already a script/way to remove the whitelist tests automatically if things are fixed later? |
scripts/run_test262.js
Outdated
const whitelistFile = path.join(__dirname, "test262_whitelist.txt"); | ||
|
||
Promise.all([utils.getTests(testDir), utils.getWhitelist(whitelistFile)]) | ||
.then(function([tests, whitelist]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks in Node 4 (do we care?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to only run on latest for these?
scripts/run_test262.js
Outdated
const badnews = []; | ||
const badnewsDetails = []; | ||
|
||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines starting with a [
are pretty scary, regardless of semicolons.
Maybe save this into a const
, or make it the right side of a for of
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, I'd prefer to keep a functional style. But I see your point. I've made this the right-hand side of a void
expression--that will guard against ASI-related bugs, and it should also more clearly indicate to the reader that this literal value is not used beyond this statement.
badnews.push(desc); | ||
badnewsDetails.push(desc + ":"); | ||
badnewsDetails.push( | ||
...tests.map(function(test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also breaks in Node 4 😄
scripts/run_test262_utils.js
Outdated
|
||
function readDir(dirName) { | ||
return new Promise(function(resolve, reject) { | ||
fs.readdir(dirName, function(err, contents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any objections to adding a devDependency on util.promisify
?
It's available natively in Node >= 8, the package just shims it if it's missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't object, but I believe this question was @hzoo, so I'm going to hold off unless he agrees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to run on anything other than latest node (8)? We can add it too if we really want to but I think it's fine to run one one version of node like we do for coverage and lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me!
scripts/run_test262_utils.js
Outdated
test.actualError = true; | ||
} | ||
|
||
test.result = test.expectedError ^ test.actualError ? "fail" : "pass"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use !==
.
return line.replace(/#.*$/, "").trim(); | ||
}) | ||
.filter(function(line) { | ||
return line.length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter(Boolean)
would work too but I guess this is clearer
There was not, but that's a good idea. Maintaining the white list in JSHint has So I think that's everything--this should be ready for another round of review. |
I've updated the job to run in the latest release of Node.js, and I've taken @Kovensky's advice regarding the "util.promisify" module. My thinking is that many contributors likely prefer to develop in the LTS release. Even though they may not all care to run this particular test suite, the module's dependency tree is light enough to be justify the convenience. The |
Like it would basically run the whitelist tests and if they pass correctly instead of erroring/not erroring it could tell you to remove them (or it is done automatically), similar to updating a snapshot/fixture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks for this work! Will help us a lot for regressions in the future! And hopefully get us started on the path for test262 in the transforms as well actually; ideally we can further more make compat-table 2.0 with test262
oops I just merged babel/babel#6056, which means we need to update yarn at least? either way unrelated to your pr |
Whoops; before you updated the comment, I thought you were saying I should update the yarn lock file. I guess wasn't necessary, after all (I'm not familiar with that tool). Should I revert this latest commit? |
I updated Babel to use a new feature in yarn; I think we have to add https://github.com/babel/babel/pull/6056/files#diff-354f30a63fb0907d4ad57269548329e3L15 since the yarn version it's using now is older. Not sure it's going to fix but it's an issue due to us targeting master. Either way it would of broke in someone else's PR |
Yeah we don't need that commit, I can try this locally and push a change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. It's crazy how much tests are not working with babylon.
I just tested this also locally and it doesn't work and stops with |
We could use graceful-fs, which handles EMFILE errors automatically. |
Yeah graceful-fs sounds good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome @jugglinmike!
Note, I bumped our yarn version to support workspaces and switched to graceful-fs.
After this lands, we can drop the rest-parameter
test262 test fixtures I added a while back
Thanks for starting this @jugglinmike! |
|
||
bootstrap-test262: clean | ||
mkdir ./build | ||
git clone https://github.com/tc39/test262.git ./build/test262 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we do a depth=x here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
It's been my pleasure :) |
Introduce a GNU Make target for retrieving TC-39's Test262 suite and
validating parsing of the files it contains. Interpret each file as a
parser test in accordance with that project's
INTERPRETING.md
document. Allow for the specification of allowed failures via a
"whitelist" file so that the test suite may help prevent regressions in
this project in situations where this project has known bugs. Initialize
the "whitelist" file with a listing of all tests that are currently
failing. Extend the continuous integration environment's configuration
to automatically run these tests.
Hey @hzoo!
Here's my first attempt at integrating Test262. There's a lot of new code here,
so I'm prepared to make a log of changes according to review feedback.
One thing I would prefer to do is split the
run_test262_utils.js
file intomultiple files, possibly within a dedicated directory. There's not much
precedent for that within the
scripts
directory, so I thought I'd hold off onthat until I heard back from you.
I'd also like to point out that the code within the
scripts
directory is notcurrently being linted by the npm "lint" command. I manually satisfied the
linter anyway, with one exception: trailing commas. (I'm developing in Node.js
current LTS release where trailing commas are not supported.) Is there anything
you would like to change about this?