Skip to content
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

[meta] add support for required and recommended nextest versions #919

Merged
merged 4 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 81 additions & 93 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions cargo-nextest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ rust-version = "1.66"
[dependencies]
camino = "1.1.6"
cfg-if = "1.0.0"
clap = { version = "4.3.17", features = ["derive", "env"] }
clap = { version = "4.3.19", features = ["derive", "env"] }
# we don't use the tracing support
color-eyre = { version = "0.6.2", default-features = false }
dialoguer = "0.10.4"
duct = "0.13.6"
enable-ansi-support = "0.2.1"
# we don't use the default formatter so we don't need default features
env_logger = { version = "0.10.0", default-features = false }
guppy = "0.17.0"
guppy = "0.17.1"
log = "0.4.19"
itertools = "0.10.5"
itertools = "0.11.0"
miette = { version = "5.10.0", features = ["fancy"] }
nextest-filtering = { version = "=0.5.0", path = "../nextest-filtering" }
nextest-runner = { version = "=0.42.0", path = "../nextest-runner" }
Expand All @@ -36,7 +36,7 @@ semver = "1.0.18"
shell-words = "1.1.0"
supports-color = "2.0.0"
supports-unicode = "2.0.0"
serde_json = "1.0.103"
serde_json = "1.0.104"
thiserror = "1.0.44"
nextest-workspace-hack = { version = "0.1", path = "../workspace-hack" }

Expand Down
100 changes: 59 additions & 41 deletions cargo-nextest/src/cargo_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use crate::output::OutputContext;
use camino::{Utf8Path, Utf8PathBuf};
use clap::Args;
use std::path::PathBuf;
use std::{borrow::Cow, path::PathBuf};

/// Options passed down to cargo.
#[derive(Debug, Args)]
Expand Down Expand Up @@ -118,6 +118,10 @@
#[arg(long, group = "cargo-opts")]
future_incompat_report: bool,

/// Timing output formats (unstable) (comma separated): html, json
#[arg(long, require_equals = true, value_name = "FMTS", group = "cargo-opts")]
timings: Option<Option<String>>,

// --verbose is not currently supported
// --color is handled by runner
/// Require Cargo.lock and cache are up to date
Expand Down Expand Up @@ -149,7 +153,7 @@
manifest_path: Option<&'a Utf8Path>,
output: OutputContext,
command: &'a str,
args: Vec<&'a str>,
args: Vec<Cow<'a, str>>,
}

