swc/crates/swc_core/tests/integration.rs
OJ Kwon 56bdacc72d
feat(plugin/runner): Update wasmer to v3 (#7197)
**Description:**

This PR reattempts https://github.com/swc-project/swc/pull/5456.

Most of the changes are for the breaking changes of wasmer@3, as well as enabling rkyv's strict mode (https://github.com/swc-project/swc/pull/6922). This could not be seperated since wasmer@3 enables strict mode by default without a way to turn it off.

There are a couple of changes worth noting:

- Disabling in-memory module lookup: https://github.com/swc-project/swc/pull/7197/files#diff-3bda5def6ce2b7553c3b3a5ad241c0bdb7021e67b7de1e594df4cd5a54d403b3R154-R159
- Disabling plugin_runner in bindings_wasm: https://github.com/swc-project/swc/pull/7197/files#diff-dc3ded556a1fd709a129acd588e5eda651b842c6acc3f5340d40088a1f927facR310-R312
- Skipping plugin compat test: https://github.com/swc-project/swc/pull/7197/files#diff-531197dfcefba05faca53f0cf442ecc2dc6b59d5ead01979f5ffb912aa36249aR64-R66
2023-04-10 03:40:25 +00:00

52 lines
1.2 KiB
Rust

use std::{
env,
path::{Path, PathBuf},
process::{Command, Stdio},
};
use anyhow::{anyhow, Error};
fn build_fixture_binary(dir: &Path, target: Option<&str>) -> Result<(), Error> {
let mut args = vec!["build".to_string()];
if let Some(target) = target {
args.push(format!("--target={}", target));
};
let mut cmd = Command::new("cargo");
cmd.current_dir(dir);
cmd.args(args).stderr(Stdio::inherit());
cmd.output()?;
if !cmd
.status()
.expect("Exit code should be available")
.success()
{
return Err(anyhow!("Failed to build binary"));
}
Ok(())
}
#[test]
fn swc_core_napi_integration_build() -> Result<(), Error> {
build_fixture_binary(
&PathBuf::from(env::var("CARGO_MANIFEST_DIR")?)
.join("tests")
.join("fixture")
.join("stub_napi"),
None,
)
}
#[test]
fn swc_core_wasm_integration_build() -> Result<(), Error> {
build_fixture_binary(
&PathBuf::from(env::var("CARGO_MANIFEST_DIR")?)
.join("tests")
.join("fixture")
.join("stub_wasm"),
Some("wasm32-unknown-unknown"),
)
}