diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-10-08 22:30:03 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-10-08 22:31:11 +0100 |
commit | 409f32c5017d3f880e003138b0548cf74f965ce0 (patch) | |
tree | ce2a0237239d5f6a145e0bb59193d487f8d0fbea /src/codegen.rs | |
parent | ada9be82cc7cc0995e14235d88f70d641aa81483 (diff) | |
download | subplot-409f32c5017d3f880e003138b0548cf74f965ce0.tar.gz |
codegen: Refuse to codegen if there are zero scenarios
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src/codegen.rs')
-rw-r--r-- | src/codegen.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen.rs b/src/codegen.rs index 89ea591..b67d94a 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -39,7 +39,8 @@ pub fn generate_test_program( fn context(doc: &mut Document, template: &str) -> Result<Context, SubplotError> { let mut context = Context::new(); - context.insert("scenarios", &doc.matched_scenarios(template)?); + let scenarios = doc.matched_scenarios(template)?; + context.insert("scenarios", &scenarios); context.insert("files", doc.files()); let funcs_filenames = doc.meta().functions_filenames(); @@ -51,6 +52,11 @@ fn context(doc: &mut Document, template: &str) -> Result<Context, SubplotError> } context.insert("functions", &funcs); + // Any of the above could fail for more serious reasons, but if we get this far + // and our context would have no scenarios in it, then we complain. + if scenarios.is_empty() { + return Err(SubplotError::NoScenariosMatched(template.to_string())); + } Ok(context) } |