summaryrefslogtreecommitdiff
path: root/subplotlib/build.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-04-17 11:17:16 +0000
committerLars Wirzenius <liw@liw.fi>2022-04-17 11:17:16 +0000
commite66003da3b6c67c4287234d6374bf86736214321 (patch)
tree0fc6d4ac14da26a6582eb8cccc3b6636593452b0 /subplotlib/build.rs
parent99e947c92737d72f41ecca4cddf359b3643c11a9 (diff)
parentfbfd853fe36c8f635f0b09f5719c5a862668d7e2 (diff)
downloadsubplot-e66003da3b6c67c4287234d6374bf86736214321.tar.gz
Merge branch 'fix-release' into 'main'0.4.1
(subplotlib): Do not generate tests for subplotlib if not in-tree See merge request subplot/subplot!271
Diffstat (limited to 'subplotlib/build.rs')
-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();
+ }
+}