diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-04-17 11:17:16 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-04-17 11:17:16 +0000 |
commit | e66003da3b6c67c4287234d6374bf86736214321 (patch) | |
tree | 0fc6d4ac14da26a6582eb8cccc3b6636593452b0 /subplotlib/build.rs | |
parent | 99e947c92737d72f41ecca4cddf359b3643c11a9 (diff) | |
parent | fbfd853fe36c8f635f0b09f5719c5a862668d7e2 (diff) | |
download | subplot-e3a0379d7e4c534366ffd027f0c2760e3cd553a4.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.rs | 12 |
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(); + } +} |