From 19115e9fabf1364fe94c21b44546aa01f380f04c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 4 Mar 2020 11:38:55 +0100 Subject: Support cross-crate marks --- crates/test_utils/src/marks.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'crates/test_utils') diff --git a/crates/test_utils/src/marks.rs b/crates/test_utils/src/marks.rs index f8fabfaff..c3185e860 100644 --- a/crates/test_utils/src/marks.rs +++ b/crates/test_utils/src/marks.rs @@ -30,6 +30,12 @@ use std::sync::atomic::{AtomicUsize, Ordering}; #[macro_export] macro_rules! tested_by { + ($ident:ident; force) => {{ + { + // sic! use call-site crate + crate::marks::$ident.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + } + }}; ($ident:ident) => {{ #[cfg(test)] { @@ -41,9 +47,12 @@ macro_rules! tested_by { #[macro_export] macro_rules! covers { + // sic! use call-site crate ($ident:ident) => { - // sic! use call-site crate - let _checker = $crate::marks::MarkChecker::new(&crate::marks::$ident); + $crate::covers!(crate::$ident) + }; + ($krate:ident :: $ident:ident) => { + let _checker = $crate::marks::MarkChecker::new(&$krate::marks::$ident); }; } @@ -52,7 +61,7 @@ macro_rules! marks { ($($ident:ident)*) => { $( #[allow(bad_style)] - pub(crate) static $ident: std::sync::atomic::AtomicUsize = + pub static $ident: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); )* }; -- cgit v1.2.3