From 8688084afee41207026cedc96d960257227c7476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=BCtt?= Date: Mon, 30 Jan 2023 08:44:54 +0100 Subject: [PATCH 1/2] Fix make-test-integration CLI producing files when running locally --- tests/integration/cli/tests/run.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/cli/tests/run.rs b/tests/integration/cli/tests/run.rs index 1f1d4e8e3e1..79d10290e93 100644 --- a/tests/integration/cli/tests/run.rs +++ b/tests/integration/cli/tests/run.rs @@ -164,8 +164,10 @@ fn test_cross_compile_python_windows() -> anyhow::Result<()> { output.arg("-o"); output.arg(python_wasmer_path.clone()); output.arg(format!("--{c}")); - output.arg("--debug-dir"); - output.arg(format!("{t}-{c}")); + if std::env::var("GITHUB_TOKEN").is_ok() { + output.arg("--debug-dir"); + output.arg(format!("{t}-{c}")); + } if t.contains("x86_64") && *c == "singlepass" { output.arg("-m"); From 690f4070a24f8f7df0e826cb0e67f44f52ae9679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=BCtt?= Date: Mon, 30 Jan 2023 18:44:41 +0100 Subject: [PATCH 2/2] Fix WASMER_DIR error --- Cargo.lock | 1 + tests/integration/cli/Cargo.toml | 1 + tests/integration/cli/tests/config.rs | 45 ++++++++++++++++++++------- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ce7ebaecdd..54ae555a740 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4554,6 +4554,7 @@ name = "wasmer-integration-tests-cli" version = "3.2.0-alpha.1" dependencies = [ "anyhow", + "dirs", "flate2", "object 0.30.3", "pretty_assertions", diff --git a/tests/integration/cli/Cargo.toml b/tests/integration/cli/Cargo.toml index 0b3b9a17cbd..153d56beb64 100644 --- a/tests/integration/cli/Cargo.toml +++ b/tests/integration/cli/Cargo.toml @@ -19,6 +19,7 @@ tempfile = "3" target-lexicon = "0.12.5" tar = "0.4.38" flate2 = "1.0.24" +dirs = "4.0.0" [features] default = ["webc_runner"] diff --git a/tests/integration/cli/tests/config.rs b/tests/integration/cli/tests/config.rs index f680146f658..21e9f58b2e1 100644 --- a/tests/integration/cli/tests/config.rs +++ b/tests/integration/cli/tests/config.rs @@ -1,11 +1,34 @@ -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::Command; -use wasmer_integration_tests_cli::get_wasmer_path; +use wasmer_integration_tests_cli::{get_repo_root_path, get_wasmer_path}; + +fn get_wasmer_dir() -> Result { + if let Ok(s) = std::env::var("WASMER_DIR") { + Ok(Path::new(&s).to_path_buf()) + } else if let Some(root_dir) = get_repo_root_path().and_then(|root| { + if root.join("package").exists() { + Some(root.join("package")) + } else { + None + } + }) { + Ok(root_dir) + } else { + let home_dir = dirs::home_dir() + .ok_or(anyhow::anyhow!("no home dir"))? + .join(".wasmer"); + if home_dir.exists() { + Ok(home_dir) + } else { + Err(anyhow::anyhow!("no .wasmer home dir")) + } + } +} #[test] fn wasmer_config_multiget() -> anyhow::Result<()> { - let bin_path = Path::new(env!("WASMER_DIR")).join("bin"); - let include_path = Path::new(env!("WASMER_DIR")).join("include"); + let bin_path = get_wasmer_dir()?.join("bin"); + let include_path = get_wasmer_dir()?.join("include"); let bin = format!("{}", bin_path.display()); let include = format!("-I{}", include_path.display()); @@ -66,7 +89,7 @@ fn config_works() -> anyhow::Result<()> { .arg("--bindir") .output()?; - let bin_path = Path::new(env!("WASMER_DIR")).join("bin"); + let bin_path = get_wasmer_dir()?.join("bin"); assert_eq!( String::from_utf8(bindir.stdout).unwrap(), format!("{}\n", bin_path.display()) @@ -77,7 +100,7 @@ fn config_works() -> anyhow::Result<()> { .arg("--cflags") .output()?; - let include_path = Path::new(env!("WASMER_DIR")).join("include"); + let include_path = get_wasmer_dir()?.join("include"); assert_eq!( String::from_utf8(bindir.stdout).unwrap(), format!("-I{}\n", include_path.display()) @@ -88,7 +111,7 @@ fn config_works() -> anyhow::Result<()> { .arg("--includedir") .output()?; - let include_path = Path::new(env!("WASMER_DIR")).join("include"); + let include_path = get_wasmer_dir()?.join("include"); assert_eq!( String::from_utf8(bindir.stdout).unwrap(), format!("{}\n", include_path.display()) @@ -99,7 +122,7 @@ fn config_works() -> anyhow::Result<()> { .arg("--libdir") .output()?; - let lib_path = Path::new(env!("WASMER_DIR")).join("lib"); + let lib_path = get_wasmer_dir()?.join("lib"); assert_eq!( String::from_utf8(bindir.stdout).unwrap(), format!("{}\n", lib_path.display()) @@ -110,7 +133,7 @@ fn config_works() -> anyhow::Result<()> { .arg("--libs") .output()?; - let lib_path = Path::new(env!("WASMER_DIR")).join("lib"); + let lib_path = get_wasmer_dir()?.join("lib"); assert_eq!( String::from_utf8(bindir.stdout).unwrap(), format!("-L{} -lwasmer\n", lib_path.display()) @@ -121,7 +144,7 @@ fn config_works() -> anyhow::Result<()> { .arg("--prefix") .output()?; - let wasmer_dir = Path::new(env!("WASMER_DIR")); + let wasmer_dir = get_wasmer_dir()?; assert_eq!( String::from_utf8(bindir.stdout).unwrap(), format!("{}\n", wasmer_dir.display()) @@ -163,7 +186,7 @@ fn config_works() -> anyhow::Result<()> { .arg("--config-path") .output()?; - let config_path = Path::new(env!("WASMER_DIR")).join("wasmer.toml"); + let config_path = get_wasmer_dir()?.join("wasmer.toml"); assert_eq!( String::from_utf8_lossy(&output.stdout), format!("{}\n", config_path.display())