From 0300135a6a2706658f5121d186a7510ebeb031e4 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Tue, 20 Jul 2021 16:47:04 -0400 Subject: [PATCH] Add exclusions for code coverage --- src/cache/mem.rs | 5 +++++ src/cache/mod.rs | 1 + src/client.rs | 1 + src/main.rs | 3 ++- src/metrics.rs | 2 ++ src/ping.rs | 1 + src/stop.rs | 2 ++ 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/cache/mem.rs b/src/cache/mem.rs index 751de35..4fbb54d 100644 --- a/src/cache/mem.rs +++ b/src/cache/mem.rs @@ -86,6 +86,7 @@ pub trait InternalMemoryCache: Sync + Send { fn pop(&mut self) -> Option<(CacheKey, CacheValue)>; } +#[cfg(not(tarpaulin_include))] impl InternalMemoryCacheInitializer for Lfu { #[inline] fn new() -> Self { @@ -93,6 +94,7 @@ impl InternalMemoryCacheInitializer for Lfu { } } +#[cfg(not(tarpaulin_include))] impl InternalMemoryCache for Lfu { #[inline] fn get(&mut self, key: &CacheKey) -> Option> { @@ -110,6 +112,7 @@ impl InternalMemoryCache for Lfu { } } +#[cfg(not(tarpaulin_include))] impl InternalMemoryCacheInitializer for Lru { #[inline] fn new() -> Self { @@ -117,6 +120,7 @@ impl InternalMemoryCacheInitializer for Lru { } } +#[cfg(not(tarpaulin_include))] impl InternalMemoryCache for Lru { #[inline] fn get(&mut self, key: &CacheKey) -> Option> { @@ -134,6 +138,7 @@ impl InternalMemoryCache for Lru { } } +#[cfg(not(tarpaulin_include))] impl InternalMemoryCache for RedisClient { fn get(&mut self, key: &CacheKey) -> Option> { Commands::get(self, key).ok().map(Cow::Owned) diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 38fa167..97c036b 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -229,6 +229,7 @@ pub trait CallbackCache: Cache { #[async_trait] impl CallbackCache for Arc { #[inline] + #[cfg(not(tarpaulin_include))] async fn put_with_on_completed_callback( &self, key: CacheKey, diff --git a/src/client.rs b/src/client.rs index 95f2f1c..2e1c955 100644 --- a/src/client.rs +++ b/src/client.rs @@ -45,6 +45,7 @@ pub static HTTP_CLIENT: Lazy = Lazy::new(|| { } }); +#[cfg(not(tarpaulin_include))] pub static DEFAULT_HEADERS: Lazy = Lazy::new(|| { let mut headers = HeaderMap::with_capacity(8); headers.insert(X_CONTENT_TYPE_OPTIONS, HeaderValue::from_static("nosniff")); diff --git a/src/main.rs b/src/main.rs index 71d0ed0..0e00bdd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,6 @@ mod metrics; mod ping; mod routes; mod state; -#[cfg(not(tarpaulin_include))] mod stop; mod units; @@ -252,6 +251,7 @@ enum InvalidCombination { MissingUnstableOption(&'static str, UnstableOptions), } +#[cfg(not(tarpaulin_include))] impl Display for InvalidCombination { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -268,6 +268,7 @@ impl Display for InvalidCombination { impl Error for InvalidCombination {} +#[cfg(not(tarpaulin_include))] fn print_preamble_and_warnings(args: &Config) -> Result<(), Box> { let build_string = option_env!("VERGEN_GIT_SHA_SHORT") .map(|git_sha| format!(" ({})", git_sha)) diff --git a/src/metrics.rs b/src/metrics.rs index 538c64d..8559468 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -1,3 +1,5 @@ +#![cfg(not(tarpaulin_include))] + use std::fs::metadata; use std::hint::unreachable_unchecked; use std::time::SystemTime; diff --git a/src/ping.rs b/src/ping.rs index a54d914..323c06c 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -162,6 +162,7 @@ impl<'de> Deserialize<'de> for Tls { } } +#[cfg(not(tarpaulin_include))] impl std::fmt::Debug for Tls { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Tls") diff --git a/src/stop.rs b/src/stop.rs index 5818e5c..6700283 100644 --- a/src/stop.rs +++ b/src/stop.rs @@ -1,3 +1,5 @@ +#![cfg(not(tarpaulin_include))] + use reqwest::StatusCode; use serde::Serialize; use tracing::{info, warn};