Browse Source

Rebased changes

pull/36/head
Andrea Ciliberti 2 years ago
parent
commit
9b483a8589
  1. 31
      src/command.rs
  2. 10
      src/lib.rs

31
src/command.rs

@ -112,6 +112,11 @@ pub struct Test { @@ -112,6 +112,11 @@ pub struct Test {
#[arg(long)]
pub no_run: bool,
/// If set, documentation tests will be built instead of unit tests.
/// This implies `--no-run`.
#[arg(long)]
pub doc: bool,
// The test command uses a superset of the same arguments as Run.
#[command(flatten)]
pub run_args: Run,
@ -135,10 +140,23 @@ impl CargoCmd { @@ -135,10 +140,23 @@ impl CargoCmd {
CargoCmd::Build(build) => build.cargo_args.cargo_args(),
CargoCmd::Run(run) => run.build_args.cargo_args.cargo_args(),
CargoCmd::Test(test) => {
// We can't run 3DS executables on the host, so pass "--no-run" here and
// send the executable with 3dslink later, if the user wants
let mut cargo_args = test.run_args.build_args.cargo_args.cargo_args();
cargo_args.push("--no-run".to_string());
// We can't run 3DS executables on the host, so unconditionally pass
// --no-run here and send the executable with 3dslink later, if the
// user wants
if test.doc {
eprintln!("Documentation tests requested, no 3dsx will be built or run");
// https://github.com/rust-lang/cargo/issues/7040
cargo_args.append(&mut vec![
"--doc".to_string(),
"-Z".to_string(),
"doctest-xcompile".to_string(),
]);
} else {
cargo_args.push("--no-run".to_string());
}
cargo_args
}
@ -198,10 +216,11 @@ impl CargoCmd { @@ -198,10 +216,11 @@ impl CargoCmd {
pub fn extract_message_format(&mut self) -> Result<Option<String>, String> {
let cargo_args = match self {
Self::Build(args) => &mut args.args,
Self::Run(run) => &mut run.cargo_args.args,
Self::Build(build) => &mut build.cargo_args.args,
Self::Run(run) => &mut run.build_args.cargo_args.args,
Self::New(new) => &mut new.cargo_args.args,
Self::Test(test) => &mut test.run_args.build_args.cargo_args.args,
Self::Passthrough(args) => args,
Self::Test(test) => &mut test.run_args.cargo_args.args,
};
let format = Self::extract_message_format_from_args(cargo_args)?;

10
src/lib.rs

@ -84,6 +84,16 @@ pub fn make_cargo_command(cmd: &CargoCmd, message_format: &Option<String>) -> Co @@ -84,6 +84,16 @@ pub fn make_cargo_command(cmd: &CargoCmd, message_format: &Option<String>) -> Co
}
}
if matches!(cmd, CargoCmd::Test(_)) {
// Cargo doesn't like --no-run for doctests:
// https://github.com/rust-lang/rust/issues/87022
let rustdoc_flags = std::env::var("RUSTDOCFLAGS").unwrap_or_default()
// TODO: should we make this output directory depend on profile etc?
+ " --no-run --persist-doctests target/doctests";
command.env("RUSTDOCFLAGS", rustdoc_flags);
}
let cargo_args = cmd.cargo_args();
command

Loading…
Cancel
Save