impl<'a> CargoCli<'a> {
Expand All @@ -170,108 +174,116 @@

#[allow(dead_code)]
pub(crate) fn add_arg(&mut self, arg: &'a str) -> &mut Self {
self.args.push(arg);
self.args.push(Cow::Borrowed(arg));
self
}

pub(crate) fn add_args(&mut self, args: impl IntoIterator<Item = &'a str>) -> &mut Self {
self.args.extend(args);
self.args.extend(args.into_iter().map(Cow::Borrowed));
self
}

pub(crate) fn add_options(&mut self, options: &'a CargoOptions) -> &mut Self {
if options.lib {
self.args.push("--lib");
self.add_arg("--lib");

Check warning on line 188 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L188

Added line #L188 was not covered by tests
}
self.args
.extend(options.bin.iter().flat_map(|s| ["--bin", s.as_str()]));
self.add_args(options.bin.iter().flat_map(|s| ["--bin", s.as_str()]));
if options.bins {
self.args.push("--bins");
self.add_arg("--bins");

Check warning on line 192 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L192

Added line #L192 was not covered by tests
}
self.args.extend(
self.add_args(
options
.example
.iter()
.flat_map(|s| ["--example", s.as_str()]),
);
if options.examples {
self.args.push("--examples");
self.add_arg("--examples");

Check warning on line 201 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L201

Added line #L201 was not covered by tests
}
self.args
.extend(options.test.iter().flat_map(|s| ["--test", s.as_str()]));
self.add_args(options.test.iter().flat_map(|s| ["--test", s.as_str()]));
if options.tests {
self.args.push("--tests");
self.add_arg("--tests");

Check warning on line 205 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L205

Added line #L205 was not covered by tests
}
self.args
.extend(options.bench.iter().flat_map(|s| ["--bench", s.as_str()]));
self.add_args(options.bench.iter().flat_map(|s| ["--bench", s.as_str()]));
if options.benches {
self.args.push("--benches");
self.add_arg("--benches");

Check warning on line 209 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L209

Added line #L209 was not covered by tests
}
if options.all_targets {
self.args.push("--all-targets");
self.add_arg("--all-targets");
}
self.args.extend(
self.add_args(
options
.packages
.iter()
.flat_map(|s| ["--package", s.as_str()]),
);
if options.workspace {
self.args.push("--workspace");
self.add_arg("--workspace");
}
self.args.extend(
self.add_args(
options
.exclude
.iter()
.flat_map(|s| ["--exclude", s.as_str()]),
);
if options.all {
self.args.push("--all");
self.add_arg("--all");

Check warning on line 230 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L230

Added line #L230 was not covered by tests
}
if options.release {
self.args.push("--release");
self.add_arg("--release");

Check warning on line 233 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L233

Added line #L233 was not covered by tests
}
if let Some(profile) = &options.cargo_profile {
self.args.extend(["--profile", profile]);
self.add_args(["--profile", profile]);

Check warning on line 236 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L236

Added line #L236 was not covered by tests
}
if let Some(build_jobs) = &options.build_jobs {
self.args.extend(["--jobs", build_jobs.as_str()]);
self.add_args(["--jobs", build_jobs.as_str()]);

Check warning on line 239 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L239

Added line #L239 was not covered by tests
}
self.args
.extend(options.features.iter().flat_map(|s| ["--features", s]));
self.add_args(options.features.iter().flat_map(|s| ["--features", s]));
if options.all_features {
self.args.push("--all-features");
self.add_arg("--all-features");

Check warning on line 243 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L243

Added line #L243 was not covered by tests
}
if options.no_default_features {
self.args.push("--no-default-features");
self.add_arg("--no-default-features");

Check warning on line 246 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L246

Added line #L246 was not covered by tests
}
if let Some(target) = &options.target {
self.args.extend(["--target", target]);
self.add_args(["--target", target]);

Check warning on line 249 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L249

Added line #L249 was not covered by tests
}
if let Some(target_dir) = &options.target_dir {
self.args.extend(["--target-dir", target_dir.as_str()]);
self.add_args(["--target-dir", target_dir.as_str()]);
}
if options.ignore_rust_version {
self.args.push("--ignore-rust-version");
self.add_arg("--ignore-rust-version");

Check warning on line 255 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L255

Added line #L255 was not covered by tests
}
if options.unit_graph {
self.args.push("--unit-graph");
self.add_arg("--unit-graph");

Check warning on line 258 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L258

Added line #L258 was not covered by tests
}
if let Some(timings) = &options.timings {
match timings {
Some(timings) => {
// The argument must be passed in as "--timings=html,json", not "--timings
// html,json".
let timings = format!("--timings={}", timings.as_str());
self.add_owned_arg(timings);
}
None => {
self.add_arg("--timings");
}

Check warning on line 270 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L261-L270

Added lines #L261 - L270 were not covered by tests
}
}
if options.future_incompat_report {
self.args.push("--future-incompat-report");
self.add_arg("--future-incompat-report");

Check warning on line 274 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L274

Added line #L274 was not covered by tests
}
if options.frozen {
self.args.push("--frozen");
self.add_arg("--frozen");

Check warning on line 277 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L277

Added line #L277 was not covered by tests
}
if options.locked {
self.args.push("--locked");
self.add_arg("--locked");

Check warning on line 280 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L280

Added line #L280 was not covered by tests
}
if options.offline {
self.args.push("--offline");
self.add_arg("--offline");

Check warning on line 283 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L283

Added line #L283 was not covered by tests
}
self.args
.extend(options.config.iter().flat_map(|s| ["--config", s.as_str()]));
self.args.extend(
self.add_args(options.config.iter().flat_map(|s| ["--config", s.as_str()]));
self.add_args(
options
.unstable_flags
.iter()
Expand All @@ -283,9 +295,13 @@
self
}

fn add_owned_arg(&mut self, arg: String) {
self.args.push(Cow::Owned(arg));
}

Check warning on line 300 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L298-L300

Added lines #L298 - L300 were not covered by tests

pub(crate) fn all_args(&self) -> Vec<&str> {
let mut all_args = vec![self.cargo_path.as_str(), self.command];
all_args.extend_from_slice(&self.args);
all_args.extend(self.args.iter().map(|s| s.as_ref()));

Check warning on line 304 in cargo-nextest/src/cargo_cli.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/cargo_cli.rs#L304

Added line #L304 was not covered by tests
all_args
}

Expand All @@ -298,7 +314,9 @@
// Ensure that cargo gets picked up from PATH if necessary, by calling as_str
// rather than as_std_path.
self.cargo_path.as_str(),
initial_args.into_iter().chain(self.args.iter().copied()),
initial_args
.into_iter()
.chain(self.args.iter().map(|s| s.as_ref())),
)
}
}
Expand Down
Loading
Loading