This repository was archived by the owner on Jan 19, 2019. It is now read-only.
Chore: AST alignment testing against Babylon #342
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@soda0289 @Andy-MS
Now that the TypeScript PR has been merged into Babylon, and the effort to align on a TypeScript AST has become somewhat "official", I would like to propose that we begin formally testing AST alignment on our existing codebase.
As you know I had set up https://github.com/JamesHenry/tsep-babylon-test for this purpose, but it is already incredibly cumbersome to have to swich contexts and repos to try out ideas and make improvements.
This PR shows how testing for AST alignment could work.
I have added a new section to the
tests/
directory, with a dedicated spec runner (still usingjest
).To run the tests, for now, you just do:
I have not yet made them a required part of the primary testing for the repo, but we may trend towards that.
As you can see in the diff, I was able to get "some" tests to pass straight out of the gate:
This does not truly reflect the current state as I did not bother to comb through all the subdirectories to find working cases, because the vast majority still seem to be failing. In some cases this is down to genuine differences in TypeScript ASTs, but in many it is down to very tiny differences in LOC data.
E.g. If there is a newline at the end of the file, tsep and babylon seem to disagree on LOC end.
Another random thing I noticed - tsep is adding
start: Number
andend: Number
for JSX code, but we do not do that for standard code. I have set up the repo to strip thestart
andend
number values from babylon ASTs to account for the predominant behaviour, but it is weird that we have this inconsistency within tsep. I have created an issue for that here: #341Let me know if you guys have any feedback, I am feeling quite good about this setup and I think it will allow us to converge in the quickest and easiest possible way.