Skip to content

Commit

Permalink
Fuzzing: Log the error we get for an input that errored after being r…
Browse files Browse the repository at this point in the history
…eprinted (#172)
  • Loading branch information
jasikpark authored Jul 10, 2024
1 parent 245d530 commit d8d5656
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions parser/fuzz/fuzz_targets/module_roundtrip_naive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ fn do_fuzz(data: &str) -> Corpus {

let output1 = module1.to_string(&to_string_options);

let Ok(module2) = Module::from_string(output1.to_owned(), parse_options) else {
panic!("input: `{input}`\noutput1: `{output1}`\n\nThis parse should not error because it was just parsed above");
let module2 = match Module::from_string(output1.to_owned(), parse_options) {
Ok(module2) => module2,
Err(error) => {
panic!("input: `{input}`\noutput1: `{output1}`\n\nThis parse should not error because it was just parsed above. \nerror: `{:?}`", error);
}
};

let output2 = module2.to_string(&to_string_options);
Expand Down
7 changes: 5 additions & 2 deletions parser/fuzz/fuzz_targets/module_roundtrip_structured.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ fn do_fuzz(data: common::FuzzSource) -> Corpus {

let output1 = module1.to_string(&to_string_options);

let Ok(module2) = Module::from_string(output1.to_owned(), parse_options) else {
panic!("input: `{input}`\noutput1: `{output1}`\n\nThis parse should not error because it was just parsed above");
let module2 = match Module::from_string(output1.to_owned(), parse_options) {
Ok(module2) => module2,
Err(error) => {
panic!("input: `{input}`\noutput1: `{output1}`\n\nThis parse should not error because it was just parsed above. \nerror: `{:?}`", error);
}
};

let output2 = module2.to_string(&to_string_options);
Expand Down

0 comments on commit d8d5656

Please sign in to comment.