diff --git a/src/check.rs b/src/check.rs index 992ed68..4c77a59 100644 --- a/src/check.rs +++ b/src/check.rs @@ -11,6 +11,7 @@ pub enum CrateSupport { ProcMacro, SourceOffenses(Vec), NoOffenseDetected, + Skipped, } #[derive(Debug)] @@ -94,6 +95,7 @@ impl CheckResult { CrateSupport::OnlyWithoutFeature(ref feature) => !self.is_feature_active(feature), CrateSupport::NoOffenseDetected => true, CrateSupport::SourceOffenses(_) => false, + CrateSupport::Skipped => true, } } diff --git a/src/check_source.rs b/src/check_source.rs index 0e3f075..5617084 100644 --- a/src/check_source.rs +++ b/src/check_source.rs @@ -145,6 +145,7 @@ pub fn get_crate_support_from_source(main_src_path: &PathBuf) -> CrateSupport { CrateSupport::ProcMacro => return main_file_support, CrateSupport::SourceOffenses(mut off) => offenses.append(&mut off), CrateSupport::NoOffenseDetected => {} + CrateSupport::Skipped => return main_file_support, }; let other_source_files_pattern = format!( diff --git a/src/main.rs b/src/main.rs index 5e28f6e..cfbb81a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod util; use clap::{App, Arg, SubCommand}; use console::Emoji; +use std::collections::HashSet; use std::path::PathBuf; use crate::check::*; @@ -17,12 +18,14 @@ use cargo_metadata::{Metadata, Package}; pub static SUCCESS: Emoji = Emoji("✅ ", "SUCCESS"); pub static FAILURE: Emoji = Emoji("❌ ", "FAILURE"); pub static MAYBE: Emoji = Emoji("❓ ", "MAYBE"); +pub static SKIPPED: Emoji = Emoji("⏭ ", "SKIPPED"); fn check_and_print_package( package: &Package, resolved_dependency_features: &[Feature], metadata: &Metadata, metadata_full: &Metadata, + allowed: &HashSet, is_main_pkg: bool, ) -> bool { let mut package_did_fail = false; @@ -42,6 +45,9 @@ fn check_and_print_package( if package.is_proc_macro() { support = CrateSupport::ProcMacro; } + if allowed.contains(&package.name) { + support = CrateSupport::Skipped; + } if support == CrateSupport::NoOffenseDetected { match is_main_pkg { false => { @@ -83,9 +89,15 @@ fn check_and_print_package( if !check.no_std_itself() { package_did_fail = true; } - let overall_res = match check.no_std_itself() { - true => SUCCESS, - false => FAILURE, + let overall_res = match check.support { + CrateSupport::ProcMacro => SUCCESS, + CrateSupport::OnlyWithoutFeature(ref feature) => match check.is_feature_active(feature) { + false => SUCCESS, + true => FAILURE, + }, + CrateSupport::NoOffenseDetected => SUCCESS, + CrateSupport::SourceOffenses(_) => FAILURE, + CrateSupport::Skipped => SKIPPED, }; println!("{}: {}", check.package_name, overall_res); if check.no_std_itself() { @@ -128,6 +140,12 @@ fn main() { .multiple(true) .takes_value(true), ) + .arg( + Arg::with_name("allow") + .long("allow") + .multiple(true) + .takes_value(true), + ) .arg(Arg::with_name("package").long("package").takes_value(true)), ); @@ -151,6 +169,11 @@ fn main() { .unwrap_or(Vec::new()) .to_owned(), ); + let allowed: HashSet = matches + .values_of("allow") + .map(|n| n.into_iter().map(|m| m.to_owned()).collect()) + .unwrap_or(HashSet::new()) + .to_owned(); let active_features = target_package.active_features_for_features(&features); let active_dependencies = target_package.active_dependencies(&active_features); @@ -171,6 +194,7 @@ fn main() { &resolved_dependency_features, &metadata, &metadata_full, + &allowed, true, ) { package_did_fail = true; @@ -182,6 +206,7 @@ fn main() { &resolved_dependency_features, &metadata, &metadata_full, + &allowed, false, ) { package_did_fail = true;