diff options
-rw-r--r-- | subplot-build/src/lib.rs | 3 | ||||
-rw-r--r-- | subplotlib/build.rs | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/subplot-build/src/lib.rs b/subplot-build/src/lib.rs index 20d3e08..db47623 100644 --- a/subplot-build/src/lib.rs +++ b/subplot-build/src/lib.rs @@ -7,7 +7,8 @@ use std::env::var_os; use std::fmt::Debug; use std::path::{Path, PathBuf}; -use subplot::{get_basedir_from, SubplotError}; +use subplot::get_basedir_from; +pub use subplot::SubplotError; use tracing::{event, instrument, span, Level}; /// Generate code for one document, inside `build.rs`. diff --git a/subplotlib/build.rs b/subplotlib/build.rs index 77e493a..977f432 100644 --- a/subplotlib/build.rs +++ b/subplotlib/build.rs @@ -14,7 +14,7 @@ use glob::glob; use std::{fs, path::Path}; -fn gen_tests() { +fn gen_tests() -> Result<(), subplot_build::SubplotError> { let subplots = glob("*.subplot").expect("failed to find subplots in subplotlib"); let tests = Path::new("tests"); let subplots = subplots.chain(Some(Ok("../subplot.subplot".into()))); @@ -31,12 +31,16 @@ fn gen_tests() { println!("cargo:rerun-if-changed={}", entry.display()); subplot_build::codegen(Path::new(&entry)).expect("failed to generate code with Subplot"); } + Ok(()) } 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.subplot which is a good indicator. if fs::metadata("../subplot.subplot").is_ok() { - gen_tests(); + if let Err(e) = gen_tests() { + eprintln!("Failed to generate code from subplot: {e}"); + std::process::exit(1); + } } } |