mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-02-17 13:58:38 +01:00
xtask: forward globals through the chain and add stderr-inheritance flag
This commit is contained in:
parent
fa92d8abe7
commit
18522122f1
4 changed files with 103 additions and 39 deletions
|
@ -130,10 +130,8 @@ pub enum BuildOrCheck {
|
||||||
Build,
|
Build,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser, Clone)]
|
||||||
#[command(author, version, about, long_about = None)]
|
pub struct Globals {
|
||||||
/// RTIC xtask powered testing toolbox
|
|
||||||
pub struct Cli {
|
|
||||||
/// For which backend to build (defaults to thumbv7)
|
/// For which backend to build (defaults to thumbv7)
|
||||||
#[arg(value_enum, short, long)]
|
#[arg(value_enum, short, long)]
|
||||||
pub backend: Option<Backends>,
|
pub backend: Option<Backends>,
|
||||||
|
@ -160,12 +158,28 @@ pub struct Cli {
|
||||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
pub verbose: u8,
|
pub verbose: u8,
|
||||||
|
|
||||||
|
/// Enable `stderr` inheritance on child processes.
|
||||||
|
///
|
||||||
|
/// If this flag is enabled, the output of `stderr` produced by child
|
||||||
|
/// processes is printed directly to `stderr`. This will cause a lot of
|
||||||
|
/// clutter, but can make debugging long-running processes a lot easier.
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub stderr_inherited: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[command(author, version, about, long_about = None)]
|
||||||
|
/// RTIC xtask powered testing toolbox
|
||||||
|
pub struct Cli {
|
||||||
|
#[clap(flatten)]
|
||||||
|
pub globals: Globals,
|
||||||
|
|
||||||
/// Subcommand selecting operation
|
/// Subcommand selecting operation
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub command: Commands,
|
pub command: Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
pub enum Commands {
|
pub enum Commands {
|
||||||
/// Check formatting
|
/// Check formatting
|
||||||
FormatCheck(PackageOpt),
|
FormatCheck(PackageOpt),
|
||||||
|
@ -227,7 +241,7 @@ pub enum Commands {
|
||||||
Book(Arg),
|
Book(Arg),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug, Clone)]
|
||||||
/// Restrict to package, or run on whole workspace
|
/// Restrict to package, or run on whole workspace
|
||||||
pub struct PackageOpt {
|
pub struct PackageOpt {
|
||||||
/// For which package/workspace member to operate
|
/// For which package/workspace member to operate
|
||||||
|
@ -236,7 +250,7 @@ pub struct PackageOpt {
|
||||||
pub package: Option<Package>,
|
pub package: Option<Package>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug, Clone)]
|
||||||
pub struct QemuAndRun {
|
pub struct QemuAndRun {
|
||||||
/// If expected output is missing or mismatching, recreate the file
|
/// If expected output is missing or mismatching, recreate the file
|
||||||
///
|
///
|
||||||
|
@ -245,7 +259,7 @@ pub struct QemuAndRun {
|
||||||
pub overwrite_expected: bool,
|
pub overwrite_expected: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser, Clone)]
|
||||||
pub struct Arg {
|
pub struct Arg {
|
||||||
/// Options to pass to `cargo size`
|
/// Options to pass to `cargo size`
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
argument_parsing::{Backends, BuildOrCheck, ExtraArguments, Package, PackageOpt, TestMetadata},
|
argument_parsing::{
|
||||||
|
Backends, BuildOrCheck, ExtraArguments, Globals, Package, PackageOpt, TestMetadata,
|
||||||
|
},
|
||||||
command::{BuildMode, CargoCommand},
|
command::{BuildMode, CargoCommand},
|
||||||
command_parser, package_feature_extractor, DEFAULT_FEATURES,
|
command_parser, package_feature_extractor, DEFAULT_FEATURES,
|
||||||
};
|
};
|
||||||
|
@ -8,6 +10,7 @@ use rayon::prelude::*;
|
||||||
|
|
||||||
/// Cargo command to either build or check
|
/// Cargo command to either build or check
|
||||||
pub fn cargo(
|
pub fn cargo(
|
||||||
|
globals: &Globals,
|
||||||
operation: BuildOrCheck,
|
operation: BuildOrCheck,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
package: &PackageOpt,
|
package: &PackageOpt,
|
||||||
|
@ -31,7 +34,7 @@ pub fn cargo(
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
command_parser(&command, false)?;
|
command_parser(globals, &command, false)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +42,7 @@ pub fn cargo(
|
||||||
///
|
///
|
||||||
/// The examples are in rtic/examples
|
/// The examples are in rtic/examples
|
||||||
pub fn cargo_example(
|
pub fn cargo_example(
|
||||||
|
globals: &Globals,
|
||||||
operation: BuildOrCheck,
|
operation: BuildOrCheck,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
|
@ -68,7 +72,7 @@ pub fn cargo_example(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = command_parser(&command, false) {
|
if let Err(err) = command_parser(globals, &command, false) {
|
||||||
error!("{err}");
|
error!("{err}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -78,12 +82,14 @@ pub fn cargo_example(
|
||||||
|
|
||||||
/// Run cargo clippy on selected package
|
/// Run cargo clippy on selected package
|
||||||
pub fn cargo_clippy(
|
pub fn cargo_clippy(
|
||||||
|
globals: &Globals,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
package: &PackageOpt,
|
package: &PackageOpt,
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let features = package_feature_extractor(package, backend);
|
let features = package_feature_extractor(package, backend);
|
||||||
command_parser(
|
command_parser(
|
||||||
|
globals,
|
||||||
&CargoCommand::Clippy {
|
&CargoCommand::Clippy {
|
||||||
cargoarg,
|
cargoarg,
|
||||||
package: package.package,
|
package: package.package,
|
||||||
|
@ -97,11 +103,13 @@ pub fn cargo_clippy(
|
||||||
|
|
||||||
/// Run cargo fmt on selected package
|
/// Run cargo fmt on selected package
|
||||||
pub fn cargo_format(
|
pub fn cargo_format(
|
||||||
|
globals: &Globals,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
package: &PackageOpt,
|
package: &PackageOpt,
|
||||||
check_only: bool,
|
check_only: bool,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
command_parser(
|
command_parser(
|
||||||
|
globals,
|
||||||
&CargoCommand::Format {
|
&CargoCommand::Format {
|
||||||
cargoarg,
|
cargoarg,
|
||||||
package: package.package,
|
package: package.package,
|
||||||
|
@ -114,6 +122,7 @@ pub fn cargo_format(
|
||||||
|
|
||||||
/// Run cargo doc
|
/// Run cargo doc
|
||||||
pub fn cargo_doc(
|
pub fn cargo_doc(
|
||||||
|
globals: &Globals,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
arguments: &Option<ExtraArguments>,
|
arguments: &Option<ExtraArguments>,
|
||||||
|
@ -125,6 +134,7 @@ pub fn cargo_doc(
|
||||||
));
|
));
|
||||||
|
|
||||||
command_parser(
|
command_parser(
|
||||||
|
globals,
|
||||||
&CargoCommand::Doc {
|
&CargoCommand::Doc {
|
||||||
cargoarg,
|
cargoarg,
|
||||||
features,
|
features,
|
||||||
|
@ -138,10 +148,14 @@ pub fn cargo_doc(
|
||||||
/// Run cargo test on the selcted package or all packages
|
/// Run cargo test on the selcted package or all packages
|
||||||
///
|
///
|
||||||
/// If no package is specified, loop through all packages
|
/// If no package is specified, loop through all packages
|
||||||
pub fn cargo_test(package: &PackageOpt, backend: Backends) -> anyhow::Result<()> {
|
pub fn cargo_test(
|
||||||
|
globals: &Globals,
|
||||||
|
package: &PackageOpt,
|
||||||
|
backend: Backends,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
if let Some(package) = package.package {
|
if let Some(package) = package.package {
|
||||||
let cmd = TestMetadata::match_package(package, backend);
|
let cmd = TestMetadata::match_package(package, backend);
|
||||||
command_parser(&cmd, false)?;
|
command_parser(globals, &cmd, false)?;
|
||||||
} else {
|
} else {
|
||||||
// Iterate over all workspace packages
|
// Iterate over all workspace packages
|
||||||
for package in [
|
for package in [
|
||||||
|
@ -154,7 +168,7 @@ pub fn cargo_test(package: &PackageOpt, backend: Backends) -> anyhow::Result<()>
|
||||||
] {
|
] {
|
||||||
let mut error_messages = vec![];
|
let mut error_messages = vec![];
|
||||||
let cmd = &TestMetadata::match_package(package, backend);
|
let cmd = &TestMetadata::match_package(package, backend);
|
||||||
if let Err(err) = command_parser(cmd, false) {
|
if let Err(err) = command_parser(globals, cmd, false) {
|
||||||
error_messages.push(err);
|
error_messages.push(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,8 +183,9 @@ pub fn cargo_test(package: &PackageOpt, backend: Backends) -> anyhow::Result<()>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use mdbook to build the book
|
/// Use mdbook to build the book
|
||||||
pub fn cargo_book(arguments: &Option<ExtraArguments>) -> anyhow::Result<()> {
|
pub fn cargo_book(globals: &Globals, arguments: &Option<ExtraArguments>) -> anyhow::Result<()> {
|
||||||
command_parser(
|
command_parser(
|
||||||
|
globals,
|
||||||
&CargoCommand::Book {
|
&CargoCommand::Book {
|
||||||
arguments: arguments.clone(),
|
arguments: arguments.clone(),
|
||||||
},
|
},
|
||||||
|
@ -183,6 +198,7 @@ pub fn cargo_book(arguments: &Option<ExtraArguments>) -> anyhow::Result<()> {
|
||||||
///
|
///
|
||||||
/// Supports updating the expected output via the overwrite argument
|
/// Supports updating the expected output via the overwrite argument
|
||||||
pub fn run_test(
|
pub fn run_test(
|
||||||
|
globals: &Globals,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
examples: &[String],
|
examples: &[String],
|
||||||
|
@ -200,7 +216,7 @@ pub fn run_test(
|
||||||
)),
|
)),
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
};
|
};
|
||||||
if let Err(err) = command_parser(&cmd, false) {
|
if let Err(err) = command_parser(globals, &cmd, false) {
|
||||||
error!("{err}");
|
error!("{err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +232,7 @@ pub fn run_test(
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = command_parser(&cmd, overwrite) {
|
if let Err(err) = command_parser(globals, &cmd, overwrite) {
|
||||||
error!("{err}");
|
error!("{err}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -226,6 +242,7 @@ pub fn run_test(
|
||||||
|
|
||||||
/// Check the binary sizes of examples
|
/// Check the binary sizes of examples
|
||||||
pub fn build_and_check_size(
|
pub fn build_and_check_size(
|
||||||
|
globals: &Globals,
|
||||||
cargoarg: &Option<&str>,
|
cargoarg: &Option<&str>,
|
||||||
backend: Backends,
|
backend: Backends,
|
||||||
examples: &[String],
|
examples: &[String],
|
||||||
|
@ -244,7 +261,7 @@ pub fn build_and_check_size(
|
||||||
)),
|
)),
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
};
|
};
|
||||||
if let Err(err) = command_parser(&cmd, false) {
|
if let Err(err) = command_parser(globals, &cmd, false) {
|
||||||
error!("{err}");
|
error!("{err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +277,7 @@ pub fn build_and_check_size(
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
arguments: arguments.clone(),
|
arguments: arguments.clone(),
|
||||||
};
|
};
|
||||||
if let Err(err) = command_parser(&cmd, false) {
|
if let Err(err) = command_parser(globals, &cmd, false) {
|
||||||
error!("{err}");
|
error!("{err}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,21 @@ pub enum BuildMode {
|
||||||
Debug,
|
Debug,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
pub enum OutputMode {
|
||||||
|
PipedAndCollected,
|
||||||
|
Inherited,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<OutputMode> for Stdio {
|
||||||
|
fn from(value: OutputMode) -> Self {
|
||||||
|
match value {
|
||||||
|
OutputMode::PipedAndCollected => Stdio::piped(),
|
||||||
|
OutputMode::Inherited => Stdio::inherit(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CargoCommand<'a> {
|
pub enum CargoCommand<'a> {
|
||||||
// For future embedded-ci
|
// For future embedded-ci
|
||||||
|
@ -414,7 +429,7 @@ impl fmt::Display for BuildMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_command(command: &CargoCommand) -> anyhow::Result<RunResult> {
|
pub fn run_command(command: &CargoCommand, stderr_mode: OutputMode) -> anyhow::Result<RunResult> {
|
||||||
let command_display = command.executable();
|
let command_display = command.executable();
|
||||||
let args = command.args();
|
let args = command.args();
|
||||||
|
|
||||||
|
@ -425,7 +440,7 @@ pub fn run_command(command: &CargoCommand) -> anyhow::Result<RunResult> {
|
||||||
let result = Command::new(command.executable())
|
let result = Command::new(command.executable())
|
||||||
.args(command.args())
|
.args(command.args())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(stderr_mode)
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
let exit_status = result.status;
|
let exit_status = result.status;
|
||||||
|
|
|
@ -4,8 +4,9 @@ mod cargo_commands;
|
||||||
mod command;
|
mod command;
|
||||||
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use argument_parsing::{ExtraArguments, Package};
|
use argument_parsing::{ExtraArguments, Globals, Package};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use command::OutputMode;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use diffy::{create_patch, PatchFormatter};
|
use diffy::{create_patch, PatchFormatter};
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -109,7 +110,9 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
|
|
||||||
let env_logger_default_level = match cli.verbose {
|
let globals = &cli.globals;
|
||||||
|
|
||||||
|
let env_logger_default_level = match globals.verbose {
|
||||||
0 => Env::default().default_filter_or("info"),
|
0 => Env::default().default_filter_or("info"),
|
||||||
1 => Env::default().default_filter_or("debug"),
|
1 => Env::default().default_filter_or("debug"),
|
||||||
_ => Env::default().default_filter_or("trace"),
|
_ => Env::default().default_filter_or("trace"),
|
||||||
|
@ -119,16 +122,16 @@ fn main() -> anyhow::Result<()> {
|
||||||
.format_timestamp(None)
|
.format_timestamp(None)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
trace!("default logging level: {0}", cli.verbose);
|
trace!("default logging level: {0}", globals.verbose);
|
||||||
|
|
||||||
let backend = if let Some(backend) = cli.backend {
|
let backend = if let Some(backend) = globals.backend {
|
||||||
backend
|
backend
|
||||||
} else {
|
} else {
|
||||||
Backends::default()
|
Backends::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let example = cli.example;
|
let example = globals.example.clone();
|
||||||
let exampleexclude = cli.exampleexclude;
|
let exampleexclude = globals.exampleexclude.clone();
|
||||||
|
|
||||||
let examples_to_run = {
|
let examples_to_run = {
|
||||||
let mut examples_to_run = examples.clone();
|
let mut examples_to_run = examples.clone();
|
||||||
|
@ -190,28 +193,29 @@ fn main() -> anyhow::Result<()> {
|
||||||
Commands::FormatCheck(args) => {
|
Commands::FormatCheck(args) => {
|
||||||
info!("Running cargo fmt --check: {args:?}");
|
info!("Running cargo fmt --check: {args:?}");
|
||||||
let check_only = true;
|
let check_only = true;
|
||||||
cargo_format(&cargologlevel, &args, check_only)?;
|
cargo_format(globals, &cargologlevel, &args, check_only)?;
|
||||||
}
|
}
|
||||||
Commands::Format(args) => {
|
Commands::Format(args) => {
|
||||||
info!("Running cargo fmt: {args:?}");
|
info!("Running cargo fmt: {args:?}");
|
||||||
let check_only = false;
|
let check_only = false;
|
||||||
cargo_format(&cargologlevel, &args, check_only)?;
|
cargo_format(globals, &cargologlevel, &args, check_only)?;
|
||||||
}
|
}
|
||||||
Commands::Clippy(args) => {
|
Commands::Clippy(args) => {
|
||||||
info!("Running clippy on backend: {backend:?}");
|
info!("Running clippy on backend: {backend:?}");
|
||||||
cargo_clippy(&cargologlevel, &args, backend)?;
|
cargo_clippy(globals, &cargologlevel, &args, backend)?;
|
||||||
}
|
}
|
||||||
Commands::Check(args) => {
|
Commands::Check(args) => {
|
||||||
info!("Checking on backend: {backend:?}");
|
info!("Checking on backend: {backend:?}");
|
||||||
cargo(BuildOrCheck::Check, &cargologlevel, &args, backend)?;
|
cargo(globals, BuildOrCheck::Check, &cargologlevel, &args, backend)?;
|
||||||
}
|
}
|
||||||
Commands::Build(args) => {
|
Commands::Build(args) => {
|
||||||
info!("Building for backend: {backend:?}");
|
info!("Building for backend: {backend:?}");
|
||||||
cargo(BuildOrCheck::Build, &cargologlevel, &args, backend)?;
|
cargo(globals, BuildOrCheck::Build, &cargologlevel, &args, backend)?;
|
||||||
}
|
}
|
||||||
Commands::ExampleCheck => {
|
Commands::ExampleCheck => {
|
||||||
info!("Checking on backend: {backend:?}");
|
info!("Checking on backend: {backend:?}");
|
||||||
cargo_example(
|
cargo_example(
|
||||||
|
globals,
|
||||||
BuildOrCheck::Check,
|
BuildOrCheck::Check,
|
||||||
&cargologlevel,
|
&cargologlevel,
|
||||||
backend,
|
backend,
|
||||||
|
@ -221,6 +225,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
Commands::ExampleBuild => {
|
Commands::ExampleBuild => {
|
||||||
info!("Building for backend: {backend:?}");
|
info!("Building for backend: {backend:?}");
|
||||||
cargo_example(
|
cargo_example(
|
||||||
|
globals,
|
||||||
BuildOrCheck::Build,
|
BuildOrCheck::Build,
|
||||||
&cargologlevel,
|
&cargologlevel,
|
||||||
backend,
|
backend,
|
||||||
|
@ -230,12 +235,19 @@ fn main() -> anyhow::Result<()> {
|
||||||
Commands::Size(args) => {
|
Commands::Size(args) => {
|
||||||
// x86_64 target not valid
|
// x86_64 target not valid
|
||||||
info!("Measuring for backend: {backend:?}");
|
info!("Measuring for backend: {backend:?}");
|
||||||
build_and_check_size(&cargologlevel, backend, &examples_to_run, &args.arguments)?;
|
build_and_check_size(
|
||||||
|
globals,
|
||||||
|
&cargologlevel,
|
||||||
|
backend,
|
||||||
|
&examples_to_run,
|
||||||
|
&args.arguments,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
Commands::Qemu(args) | Commands::Run(args) => {
|
Commands::Qemu(args) | Commands::Run(args) => {
|
||||||
// x86_64 target not valid
|
// x86_64 target not valid
|
||||||
info!("Testing for backend: {backend:?}");
|
info!("Testing for backend: {backend:?}");
|
||||||
run_test(
|
run_test(
|
||||||
|
globals,
|
||||||
&cargologlevel,
|
&cargologlevel,
|
||||||
backend,
|
backend,
|
||||||
&examples_to_run,
|
&examples_to_run,
|
||||||
|
@ -244,15 +256,15 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
Commands::Doc(args) => {
|
Commands::Doc(args) => {
|
||||||
info!("Running cargo doc on backend: {backend:?}");
|
info!("Running cargo doc on backend: {backend:?}");
|
||||||
cargo_doc(&cargologlevel, backend, &args.arguments)?;
|
cargo_doc(globals, &cargologlevel, backend, &args.arguments)?;
|
||||||
}
|
}
|
||||||
Commands::Test(args) => {
|
Commands::Test(args) => {
|
||||||
info!("Running cargo test on backend: {backend:?}");
|
info!("Running cargo test on backend: {backend:?}");
|
||||||
cargo_test(&args, backend)?;
|
cargo_test(globals, &args, backend)?;
|
||||||
}
|
}
|
||||||
Commands::Book(args) => {
|
Commands::Book(args) => {
|
||||||
info!("Running mdbook");
|
info!("Running mdbook");
|
||||||
cargo_book(&args.arguments)?;
|
cargo_book(globals, &args.arguments)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +295,13 @@ fn package_feature_extractor(package: &PackageOpt, backend: Backends) -> Option<
|
||||||
}
|
}
|
||||||
|
|
||||||
// run example binary `example`
|
// run example binary `example`
|
||||||
fn command_parser(command: &CargoCommand, overwrite: bool) -> anyhow::Result<()> {
|
fn command_parser(glob: &Globals, command: &CargoCommand, overwrite: bool) -> anyhow::Result<()> {
|
||||||
|
let output_mode = if glob.stderr_inherited {
|
||||||
|
OutputMode::Inherited
|
||||||
|
} else {
|
||||||
|
OutputMode::PipedAndCollected
|
||||||
|
};
|
||||||
|
|
||||||
match *command {
|
match *command {
|
||||||
CargoCommand::Qemu { example, .. } | CargoCommand::Run { example, .. } => {
|
CargoCommand::Qemu { example, .. } | CargoCommand::Run { example, .. } => {
|
||||||
let run_file = format!("{example}.run");
|
let run_file = format!("{example}.run");
|
||||||
|
@ -296,7 +314,7 @@ fn command_parser(command: &CargoCommand, overwrite: bool) -> anyhow::Result<()>
|
||||||
|
|
||||||
// cargo run <..>
|
// cargo run <..>
|
||||||
info!("Running example: {example}");
|
info!("Running example: {example}");
|
||||||
let cargo_run_result = run_command(command)?;
|
let cargo_run_result = run_command(command, output_mode)?;
|
||||||
info!("{}", cargo_run_result.stdout);
|
info!("{}", cargo_run_result.stdout);
|
||||||
|
|
||||||
// Create a file for the expected output if it does not exist or mismatches
|
// Create a file for the expected output if it does not exist or mismatches
|
||||||
|
@ -329,7 +347,7 @@ fn command_parser(command: &CargoCommand, overwrite: bool) -> anyhow::Result<()>
|
||||||
| CargoCommand::Test { .. }
|
| CargoCommand::Test { .. }
|
||||||
| CargoCommand::Book { .. }
|
| CargoCommand::Book { .. }
|
||||||
| CargoCommand::ExampleSize { .. } => {
|
| CargoCommand::ExampleSize { .. } => {
|
||||||
let cargo_result = run_command(command)?;
|
let cargo_result = run_command(command, output_mode)?;
|
||||||
let command = cargo_result.full_command;
|
let command = cargo_result.full_command;
|
||||||
if let Some(exit_code) = cargo_result.exit_status.code() {
|
if let Some(exit_code) = cargo_result.exit_status.code() {
|
||||||
if exit_code != exitcode::OK {
|
if exit_code != exitcode::OK {
|
||||||
|
|
Loading…
Reference in a new issue