-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: industrialize tests with snapshots #97
Conversation
445e537
to
40ab75d
Compare
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 a lot!
@yacinehmito seems some tests are failing. |
I think it's because the source maps depend on something device-specific (probably the full path). I'll dig further. |
53fde10
to
baeca02
Compare
@dsherret Tests are fixed. |
I added functions to "fix" the source maps, so that they use relative paths instead of absolute paths. |
@dsherret Sorry for pinging you again. |
@yacinehmito the CI is still failing. I fixed the one newline issue. |
I didn't realize that there was a windows run. I am not surprised if it fails because of line endings given how I split the lines in the testing code. It's a bit hard to test on my end as I cannot trigger the CI. I'll push a fix early next week (I am off until then). |
I can try to fix it in a bit (maybe later tonight or tomorrow). Yeah, the CI doesn't run automatically because this is your first PR to this repo. I wish it would after the first time I approve it. |
tests/utils.ts
Outdated
|
||
const osType = typeof Deno?.build?.os === "string" ? Deno.build.os : "linux"; | ||
|
||
const EOL = osType === "windows" ? "\r\n" : "\n"; |
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 have added this bit and used it everywhere instead of \n
. @dsherret Does that make the tests pass now?
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 had fixed that issue by adding a .gitattributes
to this PR, which is preferable because then we don't need these kind of conditions. The tests were complaining about this:
,- "file:///D:/a/deno_emit/deno_emit/testdata/mod.ts": "cYfK3r_ND0Q_nXVQYOxJjg8VYMM.js"\n
,+ "file:///testdata/mod.ts": "0BJ1Cp_wwHSv6YnJzSlY2UlxpSc.js"\n
Previous run: https://github.com/denoland/deno_emit/actions/runs/4726314879/jobs/8385766439
Now the tests are failing with more newline stuff. Can you revert your last change (I have the old code locally in case you've lost it so just let me know if you want me to push it to this PR)? Also, please land commits on top of each other instead of overwritting commits because I don't know what has changed since the last time I reviewed. We'll squash all the commits when merging.
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 reverted the changes. I also found how to run the Actions on my own fork, so I can iterate on the Windows issue.
(FYI, the Windows build takes a lot of time. Compiling Rust dependencies takes more than 12 minutes, whereas it takes less than 5 minutes for Linux and less than 2 minutes for macOS.)
c150000
to
001113b
Compare
We're almost there. There's only one test failing, because of line endings. |
@dsherret It's finally green on my fork! 😄 |
There's no need to wait until the end of the process.
I removed the queue to update the snapshots so that I could forward the paths to the module outputs to the I did that because I am porting the tests from |
This PR adds the ability to test
bundle
andemit
with snapshots. Instead of writing assertions on the output, it will be automatically compared with files already stored.Why I did this
I would like to start fixing a few bugs (starting with #98), then contribute with my own improvements. Having snapshots makes me more confident that I will not cause a regression, and will let me see clearly the difference between the output of my revisions vs. the original output.
Why I did not use
assertSnapshot
from the standard libraryThere are already ways of doing snapshot testing from what
std
provides. However, with the existingassertSnapshot
, the snapshot files are big and hard to read. The functions ofdeno_emit
produce JavaScript code, so I preferred to store the snapshots as JavaScript files. With the absence of escape characters and the help of syntax highlighting, we can better appreciate the changes.Other changes
The existing tests have been converted to using snapshots. Tests of
bundle
and tests ofemit
have been separated in two different files.