Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
wasm-forge committed Nov 1, 2023
1 parent a102a9f commit 970c804
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ fn parse_arguments(args: &Vec<String>) -> Result<(String, String), anyhow::Error
let default_output_name = String::from("no_wasi.wasm");
let output_wasm = args.get(2).unwrap_or(&default_output_name);

log::info!(
"Processing input file: '{}', writing output into '{}'",
input_wasm,
output_wasm
);

Ok((input_wasm.clone(), output_wasm.clone()))
}

Expand All @@ -343,12 +349,6 @@ fn main() -> anyhow::Result<()> {

let (input_wasm, output_wasm) = parse_arguments(&args)?;

log::info!(
"Processing input file: '{}', writing output into '{}'",
input_wasm,
output_wasm
);

do_wasm_file_processing(Path::new(&input_wasm), Path::new(&output_wasm))?;

Ok(())
Expand Down
15 changes: 15 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ fn test_do_module_replacements() {
(table (;0;) 5 5 funcref)
(elem (;0;) (i32.const 1) func $_wasi_snapshot_preview_fd_write $_wasi_snapshot_preview_random_get )
(memory (export "memory") 1 100)
(data (i32.const 0x0000)
"\65\66\67\68"
)
(func $_start (;6;) (type 0)
i32.const 1
Expand Down Expand Up @@ -327,3 +333,12 @@ fn test_argument_parsing_one_input_with_default_output() {
assert_eq!("input.wasm", input_wasm);
assert_eq!("no_wasi.wasm", output_wasm);
}

#[test]
fn test_empty_input_arguments() {
let args = vec![];

let result = parse_arguments(&args);

assert!(result.is_err());
}

0 comments on commit 970c804

Please sign in to comment.