From 7a58c825a2bfe79d34f8461f823cbfc2f01a24e4 Mon Sep 17 00:00:00 2001 From: kek kek kek Date: Fri, 1 Dec 2023 02:11:13 -0800 Subject: [PATCH] chore: add env var for test updates in nargo_fmt (#3638) # 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. --- tooling/nargo_fmt/build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tooling/nargo_fmt/build.rs b/tooling/nargo_fmt/build.rs index fba6a1730a8..c356b403ae5 100644 --- a/tooling/nargo_fmt/build.rs +++ b/tooling/nargo_fmt/build.rs @@ -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); }}