omerbenamram / evtx

A Fast (and safe) parser for the Windows XML Event Log (EVTX) format
Apache License 2.0
625 stars 61 forks source link

Tests do not run when `evtx` is tested as part of a workspace #192

Open janstarke opened 3 years ago

janstarke commented 3 years ago

The cause is that samples_dir() assumes that the project dir is the current working dir, which is not the case when a workspace is being used.

Solution:

diff --git a/tests/fixtures.rs b/tests/fixtures.rs
index 5ff166e..4d760ce 100644
--- a/tests/fixtures.rs
+++ b/tests/fixtures.rs
@@ -20,11 +20,7 @@ pub fn ensure_env_logger_initialized() {
 }

 pub fn samples_dir() -> PathBuf {
-    PathBuf::from(file!())
-        .parent()
-        .unwrap()
-        .parent()
-        .unwrap()
+    PathBuf::from(env!("CARGO_MANIFEST_DIR"))
         .join("samples")
         .canonicalize()
         .unwrap()