From 88e2f0d48aef732987319efe47fd7383dcd9e5af Mon Sep 17 00:00:00 2001 From: xd009642 Date: Wed, 17 Feb 2021 20:10:31 +0400 Subject: [PATCH] Add TraceEngine option (hidden) Added the future TraceEngine option with current options Auto, Llvm and Ptrace. Check it before doing the coverage instrumentation compiler flags and warn if the user selects Llvm but they don't have a current enough compiler --- src/cargo.rs | 4 +++- src/config/mod.rs | 4 ++-- src/config/types.rs | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cargo.rs b/src/cargo.rs index ce6fae5ac1..e80d4ba100 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -483,7 +483,9 @@ pub fn rust_flags(config: &Config) -> String { if config.release { value.push_str("-C debug-assertions=off "); } - if config.engine == TraceEngine::Llvm && supports_llvm_coverage() { + if (config.engine == TraceEngine::Auto || config.engine == TraceEngine::Llvm) + && supports_llvm_coverage() + { value.push_str("-Z instrument-coverage "); } else if config.engine == TraceEngine::Llvm { error!( diff --git a/src/config/mod.rs b/src/config/mod.rs index 721d959934..a727f1d773 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -229,7 +229,7 @@ impl Default for Config { avoid_cfg_tarpaulin: false, jobs: None, color: Color::Auto, - engine: TraceEngine::Ptrace, + engine: TraceEngine::Auto, } } } @@ -303,7 +303,7 @@ impl<'a> From<&'a ArgMatches<'a>> for ConfigWrapper { profile: get_profile(args), metadata: RefCell::new(None), avoid_cfg_tarpaulin: args.is_present("avoid-cfg-tarpaulin"), - engine: TraceEngine::Ptrace, + engine: TraceEngine::Auto, }; if args.is_present("ignore-config") { Self(vec![args_config]) diff --git a/src/config/types.rs b/src/config/types.rs index d5c51062b5..c529ecf8f6 100644 --- a/src/config/types.rs +++ b/src/config/types.rs @@ -15,6 +15,7 @@ arg_enum! { arg_enum! { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Deserialize, Serialize)] pub enum TraceEngine { + Auto, Ptrace, Llvm, }