-
Notifications
You must be signed in to change notification settings - Fork 893
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
Pass Process around explicitly #3871
Conversation
Here the only place that still calls |
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.
@djc Thanks for the work! Looks like 84e01b5 is a rather mechanical change (replacing process()
with process
)? If that is the case, I think we can first merge the 2 commits before it.
Having noticed the fact that effectively PROCESS
is only altered in with()
and with_runtime()
, both of which are used only in tests (except one single mention of with_runtime()
in rustup-init.rs
), my overall plan is that:
- refactor(test): execute all
#[rustup_macros::unit_test]
s within atokio
context #3868 temporarily removes in-process tests, now subscribers can be totally local. - chore(dist/features): ship
tracing
and friends by default #3803 sets a global subscriber based on the currentstatic PROCESS
in normal business logic, and for tests it sets a local subscriber usinglet _guard = tracing::subscriber::set_default(subscriber);
, wheresubscriber
is a function of the currentPROCESS
. Clearly, the only injection points of the local subscriber would be inside thewith*()
functions (a newPROCESS
will naturally require a newstderr
-oriented subscriber). Thelog
module now relies on the implicit subscriber in the current scope (global or local). - With this PR,
PROCESS
can be safely removed, since theinfo!()
calls and friends only implicitly rely on the subscriber. The subscriber's dependency on the newprocess
in this case can be specified elsewhere (globally, or locally usingwith()
). Nowwith()
's only job is to install the hook and then change the current subscriber when the closure runs. since there's noPROCESS
anymore and thus no more calls to.on_thread_start()
and stuff to alter it,with_runtime()
is no longer required. 1 An async version ofwith()
might still be desired though, but it won't have to depend on tokio runtime builder. - test(clitools): revive
run_inprocess()
#3891 revives in-process tests using justwith()
or its async counterpart.
What do you think?
Footnotes
-
I'm not sure about the parameters to be passed to the topmost tokio runtime builder yet. IIRC in
with_runtime()
2 workers are used, in#[test]
there's only one. ↩
Sounds like a good direction! I'm not completely clear on which order you want to merge things?
I've submitted them separately as #3872. Once that is merged, I can rebase this. |
@djc Just the top-down order from 1 to 4. It's a back-and-forth dance around #2367, but the latter is a small change and I believe we can afford reverting and then reviving it. PS: Just in case it's not clear:
It's a bit late now here so I'll probably continue my work tomorrow, by polishing (1.) (i.e. #3868) first. |
480fc43
to
8415d12
Compare
0202bd6
to
be69317
Compare
stderr: filesource::TestWriterInner, | ||
pub process: Process, | ||
#[allow(dead_code)] // guard is dropped at the end of the test | ||
guard: DefaultGuard, |
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.
Nit: I guess the linter actually wants you to write _guard
, see https://github.com/search?q=org%3Arust-lang%20_guard%3A&type=code for more examples across the org.
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 a lot for the patch! I've left some minor questions/suggestions, but great improvement overall :D
I think that's kind of what this is? Doesn't seem too radical to me.
I haven't quite finished the tests and the I'm not sure yet what to do about the logging macros, but this seems viable (and should enable ripping out a bunch of stuff like
with()
andwith_runtime()
etc).