-
Notifications
You must be signed in to change notification settings - Fork 75
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
Updating Tests to latest Prettier tests #448
Conversation
Codecov Report
@@ Coverage Diff @@
## master #448 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 92 92
Lines 770 770
Branches 147 147
=========================================
Hits 770 770 Continue to review full report at Codecov.
|
@@ -1,13 +1,20 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
|
|||
exports[`EnumDefinitions.sol 1`] = ` | |||
exports[`EnumDefinitions.sol - {"bracketSpacing":true} format 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.
things like these are very nice when reviewing a snapshot with specific options
uint256 _e, | ||
int256 _f, | ||
bytes1 _g | ||
uint _a, |
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.
These changed because the order of the snapshots changed.
|
||
// TODO: these test files need fix | ||
const unstableTests = new Map( | ||
['Assembly/Assembly.sol'].map((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.
Until we fix this Issue we won't compare this file formatted twice.
happy to approve this if you can fix the conflicts @Janther thanks |
AFK right now but the conflict might only be with the lock file since the merge of the eslint update |
29acf09
to
44d0e74
Compare
thanks @Janther this is a 104 files long PR, anything specific you'd like us to take a look at? |
Every The files in the
Probably would suggest to only check these 2 files. Finally there are some changes in the Jest config mainly taken from Prettier’s repo. And a few changes in the
Finally you could have a look and play with the result. |
thanks for the recap @Janther this is great |
sorry @Janther I was finally able to take a look at this PR, added some comments thanks // cc @fvictorio |
@@ -152,8 +152,9 @@ If you want a different configuration for your javascript and solidity files, yo | |||
1. [Fork it](https://github.com/prettier-solidity/prettier-plugin-solidity/fork) | |||
2. Create your feature branch (`git checkout -b feature/fooBar`) | |||
3. Commit your changes (`git commit -am 'Add some fooBar'`) | |||
4. Push to the branch (`git push origin feature/fooBar`) | |||
5. Create a new Pull Request | |||
4. All existing test and coverage must pass (`npm run test:all`), if coverage drops below 100% add missing tests. |
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.
not really clear, can you elaborate more on this?
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.
Not sure what else can I write here. Perhaps I'm too close to the forest to see the trees. Maybe you can add something here?
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 is my bad sorry, the desc is perfect
"test": "jest", | ||
"test:all": "AST_COMPARE=true npm t -- --coverage" | ||
"test:all": "FULL_TEST=1 jest" |
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.
can we use true
instead of 1
? thanks
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 used 1
as it is what's used in Prettier's scripts. It can be anything though as the variable is a string and the code just checks for a truthy
value. It would also run full tests with FULL_TEST=false jest
. Only FULL_TEST= jest
will run normal tests as FULL_TEST
would be considered a falsy
value as it is an empty string, of course no FULL_TEST
at all will also be a falsy
value since in runtime will be undefined
. I'm just pointing out that using true
as a value could be misleading since Prettier's test doesn't really parse the flag as JSON and I wouldn't implement that step since I'd like to keep this code as close as possible to the original, that way we can follow Prettier's enhancements to the testing system easier.
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.
alright, I'm ok to keep 1 then thanks for the explanation
jest.config.js
Outdated
module.exports = { | ||
collectCoverage: true, | ||
collectCoverage: !!FULL_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.
related to my other comment below; not a huge fan of the !!
operator
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.
Solved
|
||
module.exports = { | ||
formatWithCursor(input, options) { | ||
const $$$options = { |
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.
$$$options
can you tell me more about it?
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 a name to be different from options
it came from the original file. That one instead of importing the code, it reads the files and treats it as a string to be evaluated by the vm
. I didn't have much time to go through this process so there's some room for improvement here.
@@ -0,0 +1,7 @@ | |||
const runSpec = require('./run_spec.js'); |
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.
interesting, it looks like from this file on GH is no longer formatting js? 🤷♂️
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.
Looks normal in my screen.
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.
thanks @Janther good job 🙏
there are a few benefits of updating our testing framework.
FULL_TEST
not only comparesAST
but also differentEOL
,BOM
, and compares the file formatted twice (as described in Prettier's documentation) which led to the discovery with Assembly Labels adding an extra line if there is an existing one.