Replace more miscellaenous read_wasm utilities with wat::parse_file. (#601)
This commit is contained in:
committed by
Alex Crichton
parent
7d7360b32d
commit
58dd4c6c88
@@ -22,3 +22,4 @@ pretty_env_logger = "0.3.0"
|
||||
tempfile = "3.1.0"
|
||||
os_pipe = "0.9"
|
||||
anyhow = "1.0.19"
|
||||
wat = "1.0.2"
|
||||
|
||||
@@ -127,7 +127,7 @@ fn write_testsuite_tests(out: &mut File, dir_entry: DirEntry, testsuite: &str) -
|
||||
" let path = std::path::Path::new(r#\"{}\"#);",
|
||||
path.display()
|
||||
)?;
|
||||
writeln!(out, " let data = utils::read_wasm(path)?;")?;
|
||||
writeln!(out, " let data = wat::parse_file(path)?;")?;
|
||||
writeln!(
|
||||
out,
|
||||
" let bin_name = utils::extract_exec_name_from_path(path)?;"
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use tempfile::{Builder, TempDir};
|
||||
|
||||
pub fn read_wasm(path: &Path) -> anyhow::Result<Vec<u8>> {
|
||||
let data = fs::read(path)?;
|
||||
if data.starts_with(&[b'\0', b'a', b's', b'm']) {
|
||||
Ok(data)
|
||||
} else {
|
||||
anyhow::bail!("Invalid Wasm file encountered")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prepare_workspace(exe_name: &str) -> anyhow::Result<TempDir> {
|
||||
let prefix = format!("wasi_common_{}", exe_name);
|
||||
let tempdir = Builder::new().prefix(&prefix).tempdir()?;
|
||||
|
||||
Reference in New Issue
Block a user