Skip to content

Conversation

@saschanaz
Copy link
Member

@saschanaz saschanaz commented Jan 26, 2018

I tried fixing #93 and got a BIG AST parser result changes, so I created a tool to automate change acquisitions.

Much shorter test scripts as a bonus!

Also I fixed an issue that typedef-union test was being ignored because of its file extension.

@saschanaz saschanaz changed the title Auto acquisition for AST changes Auto acquisition for parser result changes Jan 26, 2018
test/invalid.js Outdated
expect(error.message).toEqual(err.message);
expect(error.line).toEqual(err.line);
}
for (const test of collect("invalid", true)) {
Copy link
Member

@marcoscaceres marcoscaceres Jan 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you add a comment saying what the boolean trap is there? like:

collect("invalid", /*whatThisIs=*/ true)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, let's fix this at the source.

Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits... only really ask that you avoid the boolean trap, but a few other suggestions to consider.

test/invalid.js Outdated
expect(error.message).toEqual(err.message);
expect(error.line).toEqual(err.line);
}
for (const test of collect("invalid", true)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, let's fix this at the source.

* @param {string} base
* @param {boolean} [expectError]
*/
function* collect(base, expectError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make expectError not be a boolean. Maybe make it an object, so to avoid the boolean trap?

* @param {string} path
* @param {Error} [error]
*/
function createItem(ast, path, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a class TestItem maybe? Might make this a little cleaner.

ast,
path,
error,
jsonPath() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe get jsonPath()? then just item.jsonPath;

jsonPath() {
return pth.join(pth.dirname(this.path), "../json", pth.basename(this.path).replace(".widl", ".json"));
},
diff() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I guess if we are only using this with testing it doesn't matter too much about using readFileSync... or could we spin up the tests to run in parallel?

@saschanaz
Copy link
Member Author

saschanaz commented Jan 29, 2018

Great reviews! I applied your feedbacks, although I'm not sure I understand this comment:

Nit: I guess if we are only using this with testing it doesn't matter too much about using readFileSync... or could we spin up the tests to run in parallel?

The readFileSync part is now moved to readJSON(), but should we use async fs.readFile? Things will be easy enough if we only use Node 8+ as it supports async functions.

@marcoscaceres
Copy link
Member

The readFileSync part is now moved to readJSON(), but should we use async fs.readFile? Things will be easy enough if we use Node 8+ as it supports async functions.

I think even Node 6 supported promises, but obviously not await (so, not as pretty)... having said that, let's leave it reading the files synchronously. The tests run pretty quick already :)

@saschanaz saschanaz merged commit 1e29dcb into develop Jan 29, 2018
@saschanaz saschanaz deleted the acquire branch January 29, 2018 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants