2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2022-10-05 10:06:44 -04:00
|
|
|
|
|
|
|
use std::process::Command;
|
|
|
|
use test_util::deno_cmd;
|
|
|
|
|
|
|
|
#[cfg(debug_assertions)]
|
|
|
|
const BUILD_VARIANT: &str = "debug";
|
|
|
|
|
|
|
|
#[cfg(not(debug_assertions))]
|
|
|
|
const BUILD_VARIANT: &str = "release";
|
|
|
|
|
|
|
|
fn build() {
|
|
|
|
let mut build_plugin_base = Command::new("cargo");
|
|
|
|
let mut build_plugin =
|
|
|
|
build_plugin_base.arg("build").arg("-p").arg("test_napi");
|
|
|
|
if BUILD_VARIANT == "release" {
|
|
|
|
build_plugin = build_plugin.arg("--release");
|
|
|
|
}
|
|
|
|
let build_plugin_output = build_plugin.output().unwrap();
|
|
|
|
assert!(build_plugin_output.status.success());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn napi_tests() {
|
|
|
|
build();
|
|
|
|
|
|
|
|
let output = deno_cmd()
|
|
|
|
.current_dir(test_util::napi_tests_path())
|
2023-05-18 06:49:56 -04:00
|
|
|
.env("RUST_BACKTRACE", "1")
|
2022-10-05 10:06:44 -04:00
|
|
|
.arg("test")
|
|
|
|
.arg("--allow-read")
|
|
|
|
.arg("--allow-env")
|
|
|
|
.arg("--allow-ffi")
|
2023-01-10 13:15:10 -05:00
|
|
|
.arg("--allow-run")
|
2022-10-05 10:06:44 -04:00
|
|
|
.spawn()
|
|
|
|
.unwrap()
|
|
|
|
.wait_with_output()
|
|
|
|
.unwrap();
|
|
|
|
let stdout = std::str::from_utf8(&output.stdout).unwrap();
|
|
|
|
let stderr = std::str::from_utf8(&output.stderr).unwrap();
|
2023-01-10 13:15:10 -05:00
|
|
|
|
2022-10-05 10:06:44 -04:00
|
|
|
if !output.status.success() {
|
2023-05-18 06:49:56 -04:00
|
|
|
eprintln!("exit code {:?}", output.status.code());
|
2023-01-27 10:43:16 -05:00
|
|
|
println!("stdout {stdout}");
|
|
|
|
println!("stderr {stderr}");
|
2022-10-05 10:06:44 -04:00
|
|
|
}
|
|
|
|
assert!(output.status.success());
|
|
|
|
}
|