-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathintegration.rs
51 lines (44 loc) · 1.16 KB
/
integration.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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"),
)
}