-
-
Notifications
You must be signed in to change notification settings - Fork 485
Add Process object so as to allow process.env #4597
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
base: main
Are you sure you want to change the base?
Conversation
Test262 conformance changes
Fixed tests (1): |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4597 +/- ##
==========================================
+ Coverage 47.24% 56.49% +9.25%
==========================================
Files 476 547 +71
Lines 46892 60060 +13168
==========================================
+ Hits 22154 33933 +11779
- Misses 24738 26127 +1389 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hansl
left a comment
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.
2 non-blocking nits for now. If you want to merge without addressing that's fine we can do it in a follow up PR.
|
That makes sense. Regarding the new Regarding it being enabled by default, I think we should let it be enabled for now and if in case we strictly don't want it enabled as it's a node api, we'll do a follow up to make it not being enabled by default. |
|
I'd second having the Process extension not on by default. I think this is a super cool extension to have as an option, but since process is not based on a web standard, we should have it be an opt in extension and not opt out. |
|
Done! I've made it optional. |
99bb4b8 to
dd0471a
Compare
nekevss
left a comment
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! 😄
The feature flag approach looks good to me!
dd0471a to
b4a7f78
Compare
jedel1043
left a comment
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.
Thank you for the contribution! I have a couple of questions about the implementation
core/runtime/src/process/tests.rs
Outdated
| unsafe { | ||
| std::env::set_var("TEST_VAR", "test_value"); | ||
| std::env::set_var("ANOTHER_VAR", "another_value"); | ||
| } |
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.
Wouldn't this cause UB if Cargo decides to run this test and the test below it concurrently?
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.
Oh, shoot. That's true.
It may be worth using something like temp_env as a dev-dependency.
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.
Ah yes, my bad for overlooking it.
Also as per @nekevss's suggestion, I'll use temp_env as a dev dependency and fix 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.
Done!
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.
Unfortunately, I don't think this fixes the issue, according to this issue in the temp_env repo. I see two possible solutions:
- Require running tests with nextest, but it feels "weird" to depend on another test runner to not cause UB.
- Somehow run the test in a subprocess that sets up the environment variables before running it. This is the safest way of testing this but might be much more complex to set up.
Are you open for taking a shot at the second option? If not, then I would propose ignoring the tests for now and opening an issue for fixing this later.
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.
@jedel1043 I think there is a couple other solutions:
- have a global mutex lock. Rust describes that
set_varis only UB when multiple threads try to write at the same time. If threads are synchronized, there's no UB. - merge the two tests into the same test to avoid this case. I don't recommend this one because we might add more tests in runtime with
set_varlater on and would likely not think about updating this test suite.
This saves having to create a subprocess which is heavy.
Ref https://doc.rust-lang.org/stable/std/env/fn.set_var.html#safety
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.
Hmm a lot of options to discuss then.
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.
In that case, let's just merge after ignoring the new tests, and we can discuss the shape of our solution later
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 agree that the subprocess option would be safest but it'll be quite complex to implement for what we're trying to test here.
I think we can go for the mutex route later but I'm okay with ignoring the new tests for now and create a new issue for it where we can discuss it.
Thanks for the review!
5458f5e to
9729a91
Compare
347ee9b to
fb30184
Compare
This Pull Request fixes/closes #4492.
It changes the following:
Example code