summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2022-04-17 12:03:53 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2022-04-17 12:03:53 +0100
commit1c28232c16a867a644ad28f5df232220cb82bead (patch)
treeb42b87b258bd7820e2a09e137d330b59330e73db
parent99e947c92737d72f41ecca4cddf359b3643c11a9 (diff)
downloadsubplot-1c28232c16a867a644ad28f5df232220cb82bead.tar.gz
(subplotlib): Do not generate tests for subplotlib if not in-tree
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r--subplotlib/build.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/subplotlib/build.rs b/subplotlib/build.rs
index 5b02a27..f22a50c 100644
--- a/subplotlib/build.rs
+++ b/subplotlib/build.rs
@@ -12,9 +12,9 @@
// ```
use glob::glob;
-use std::path::Path;
+use std::{fs, path::Path};
-fn main() {
+fn gen_tests() {
let subplots = glob("*.md").expect("failed to find subplots in subplotlib");
let tests = Path::new("tests");
let subplots = subplots.chain(Some(Ok("../subplot.md".into())));
@@ -32,3 +32,11 @@ fn main() {
subplot_build::codegen(Path::new(&entry)).expect("failed to generate code with Subplot");
}
}
+
+fn main() {
+ // Because we cannot generate tests if we're not fully inside the main subplot tree
+ // we only generate them if we can see ../subplot.md which is a good indicator.
+ if fs::metadata("../subplot.md").is_ok() {
+ gen_tests();
+ }
+}