From e13ca384c6ac948aff5b00392946b54cbce9f536 Mon Sep 17 00:00:00 2001 From: Xavier Denis Date: Sat, 3 Aug 2024 11:48:51 +0200 Subject: [PATCH 1/2] Add magic comment for custom arguments in ui tests --- creusot/tests/ui.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/creusot/tests/ui.rs b/creusot/tests/ui.rs index cd391604c2..b1f31b5d92 100644 --- a/creusot/tests/ui.rs +++ b/creusot/tests/ui.rs @@ -86,6 +86,15 @@ fn run_creusot( creusot_contract_path.to_str().expect("invalid utf-8 in contract path"); let creusot_contract_path = normalize_file_path(creusot_contract_path); + // Magic comment with instructions for creusot + let header_line = BufReader::new(File::open(file).unwrap()).lines().nth(0).unwrap().unwrap(); + // Find comment chunks of the form CREUSOT_ARG=ARGUMENT. Does not support spaces in arguments currently (would require real parser) + let args: Vec<_> = header_line + .split(" ") + .filter(|chunk| chunk.contains("CREUSOT_ARG")) + .flat_map(|chunk| chunk.split("=").nth(1)) + .collect(); + cmd.args(&[ "--stdout", "--export-metadata=false", @@ -93,6 +102,7 @@ fn run_creusot( // we will write the coma output next to the .rs file "--spans-relative-to=.", ]); + cmd.args(args); cmd.args(&[ "--creusot-extern", &format!("creusot_contracts={}", normalize_file_path(contracts)), From 12ca32c4a5ec089fd97ca109f22959443ee5d6c5 Mon Sep 17 00:00:00 2001 From: dewert99 Date: Sat, 3 Aug 2024 09:29:09 -0700 Subject: [PATCH 2/2] Fix creusot argument command --- creusot/tests/ui.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/creusot/tests/ui.rs b/creusot/tests/ui.rs index b1f31b5d92..15e829d367 100644 --- a/creusot/tests/ui.rs +++ b/creusot/tests/ui.rs @@ -91,8 +91,14 @@ fn run_creusot( // Find comment chunks of the form CREUSOT_ARG=ARGUMENT. Does not support spaces in arguments currently (would require real parser) let args: Vec<_> = header_line .split(" ") - .filter(|chunk| chunk.contains("CREUSOT_ARG")) - .flat_map(|chunk| chunk.split("=").nth(1)) + .filter_map(|chunk| { + let (first, rest) = chunk.split_once("=")?; + if first != "CREUSOT_ARG" { + None + } else { + Some(rest) + } + }) .collect(); cmd.args(&[