Skip to content

Commit

Permalink
Merge pull request #1058 from creusot-rs/custom-args-ui-test
Browse files Browse the repository at this point in the history
Add magic comment for custom arguments in ui tests
  • Loading branch information
xldenis authored Aug 3, 2024
2 parents 78ae50c + 12ca32c commit 3a9a3fe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions creusot/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,29 @@ 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_map(|chunk| {
let (first, rest) = chunk.split_once("=")?;
if first != "CREUSOT_ARG" {
None
} else {
Some(rest)
}
})
.collect();

cmd.args(&[
"--stdout",
"--export-metadata=false",
"--span-mode=relative",
// 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)),
Expand Down

0 comments on commit 3a9a3fe

Please sign in to comment.