[librsvg: 2/15] tests: Fix CI run where srcdir != builddir



commit 8ec0ede8ceba4a34c19b87994539181a891382a2
Author: Sven Neumann <sven svenfoo org>
Date:   Mon Feb 3 21:33:32 2020 +0100

    tests: Fix CI run where srcdir != builddir
    
    The solution is not perfect, but it handles the common cases
    - running cargo test (needs srcdir == builddir)
    - running make check (allows srcdir != builddir)

 Makefile.am                       |  1 +
 tests/src/cmdline/rsvg_convert.rs | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c51b2e1d..3b3c25d7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -160,6 +160,7 @@ endif
 check-local:
        cd $(srcdir) &&                                 \
        CARGO_TARGET_DIR=$(CARGO_TARGET_DIR)            \
+       LIBRSVG_BUILD_DIR=$(LIBRSVG_BUILD_DIR)          \
        OUT_DIR=$(LIBRSVG_BUILD_DIR)/tests/output       \
        $(CARGO) --locked test $(CARGO_VERBOSE) $(CARGO_TARGET_ARGS) $(CARGO_RELEASE_ARGS)
 
diff --git a/tests/src/cmdline/rsvg_convert.rs b/tests/src/cmdline/rsvg_convert.rs
index 83feeb28..57205737 100644
--- a/tests/src/cmdline/rsvg_convert.rs
+++ b/tests/src/cmdline/rsvg_convert.rs
@@ -8,10 +8,17 @@ struct RsvgConvert {
     cmd: assert_cmd::Command,
 }
 
+fn location() -> &'static Path {
+    match option_env!("LIBRSVG_BUILD_DIR") {
+        Some(dir) => Path::new(dir),
+        None => Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap()
+    }
+}
+
 impl RsvgConvert {
     fn new() -> Self {
-        let dir = Path::new(env!("CARGO_MANIFEST_DIR"));
-        let path = dir.parent().unwrap().join("rsvg-convert");
+        let path = location().join("rsvg-convert");
+        println!("{:?}", path);
         RsvgConvert { cmd: assert_cmd::Command::new(path) }
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]