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

Basic N-API tests #449

Merged
merged 3 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ members = [
"test/static",
"test/electron/native",
"test/dynamic/native",
"test/napi/native"
]
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,17 @@ mod tests {
run("cargo package --allow-dirty", &test_package);
}
}

#[test]
fn napi_test() {
let _guard = TEST_MUTEX.lock();

log("napi_test");

cli_setup();

let test_napi = project_root().join("test").join("napi");
run("npm install", &test_napi);
run("npm test", &test_napi);
}
}
6 changes: 6 additions & 0 deletions test/napi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
native/target
native/index.node
native/artifacts.json
**/*~
**/node_modules
**/.DS_Store
3 changes: 3 additions & 0 deletions test/napi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# napi

Acceptance test suite for Neon with N-API backend
8 changes: 8 additions & 0 deletions test/napi/lib/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var addon = require('../native');
var assert = require('chai').assert;

describe('hello', function() {
it('should load the module without crashing', function () {
assert.isTrue(true, "loaded native module without crashing");
});
});
21 changes: 21 additions & 0 deletions test/napi/native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "napi"
version = "0.1.0"
authors = ["The Neon Community <[email protected]>"]
license = "MIT"
build = "build.rs"
exclude = ["artifacts.json", "index.node"]
edition = "2018"

[lib]
name = "napi"
crate-type = ["cdylib"]

[build-dependencies]
neon-build = {version = "*", path = "../../../crates/neon-build"}

[dependencies.neon]
version = "*"
path = "../../../"
default-features = false
features = ["napi-runtime"]
7 changes: 7 additions & 0 deletions test/napi/native/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extern crate neon_build;

fn main() {
neon_build::setup(); // must be called in build.rs

// add project-specific build logic here...
}
3 changes: 3 additions & 0 deletions test/napi/native/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use neon::prelude::*;

register_module!(_, { });
Loading