Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CLI integration tests automatically run the most up-to-date version of the CLI #4020

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,14 @@ required-features = ["backend"]
name = "features"
path = "examples/features.rs"
required-features = ["cranelift"]

# Enable optimizations for a few crates, even for debug builds.
#
# This greatly speeds up debug builds because these crates are extremely slow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is a bit confusing.

Suggested change
# This greatly speeds up debug builds because these crates are extremely slow
# This greatly improves runtime performance of debug builds, because these crates are extremely slow

And yes, I'm perfectly aware who originally wrote that comment, so blame is on me.

# without optimizations.
[profile.dev.package.cranelift-codegen]
opt-level = 2
[profile.dev.package.regalloc2]
opt-level = 2
[profile.dev.package.wasmparser]
opt-level = 2
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -619,18 +619,18 @@ test-wasi-unit:
test-wasi:
$(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- wasi::wasitests

test-integration-cli: build-wasmer build-capi package-capi-headless package distribution
test-integration-cli: build-capi package-capi-headless package distribution
cp ./dist/wasmer.tar.gz ./link.tar.gz
rustup target add wasm32-wasi
WASMER_DIR=`pwd`/package $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner --no-fail-fast -p wasmer-integration-tests-cli -- --nocapture --test-threads=1
WASMER_DIR=`pwd`/package $(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --no-fail-fast -p wasmer-integration-tests-cli -- --nocapture --test-threads=1

# Before running this in the CI, we need to set up link.tar.gz and /cache/wasmer-[target].tar.gz
test-integration-cli-ci:
rustup target add wasm32-wasi
$(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner -p wasmer-integration-tests-cli -- --test-threads=1
$(CARGO_BINARY) test $(CARGO_TARGET_FLAG) -p wasmer-integration-tests-cli -- --test-threads=1

test-integration-ios:
$(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner -p wasmer-integration-tests-ios
$(CARGO_BINARY) test $(CARGO_TARGET_FLAG) -p wasmer-integration-tests-ios

generate-wasi-tests:
# Uncomment the following for installing the toolchain
Expand Down
6 changes: 1 addition & 5 deletions tests/integration/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,4 @@ tar = "0.4.38"
flate2 = "1.0.24"
dirs = "4.0.0"
derivative = { version = "^2" }

[features]
default = ["webc_runner"]
webc_runner = []
debug = []
wasmer-cli = { path = "../../../lib/cli", features = ["cranelift", "compiler"] }
82 changes: 1 addition & 81 deletions tests/integration/cli/src/assets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::env;
use std::path::PathBuf;
use std::{env, path::PathBuf};

pub const C_ASSET_PATH: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
Expand All @@ -9,16 +8,6 @@ pub const ASSET_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../test

pub const WASMER_INCLUDE_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../lib/c-api/");

#[cfg(feature = "debug")]
pub const WASMER_TARGET_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../target/debug/");
#[cfg(feature = "debug")]
pub const WASMER_TARGET_PATH_2: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../target/",
env!("CARGO_BUILD_TARGET"),
"/debug/"
);

/* env var TARGET is set by tests/integration/cli/build.rs on compile-time */

#[cfg(not(feature = "debug"))]
Expand Down Expand Up @@ -53,75 +42,6 @@ pub fn get_libwasmer_path() -> PathBuf {
ret
}

/// Get the path to the `wasmer` executable to be used in this test.
pub fn get_wasmer_path() -> PathBuf {
let mut ret = PathBuf::from(
env::var("WASMER_TEST_WASMER_PATH")
.unwrap_or_else(|_| format!("{}wasmer", WASMER_TARGET_PATH)),
);
if !ret.exists() {
ret = PathBuf::from(format!("{}wasmer", WASMER_TARGET_PATH_2));
}
if !ret.exists() {
ret = match get_repo_root_path() {
Some(s) => {
#[cfg(target_os = "windows")]
{
s.join("target").join("release").join("wasmer.exe")
}
#[cfg(not(target_os = "windows"))]
{
s.join("target").join("release").join("wasmer")
}
}
None => {
panic!("Could not find wasmer executable path! {:?}", ret);
}
};
}

if !ret.exists() {
ret = match get_repo_root_path() {
Some(s) => {
#[cfg(target_os = "windows")]
{
s.join("target")
.join(target_lexicon::HOST.to_string())
.join("release")
.join("wasmer.exe")
}
#[cfg(not(target_os = "windows"))]
{
s.join("target")
.join(target_lexicon::HOST.to_string())
.join("release")
.join("wasmer")
}
}
None => {
panic!("Could not find wasmer executable path! {:?}", ret);
}
};
}

if !ret.exists() {
if let Some(root) = get_repo_root_path() {
use std::process::Stdio;
let _ = std::process::Command::new("ls")
.arg(root.join("target"))
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.stdin(Stdio::null())
.output();
}
panic!(
"cannot find wasmer / wasmer.exe for integration test at '{}'!",
ret.display()
);
}
ret
}

pub fn get_repo_root_path() -> Option<PathBuf> {
let mut current_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
let mut counter = 0;
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/cli/src/bin/wasmer-cli-shim.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! A shim that makes the `wasmer` CLI available to integration tests via the
//! [`$CARGO_BIN_EXE_wasmer-cli-shim`][var] environment variable.
//!
//! [var]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates

fn main() {
wasmer_cli::cli::wasmer_main();
}
Loading