Browse Source

Slightly improve doctest output

Warn user that no 3dsx will be built in this case, and use "human"
formatting so that we get colored rustc output (since we don't need to
parse the JSON output in this case anyway).
pull/32/head
Ian Chamberlain 2 years ago
parent
commit
3e7665fb63
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 30
      src/command.rs
  2. 2
      src/lib.rs

30
src/command.rs

@ -119,8 +119,8 @@ impl CargoCmd { @@ -119,8 +119,8 @@ impl CargoCmd {
/// `3dslink`.
pub fn should_link_to_device(&self) -> bool {
match self {
CargoCmd::Test(test) => !test.no_run,
CargoCmd::Run(_) => true,
Self::Test(test) => !test.no_run,
Self::Run(_) => true,
_ => false,
}
}
@ -128,12 +128,26 @@ impl CargoCmd { @@ -128,12 +128,26 @@ impl CargoCmd {
pub const DEFAULT_MESSAGE_FORMAT: &str = "json-render-diagnostics";
pub fn extract_message_format(&mut self) -> Result<Option<String>, String> {
Self::extract_message_format_from_args(match self {
CargoCmd::Build(args) => &mut args.args,
CargoCmd::Run(run) => &mut run.cargo_args.args,
CargoCmd::Test(test) => &mut test.run_args.cargo_args.args,
CargoCmd::Passthrough(args) => args,
})
let cargo_args = match self {
Self::Build(args) => &mut args.args,
Self::Run(run) => &mut run.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)?;
if format.is_some() {
return Ok(format);
}
if let Self::Test(Test { doc: true, .. }) = self {
// We don't care about JSON output for doctests since we're not
// building any 3dsx etc. Just use the default output as it's more
// readable compared to DEFAULT_MESSAGE_FORMAT
Ok(Some(String::from("human")))
} else {
Ok(None)
}
}
fn extract_message_format_from_args(

2
src/lib.rs

@ -97,6 +97,8 @@ pub fn make_cargo_build_command(cmd: &CargoCmd, message_format: &Option<String>) @@ -97,6 +97,8 @@ pub fn make_cargo_build_command(cmd: &CargoCmd, message_format: &Option<String>)
// user wants
if test.doc {
eprintln!("Documentation tests requested, no 3dsx will be built or run");
// https://github.com/rust-lang/cargo/issues/7040
command.args(["--doc", "-Z", "doctest-xcompile"]);

Loading…
Cancel
Save