@@ -160,30 +160,7 @@ impl CargoCmd {
160160 match self {
161161 CargoCmd :: Build ( build) => build. passthrough . cargo_args ( ) ,
162162 CargoCmd :: Run ( run) => run. build_args . passthrough . cargo_args ( ) ,
163- CargoCmd :: Test ( test) => {
164- let mut cargo_args = test. run_args . build_args . passthrough . cargo_args ( ) ;
165-
166- // We can't run 3DS executables on the host, but we want to respect
167- // the user's "runner" configuration if set.
168- //
169- // If doctests were requested, `--no-run` will be rejected on the
170- // command line and must be set with RUSTDOCFLAGS instead:
171- // https://github.com/rust-lang/rust/issues/87022
172- if !test. run_args . use_custom_runner ( ) && !test. doc {
173- cargo_args. push ( "--no-run" . to_string ( ) ) ;
174- }
175-
176- if test. doc {
177- cargo_args. extend ( [
178- "--doc" . into ( ) ,
179- // https://github.com/rust-lang/cargo/issues/7040
180- "-Z" . into ( ) ,
181- "doctest-xcompile" . into ( ) ,
182- ] ) ;
183- }
184-
185- cargo_args
186- }
163+ CargoCmd :: Test ( test) => test. cargo_args ( ) ,
187164 CargoCmd :: New ( new) => {
188165 // We push the original path in the new command (we captured it in [`New`] to learn about the context)
189166 let mut cargo_args = new. cargo_args . cargo_args ( ) ;
@@ -493,6 +470,46 @@ impl Test {
493470 self . run_args . callback ( config) ;
494471 }
495472 }
473+
474+ fn should_run ( & self ) -> bool {
475+ self . run_args . use_custom_runner ( ) && !self . no_run
476+ }
477+
478+ /// The args to pass to the underlying `cargo test` command.
479+ fn cargo_args ( & self ) -> Vec < String > {
480+ let mut cargo_args = self . run_args . build_args . passthrough . cargo_args ( ) ;
481+
482+ // We can't run 3DS executables on the host, but we want to respect
483+ // the user's "runner" configuration if set.
484+ //
485+ // If doctests were requested, `--no-run` will be rejected on the
486+ // command line and must be set with RUSTDOCFLAGS instead:
487+ // https://github.com/rust-lang/rust/issues/87022
488+
489+ if self . doc {
490+ cargo_args. extend ( [
491+ "--doc" . into ( ) ,
492+ // https://github.com/rust-lang/cargo/issues/7040
493+ "-Z" . into ( ) ,
494+ "doctest-xcompile" . into ( ) ,
495+ ] ) ;
496+ } else if !self . should_run ( ) {
497+ cargo_args. push ( "--no-run" . into ( ) ) ;
498+ }
499+
500+ cargo_args
501+ }
502+
503+ /// Flags to pass to rustdoc via RUSTDOCFLAGS
504+ pub ( crate ) fn rustdocflags ( & self ) -> & ' static str {
505+ if self . should_run ( ) {
506+ ""
507+ } else {
508+ // We don't support running doctests by default, but cargo doesn't like
509+ // --no-run for doctests, so we have to plumb it in via RUSTDOCFLAGS
510+ " --no-run"
511+ }
512+ }
496513}
497514
498515const TOML_CHANGES : & str = r#"ctru-rs = { git = "https://github.com/rust3ds/ctru-rs" }
0 commit comments