Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub struct TestGenerator {
fn_cname: Box<Fn(&str, Option<&str>) -> String>,
const_cname: Box<Fn(&str) -> String>,
rust_version: rustc_version::Version,
abort_on_errors: bool,
}

struct TyFinder {
Expand Down Expand Up @@ -174,6 +175,7 @@ impl TestGenerator {
}),
const_cname: Box::new(std::string::ToString::to_string),
rust_version: rustc_version::version().unwrap(),
abort_on_errors: false,
}
}

Expand Down Expand Up @@ -778,6 +780,15 @@ impl TestGenerator {
self
}

/// Fail if parsing / macro expansion had errors
///
/// Without this macro expansion errors are ignore (and the macro invocation is
/// treated like it didn't exist).
pub fn abort_on_errors(&mut self) -> &mut Self {
self.abort_on_errors = true;
self
}

/// Generate all tests.
///
/// This function is first given the path to the `*-sys` crate which is
Expand Down Expand Up @@ -1034,6 +1045,10 @@ impl TestGenerator {
visit::walk_crate(&mut gen, &krate);
gen.emit_run_all();

if self.abort_on_errors {
sess.span_diagnostic.abort_if_errors();
}

out_file
}
}
Expand Down