summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/doc.rs b/src/doc.rs
index 2ff1484..d6ab697 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -13,6 +13,7 @@ use crate::ScenarioStep;
use crate::Style;
use crate::{bindings::CaptureType, parser::parse_scenario_snippet};
use crate::{Result, SubplotError};
+use crate::{Warning, Warnings};
use std::collections::HashSet;
use std::default::Default;
@@ -83,6 +84,7 @@ pub struct Document {
meta: Metadata,
files: DataFiles,
style: Style,
+ warnings: Warnings,
}
impl<'a> Document {
@@ -99,9 +101,15 @@ impl<'a> Document {
meta,
files,
style,
+ warnings: Warnings::default(),
}
}
+ /// Return all warnings about this document.
+ pub fn warnings(&self) -> &[Warning] {
+ self.warnings.warnings()
+ }
+
fn from_ast<P>(
basedir: P,
markdowns: Vec<PathBuf>,
@@ -344,7 +352,7 @@ impl<'a> Document {
if matches!(step.types().get(name.as_str()), Some(CaptureType::File))
&& !filenames.contains(&text.to_lowercase())
{
- eprintln!("Found reference to unknown file {}", text);
+ self.warnings.push(Warning::UnknownEmbeddedFile(text.to_string()));
okay = false;
}
}
@@ -378,10 +386,7 @@ impl<'a> Document {
}
}
for filename in filenames.iter() {
- eprintln!(
- "WARNING: embedded file is not used by any scenario: {}",
- filename
- );
+ self.warnings.push(Warning::UnusedEmbeddedFile(filename.to_string()));
}
// We always succeed. Subplot's own subplot had valid cases of
@@ -402,16 +407,10 @@ impl<'a> Document {
trace!("Found {} scenarios", scenarios.len());
for scenario in scenarios {
trace!("Checking that steps in scenario");
- let mut said_scenario = false;
for step in scenario.steps() {
if step.function().is_none() {
- if !said_scenario {
- eprintln!("Scenario: '{}'", scenario.title());
- eprintln!(" Template: '{}'", template);
- said_scenario = true;
- }
- eprintln!(" Step missing implementation: '{}'", step.text());
trace!("Missing step implementation: {:?}", step.text());
+ self.warnings.push(Warning::MissingStepImplementation(step.text().to_string()));
okay = false;
}
}