ci: pass tests on the freebsd platform

This commit is contained in:
LongYinan 2020-10-13 22:58:29 +08:00
parent 97d5311b10
commit b651be1bec
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
3 changed files with 31 additions and 7 deletions

View file

@ -7,7 +7,7 @@ task:
DEBUG: 'napi:*'
setup_script:
- pkg update
- pkg install -y -f curl node yarn npm libnghttp2
- pkg install -y -f curl node yarn npm libnghttp2 llvm
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh -y --profile minimal --default-toolchain stable
- . $HOME/.cargo/env
@ -20,7 +20,7 @@ task:
yarn --version
test_script:
- . $HOME/.cargo/env
- yarn install --frozen-lockfile --registry https://registry.npmjs.org
- yarn install --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org
- yarn build
- cargo test -p napi-sys --lib -- --nocapture
- yarn build:test

View file

@ -1,7 +1,15 @@
import { platform } from 'os'
const platformName = platform()
const configuration = {
extensions: ['ts', 'tsx'],
files: ['test_module/__test__/**/*.spec.ts'],
require: ['@swc-node/register'],
require: [
platformName === 'freebsd'
? 'ts-node/register/transpile-only'
: '@swc-node/register',
],
environmentVariables: {
SWC_NODE_PROJECT: './test_module/tsconfig.json',
},

View file

@ -28,21 +28,37 @@ fn main() {
);
}
if node_major_version < 10 {
if node_major_version < 8 && node_version.minor < 9 {
panic!("node version is too low")
}
let node_include_path = find_node_include_path(node_full_version.trim_end());
let node_include_path_buf = find_node_include_path(node_full_version.trim_end());
let node_include_path = match env::var("NODE_INCLUDE_PATH") {
Ok(node_include_path) => node_include_path,
Err(_) => node_include_path_buf.to_str().unwrap().to_owned(),
};
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let mut sys_bindings_path = PathBuf::from("src");
sys_bindings_path.push("bindings.h");
bindgen::Builder::default()
let mut bindgen_builder = bindgen::Builder::default()
.derive_default(true)
.header(sys_bindings_path.to_str().unwrap().to_owned())
.clang_arg(String::from("-I") + node_include_path.to_str().unwrap())
.clang_arg(format!("-I{}", node_include_path));
if let Ok(uv_include_path) = env::var("UV_INCLUDE_PATH") {
bindgen_builder = bindgen_builder.clang_arg(format!("-I{}", uv_include_path));
} else if cfg!(target_os = "freebsd") {
bindgen_builder = bindgen_builder.clang_arg(format!(
"-I{}",
node_include_path_buf.parent().unwrap().to_str().unwrap()
));
}
bindgen_builder
.rustified_enum("(napi_|uv_).+")
.whitelist_function("(napi_|uv_|extras_).+")
.whitelist_type("(napi_|uv_|extras_).+")