mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 21:28:21 +00:00
Fix integration tests
This commit is contained in:
@@ -43,8 +43,10 @@ pub use {
|
|||||||
#[cfg(any(feature = "static-artifact-create", feature = "wasmer-artifact-create"))]
|
#[cfg(any(feature = "static-artifact-create", feature = "wasmer-artifact-create"))]
|
||||||
pub enum ObjectFormat {
|
pub enum ObjectFormat {
|
||||||
/// Serialize the entire module into an object file.
|
/// Serialize the entire module into an object file.
|
||||||
|
#[clap(name = "serialized")]
|
||||||
Serialized,
|
Serialized,
|
||||||
/// Serialize only the module metadata into an object file and emit functions as symbols.
|
/// Serialize only the module metadata into an object file and emit functions as symbols.
|
||||||
|
#[clap(name = "symbols")]
|
||||||
Symbols,
|
Symbols,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ impl CreateExe {
|
|||||||
let input_path = starting_cd.join(&path);
|
let input_path = starting_cd.join(&path);
|
||||||
let output_path = starting_cd.join(&self.output);
|
let output_path = starting_cd.join(&self.output);
|
||||||
let object_format = self.object_format.unwrap_or_default();
|
let object_format = self.object_format.unwrap_or_default();
|
||||||
|
|
||||||
let cross_compilation =
|
let cross_compilation =
|
||||||
utils::get_cross_compile_setup(&mut cc, &target_triple, &starting_cd, &object_format)?;
|
utils::get_cross_compile_setup(&mut cc, &target_triple, &starting_cd, &object_format)?;
|
||||||
|
|
||||||
@@ -182,14 +183,15 @@ impl CreateExe {
|
|||||||
return Err(anyhow::anyhow!("library path does not exist"));
|
return Err(anyhow::anyhow!("library path does not exist"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(pirita) = WebCMmap::parse(input_path.clone(), &ParseOptions::default()) {
|
let temp = tempfile::tempdir();
|
||||||
// pirita file
|
|
||||||
let temp = tempdir::TempDir::new("pirita-compile")?;
|
|
||||||
let tempdir = match self.debug_dir.as_ref() {
|
let tempdir = match self.debug_dir.as_ref() {
|
||||||
Some(s) => s.clone(),
|
Some(s) => s.clone(),
|
||||||
None => temp.path().to_path_buf(),
|
None => temp?.path().to_path_buf(),
|
||||||
};
|
};
|
||||||
std::fs::create_dir_all(&tempdir)?;
|
std::fs::create_dir_all(&tempdir)?;
|
||||||
|
|
||||||
|
if let Ok(pirita) = WebCMmap::parse(input_path.clone(), &ParseOptions::default()) {
|
||||||
|
// pirita file
|
||||||
let atoms = compile_pirita_into_directory(
|
let atoms = compile_pirita_into_directory(
|
||||||
&pirita,
|
&pirita,
|
||||||
&tempdir,
|
&tempdir,
|
||||||
@@ -215,12 +217,6 @@ impl CreateExe {
|
|||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
// wasm file
|
// wasm file
|
||||||
let temp = tempdir::TempDir::new("pirita-compile")?;
|
|
||||||
let tempdir = match self.debug_dir.as_ref() {
|
|
||||||
Some(s) => s.clone(),
|
|
||||||
None => temp.path().to_path_buf(),
|
|
||||||
};
|
|
||||||
std::fs::create_dir_all(&tempdir)?;
|
|
||||||
let atoms = prepare_directory_from_single_wasm_file(
|
let atoms = prepare_directory_from_single_wasm_file(
|
||||||
&input_path,
|
&input_path,
|
||||||
&tempdir,
|
&tempdir,
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ impl CreateObj {
|
|||||||
let target_triple = self.target_triple.clone().unwrap_or_else(Triple::host);
|
let target_triple = self.target_triple.clone().unwrap_or_else(Triple::host);
|
||||||
let starting_cd = env::current_dir()?;
|
let starting_cd = env::current_dir()?;
|
||||||
let input_path = starting_cd.join(&path);
|
let input_path = starting_cd.join(&path);
|
||||||
let temp_dir = tempdir::TempDir::new("create-obj-intermediate")?;
|
let temp_dir = tempfile::tempdir();
|
||||||
let output_directory_path = match self.debug_dir.as_ref() {
|
let output_directory_path = match self.debug_dir.as_ref() {
|
||||||
Some(s) => s.as_path(),
|
Some(s) => s.clone(),
|
||||||
None => temp_dir.path(),
|
None => temp_dir?.path().to_path_buf(),
|
||||||
};
|
};
|
||||||
std::fs::create_dir_all(&output_directory_path)?;
|
std::fs::create_dir_all(&output_directory_path)?;
|
||||||
let object_format = self.object_format.unwrap_or_default();
|
let object_format = self.object_format.unwrap_or_default();
|
||||||
@@ -102,7 +102,7 @@ impl CreateObj {
|
|||||||
if let Ok(pirita) = WebCMmap::parse(input_path.clone(), &ParseOptions::default()) {
|
if let Ok(pirita) = WebCMmap::parse(input_path.clone(), &ParseOptions::default()) {
|
||||||
crate::commands::create_exe::compile_pirita_into_directory(
|
crate::commands::create_exe::compile_pirita_into_directory(
|
||||||
&pirita,
|
&pirita,
|
||||||
output_directory_path,
|
&output_directory_path,
|
||||||
&self.compiler,
|
&self.compiler,
|
||||||
&self.cpu_features,
|
&self.cpu_features,
|
||||||
&target_triple,
|
&target_triple,
|
||||||
@@ -114,7 +114,7 @@ impl CreateObj {
|
|||||||
} else {
|
} else {
|
||||||
crate::commands::create_exe::prepare_directory_from_single_wasm_file(
|
crate::commands::create_exe::prepare_directory_from_single_wasm_file(
|
||||||
&input_path,
|
&input_path,
|
||||||
output_directory_path,
|
&output_directory_path,
|
||||||
&self.compiler,
|
&self.compiler,
|
||||||
&target_triple,
|
&target_triple,
|
||||||
&self.cpu_features,
|
&self.cpu_features,
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ impl WasmerCreateExe {
|
|||||||
output.args(self.extra_cli_flags.iter());
|
output.args(self.extra_cli_flags.iter());
|
||||||
output.arg("-o");
|
output.arg("-o");
|
||||||
output.arg(&self.native_executable_path);
|
output.arg(&self.native_executable_path);
|
||||||
|
|
||||||
let cmd = format!("{:?}", output);
|
let cmd = format!("{:?}", output);
|
||||||
|
|
||||||
|
println!("(integration-test) running create-exe: {cmd}");
|
||||||
|
|
||||||
let output = output.output()?;
|
let output = output.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
@@ -126,6 +127,8 @@ impl WasmerCreateObj {
|
|||||||
|
|
||||||
let cmd = format!("{:?}", output);
|
let cmd = format!("{:?}", output);
|
||||||
|
|
||||||
|
println!("(integration-test) running create-obj: {cmd}");
|
||||||
|
|
||||||
let output = output.output()?;
|
let output = output.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
@@ -385,7 +388,7 @@ fn create_obj_serialized() -> anyhow::Result<()> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_exe_with_object_input(mut args: Vec<String>) -> anyhow::Result<()> {
|
fn create_exe_with_object_input(args: Vec<String>) -> anyhow::Result<()> {
|
||||||
let temp_dir = tempfile::tempdir()?;
|
let temp_dir = tempfile::tempdir()?;
|
||||||
let operating_dir: PathBuf = temp_dir.path().to_owned();
|
let operating_dir: PathBuf = temp_dir.path().to_owned();
|
||||||
|
|
||||||
@@ -396,15 +399,21 @@ fn create_exe_with_object_input(mut args: Vec<String>) -> anyhow::Result<()> {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let object_path = operating_dir.join("wasm.obj");
|
let object_path = operating_dir.join("wasm.obj");
|
||||||
|
|
||||||
args.push("--prefix".to_string());
|
let mut create_obj_args = args.clone();
|
||||||
args.push("abc123".to_string());
|
create_obj_args.push("--prefix".to_string());
|
||||||
|
create_obj_args.push("abc123".to_string());
|
||||||
|
create_obj_args.push("--debug-dir".to_string());
|
||||||
|
create_obj_args.push(format!(
|
||||||
|
"{}",
|
||||||
|
operating_dir.join("compile-create-obj").display()
|
||||||
|
));
|
||||||
|
|
||||||
WasmerCreateObj {
|
WasmerCreateObj {
|
||||||
current_dir: operating_dir.clone(),
|
current_dir: operating_dir.clone(),
|
||||||
wasm_path: wasm_path.clone(),
|
wasm_path: wasm_path.clone(),
|
||||||
output_object_path: object_path.clone(),
|
output_object_path: object_path.clone(),
|
||||||
compiler: Compiler::Cranelift,
|
compiler: Compiler::Cranelift,
|
||||||
extra_cli_flags: args,
|
extra_cli_flags: create_obj_args,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.run()
|
.run()
|
||||||
@@ -421,15 +430,21 @@ fn create_exe_with_object_input(mut args: Vec<String>) -> anyhow::Result<()> {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let executable_path = operating_dir.join("wasm.exe");
|
let executable_path = operating_dir.join("wasm.exe");
|
||||||
|
|
||||||
|
let mut create_exe_args = args.clone();
|
||||||
|
create_exe_args.push("--precompiled-atom".to_string());
|
||||||
|
create_exe_args.push(format!("qjs:abc123:{}", object_path.display()));
|
||||||
|
create_exe_args.push("--debug-dir".to_string());
|
||||||
|
create_exe_args.push(format!(
|
||||||
|
"{}",
|
||||||
|
operating_dir.join("compile-create-exe").display()
|
||||||
|
));
|
||||||
|
|
||||||
let create_exe_stdout = WasmerCreateExe {
|
let create_exe_stdout = WasmerCreateExe {
|
||||||
current_dir: std::env::current_dir().unwrap(),
|
current_dir: std::env::current_dir().unwrap(),
|
||||||
wasm_path,
|
wasm_path,
|
||||||
native_executable_path: executable_path.clone(),
|
native_executable_path: executable_path.clone(),
|
||||||
compiler: Compiler::Cranelift,
|
compiler: Compiler::Cranelift,
|
||||||
extra_cli_flags: vec![
|
extra_cli_flags: create_exe_args,
|
||||||
"--precompiled-atom".to_string(),
|
|
||||||
format!("qjs:abc123:{}", object_path.display()),
|
|
||||||
],
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.run()
|
.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user