Skip to content

Commit

Permalink
feat: check packages and report failures
Browse files Browse the repository at this point in the history
  • Loading branch information
BD103 committed Jul 5, 2024
1 parent 706775c commit 074b6ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 38 deletions.
17 changes: 0 additions & 17 deletions config/demo.toml

This file was deleted.

19 changes: 19 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use combos::{feature_combos, ncr};
use config::{load_config, Config};
use intern::FeatureStorage;
use metadata::{load_metadata, Package};
use runner::check_with_features;

fn main() {
let cli: CLI = argh::from_env();
Expand All @@ -30,6 +31,8 @@ fn main() {
#[cfg(debug_assertions)]
println!("{:?}", metadata);

let mut failures = Vec::new();

for package in metadata.packages {
let Package { name, features } = package;
let config = config.get(&name);
Expand All @@ -54,6 +57,22 @@ fn main() {
}

println!("\tChecking: {:?}", names);

let status = check_with_features(&name, &cli.manifest_path, &combo, &storage);

if !status.success() {
failures.push(format!(
"Failed checking package {name} with features {names:?}"
));
}
}
}

if !failures.is_empty() {
eprintln!("Failure report:");

for failure in failures {
eprintln!("\t{failure}");
}
}
}
Expand Down
35 changes: 14 additions & 21 deletions src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
ffi::OsStr,
path::Path,
process::{Command, Output},
process::{Command, ExitStatus},
};

use crate::intern::{FeatureKey, FeatureStorage};
Expand All @@ -12,32 +12,25 @@ pub fn check_with_features(
manifest_path: &Path,
features: &[FeatureKey],
storage: &FeatureStorage,
) -> Output {
) -> ExitStatus {
// Create comma-separated list of features.
let features = features
.into_iter()
.map(|key| storage.get(*key).unwrap())
.fold(String::new(), |mut acc, f| {
acc.push_str(f);
acc.push(',');
acc
});

// Strip ending comma if it exists.
let features = match features.strip_suffix(',') {
Some(f) => f,
None => &features,
};

println!("Checking {package} with features {features}");
let features =
features
.iter()
.map(|key| storage.get(*key).unwrap())
.fold(String::new(), |mut acc, f| {
acc.push_str(f);
acc.push(',');
acc
});

Command::new("cargo")
.arg("check")
.args([OsStr::new("--manifest-path"), manifest_path.as_os_str()])
.args(["--package", package])
.args(["--color", "never"])
.arg("--no-default-features")
.args(["--features", features])
.output()
.args(["--features", &features])
.arg("--quiet")
.status()
.unwrap()
}

0 comments on commit 074b6ca

Please sign in to comment.