Skip to content

Commit

Permalink
chore: add env var for test updates in nargo_fmt (#3638)
Browse files Browse the repository at this point in the history
# Description

Introduced an environment variable UPDATE_EXPECT in nargo_fmt build
script to allow automatic updating of test outputs.

## Documentation

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
kek kek kek authored Dec 1, 2023
1 parent 47d4725 commit 7a58c82
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tooling/nargo_fmt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ fn format_{test_name}() {{
let expected_output = r#"{output_source}"#;
let (parsed_module, errors) = noirc_frontend::parse_program(&input);
let (parsed_module, _errors) = noirc_frontend::parse_program(&input);
let config = nargo_fmt::Config::of("{config}").unwrap();
let fmt_text = nargo_fmt::format(&input, parsed_module, &config);
std::fs::write("{output_source_path}", fmt_text.clone());
if std::env::var("UPDATE_EXPECT").is_ok() {{
std::fs::write("{output_source_path}", fmt_text.clone()).unwrap();
}}
similar_asserts::assert_eq!(fmt_text, expected_output);
}}
Expand Down

0 comments on commit 7a58c82

Please sign in to comment.