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.
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
fix: parse env options from comments (fix #1962) #1984
fix: parse env options from comments (fix #1962) #1984
Changes from 8 commits
ffbb83f
a79bcae
35a0e08
aa4c86f
47d6b77
a5b3e25
6df9170
103f886
03babe7
1aa7461
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
What about this case?
These files should run in the same environment, because they have the same values.
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.
Personally I'm not sure that's beneficial enough to be worth the downsides. We would have to make the equality logic much more complex. Also from what I understand, the JSON and ECMAScript spec do not specify whether parsers need to be ordered, so we would need to hard code different logic for JavaScript runtimes and environments. Even if we only supported V8, we would have to either ban numerical keys (technically a breaking change since custom environments can have any keys), or introduce undefined runtime behavior (possibly a breaking change).
If you wanted to ensure better performance as a user, you could simply sort your keys with a linter. Worst case, we get an
O(n)
performance in exchange for respecting the ECMAScript spec, which I think is worth it.Would something break if we made the wrong assumption about option equality for grouping envs? If not, then this is just a performance issue and maybe that argument doesn't hold much weight. However, in that case I think adding too much time complexity for edge cases like this could make tests slower than if they had some extra env instances. Also JSON parsing is synchronous, but we already parallelize envs.
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 you overcomplicate things here, I'm sure we can create a string key that doesn't depend on key order. Sorting keys seems like an obvious solution.
I don't think you can store them with linter in our docblock?
Most things that expect single JSOM instance will break, because we don't clear ESM cache in
--no-threads
: Vue, for example, stores "document" globally on import, so next tests with different "options" will fail, because global "document" will be different. This is actually why we have grouping.I am sure this usecase will emerge, if people will use
@vitet-environment-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.
That sounds like a good place to start, but I still feel like that's a lot of time complexity. I'll try some benchmarks.