diff --git a/Cargo.lock b/Cargo.lock index be37ebf9..da6c1e35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,14 @@ dependencies = [ "memchr", ] +[[package]] +name = "disable-redaction-test" +version = "0.1.0" +dependencies = [ + "veil", + "veil-tests", +] + [[package]] name = "glob" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index c865629d..219d3245 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,12 @@ license = "MIT" repository = "https://github.com/primait/veil" [workspace] -members = ["veil-macros", "veil-tests"] +members = ["veil-macros", "veil-tests" +# Because those tests deal with global state we need to run them in a separate process. +# The easiest/only way to do this with the standard rust test harness is to put them in a +# separate crate +,"veil-tests/disable-redaction-test" +] [dependencies] veil-macros = { path = "veil-macros" } diff --git a/veil-tests/disable-redaction-test/Cargo.toml b/veil-tests/disable-redaction-test/Cargo.toml new file mode 100644 index 00000000..ed8b9d0c --- /dev/null +++ b/veil-tests/disable-redaction-test/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "disable-redaction-test" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +veil = { path = "../../" } +veil-tests = { path = "../" } diff --git a/veil-tests/disable-redaction-test/src/lib.rs b/veil-tests/disable-redaction-test/src/lib.rs new file mode 100644 index 00000000..f1892218 --- /dev/null +++ b/veil-tests/disable-redaction-test/src/lib.rs @@ -0,0 +1,12 @@ +#![cfg_attr(not(test), allow(unused))] +/// Simple test that ensures veil can actually be disabled + +use veil::Redact; +use veil_tests::{SENSITIVE_DATA, assert_has_sensitive_data}; +#[test] +fn test_veil_can_be_disabled() { + #[derive(Redact)] + struct SensitiveWrapper(#[redact] String); + veil::set_debug_format(veil::DebugFormat::Plaintext).ok(); + assert_has_sensitive_data(SensitiveWrapper(SENSITIVE_DATA[0].to_string())); +} diff --git a/veil-tests/src/redaction_tests.rs b/veil-tests/src/redaction_tests.rs index f686bb67..eecc67f6 100644 --- a/veil-tests/src/redaction_tests.rs +++ b/veil-tests/src/redaction_tests.rs @@ -147,11 +147,3 @@ fn test_sensitive_tuple_structs() { SENSITIVE_DATA[3], )); } - -#[test] -fn test_veil_can_be_disabled() { - #[derive(Redact)] - struct SensitiveWrapper(#[redact] String); - veil::set_debug_format(veil::DebugFormat::Plaintext).ok(); - assert_has_sensitive_data(SensitiveWrapper(SENSITIVE_DATA[0].to_string())); -}