diff --git a/Cargo.toml b/Cargo.toml index 5f02f1ca..53dd08b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,8 +40,10 @@ sophia_turtle = { version = "0.8.0", path = "./turtle" } sophia_xml = { version = "0.8.0", path = "./xml" } criterion = "0.5" +env_logger = "0.11.3" futures-util = "0.3.28" lazy_static = "1.4.0" +log = "0.4.21" mownstr = "0.2.1" oxiri = "0.2.2" regex = "1.6.0" diff --git a/c14n/Cargo.toml b/c14n/Cargo.toml index 00e42315..9f2cf76d 100644 --- a/c14n/Cargo.toml +++ b/c14n/Cargo.toml @@ -13,7 +13,11 @@ keywords.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +log.workspace = true sha2 = "0.10.7" sophia_api.workspace = true sophia_iri.workspace = true -thiserror.workspace = true \ No newline at end of file +thiserror.workspace = true + +[dev-dependencies] +env_logger.workspace = true diff --git a/c14n/src/_permutations.rs b/c14n/src/_permutations.rs index 842dc4f3..e1a459af 100644 --- a/c14n/src/_permutations.rs +++ b/c14n/src/_permutations.rs @@ -37,6 +37,8 @@ mod test { #[test] fn check_empty() { + crate::test_setup(); + let mut a = []; let mut got = HashSet::>::new(); for_each_permutation_of(&mut a, |a| { @@ -49,6 +51,8 @@ mod test { #[test] fn check_1() { + crate::test_setup(); + let mut a = [1]; let exp = [vec![1]].into_iter().collect::>(); let mut got = HashSet::>::new(); @@ -62,6 +66,8 @@ mod test { #[test] fn check_12() { + crate::test_setup(); + let mut a = [1, 2]; let exp = [vec![1, 2], vec![2, 1]].into_iter().collect::>(); let mut got = HashSet::>::new(); @@ -75,6 +81,8 @@ mod test { #[test] fn check_123() { + crate::test_setup(); + let mut a = [1, 2, 3]; let exp = [ vec![1, 2, 3], @@ -97,6 +105,8 @@ mod test { #[test] fn check_1234() { + crate::test_setup(); + let mut a = [1, 2, 3, 4]; let exp = [ vec![1, 2, 3, 4], @@ -137,6 +147,8 @@ mod test { #[test] fn check_12345() { + crate::test_setup(); + let mut a = [1, 2, 3, 4, 5]; let mut got = HashSet::>::new(); for_each_permutation_of(&mut a, |a| { @@ -149,6 +161,8 @@ mod test { #[test] fn check_err() { + crate::test_setup(); + let mut a = [1, 2, 3, 4]; let exp = [ vec![1, 2, 3, 4], diff --git a/c14n/src/lib.rs b/c14n/src/lib.rs index 94a9285a..acef4c25 100644 --- a/c14n/src/lib.rs +++ b/c14n/src/lib.rs @@ -40,3 +40,13 @@ pub enum C14nError { #[error("Unsupported feature: {0}")] Unsupported(String), } + +#[cfg(test)] +fn test_setup() { + TEST_SETUP.call_once(|| { + env_logger::init(); + }); +} + +#[cfg(test)] +static TEST_SETUP: std::sync::Once = std::sync::Once::new(); diff --git a/c14n/src/rdfc10.rs b/c14n/src/rdfc10.rs index afa399a6..2195608b 100644 --- a/c14n/src/rdfc10.rs +++ b/c14n/src/rdfc10.rs @@ -398,7 +398,7 @@ impl<'a, H: HashFunction, T: Term> C14nState<'a, H, T> { ret_issuer.unwrap_or_else(|| issuer.clone()), ); debug_assert!({ - eprintln!( + log::trace!( "hash-n-degree({}, {})\n-> {}", identifier, depth, @@ -470,7 +470,7 @@ fn hash_first_degree_quads(bnid: &str, quads: &[&Q]) - } let ret = hasher.finalize(); debug_assert!({ - eprintln!("hash-first-degree({})\n-> {}", bnid, hex(&ret)); + log::trace!("hash-first-degree({})\n-> {}", bnid, hex(&ret)); true }); ret @@ -520,6 +520,8 @@ mod test { #[test] fn example2() { + crate::test_setup(); + let dataset = ez_quads(&[ " _:e0 .", " _:e1 .", @@ -538,6 +540,8 @@ _:c14n1 . #[test] fn example3() { + crate::test_setup(); + let dataset = ez_quads(&[ " _:e0 .", " _:e1 .", @@ -558,6 +562,8 @@ _:c14n3 _:c14n0 . #[test] fn cycle5() { + crate::test_setup(); + let dataset = ez_quads(&[ "_:e0 _:e1 .", "_:e1 _:e2 .", @@ -578,6 +584,8 @@ _:c14n4 _:c14n3 . #[test] fn cycle5_toxic() { + crate::test_setup(); + let dataset = ez_quads(&[ "_:e0 _:e1 .", "_:e1 _:e2 .", @@ -598,6 +606,8 @@ _:c14n4 _:c14n3 . #[test] fn clique5() { + crate::test_setup(); + let dataset = ez_quads(&[ "_:e0 _:e1 .", "_:e0 _:e2 .", @@ -648,6 +658,8 @@ _:c14n4 _:c14n3 . #[test] fn clique5_toxic() { + crate::test_setup(); + let dataset = ez_quads(&[ "_:e0 _:e1 .", "_:e0 _:e2 .", @@ -679,6 +691,8 @@ _:c14n4 _:c14n3 . #[test] fn cycle2plus3() { + crate::test_setup(); + let dataset = ez_quads(&[ "_:e0 _:e1 .", "_:e1 _:e0 .", @@ -699,6 +713,8 @@ _:c14n4 _:c14n3 . #[test] fn tricky_order() { + crate::test_setup(); + let dataset = ez_quads(&[ " _:a .", " .", @@ -780,6 +796,8 @@ _:c14n4 _:c14n3 . #[test] fn example2_sha384() { + crate::test_setup(); + let dataset = ez_quads(&[ " _:e0 .", " _:e1 .",