Skip to content

Commit

Permalink
Merge pull request #671 from HigherOrderCO/666-whenever-a-test-in-exa…
Browse files Browse the repository at this point in the history
…mples-doesnt-compile-the-test-fails-instead-of-updating-the-snapshot

#666 Whenever a test in /examples doesn't compile, the test fails instead of updating the snapshot
  • Loading branch information
imaqtkatt authored Aug 14, 2024
2 parents b69d1e4 + aacad7a commit d6a1995
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/golden_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,21 @@ fn examples() -> Result<(), Diagnostics> {
.filter_map(|e| e.ok())
.filter(|e| e.path().extension().map_or(false, |ext| ext == "bend"))
{
let _guard = RUN_MUTEX.lock().unwrap();
let _guard = RUN_MUTEX.lock().unwrap_or_else(|e| e.into_inner());
let path = entry.path();
eprintln!("Testing {}", path.display());
let code = std::fs::read_to_string(path).map_err(|e| e.to_string())?;

let book = do_parse_book_default(&code, path).unwrap();
let compile_opts = CompileOpts::default();
let diagnostics_cfg = DiagnosticsConfig::default();
let (term, _, diags) =
run_book(book, RunOpts::default(), compile_opts, diagnostics_cfg, None, "run-c")?.unwrap();
let res = format!("{diags}{term}");
let res = match do_parse_book_default(&code, path) {
Ok(book) => {
let compile_opts = CompileOpts::default();
let diagnostics_cfg = DiagnosticsConfig::default();
let (term, _, diags) =
run_book(book, RunOpts::default(), compile_opts, diagnostics_cfg, None, "run-c")?.unwrap();
format!("{diags}{term}")
}
Err(e) => e,
};

let mut settings = insta::Settings::clone_current();
settings.set_prepend_module_to_snapshot(false);
Expand Down

0 comments on commit d6a1995

Please sign in to comment.