summaryrefslogtreecommitdiff
path: root/test_napi/tests/napi_tests.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-26 06:40:17 +0200
committerGitHub <noreply@github.com>2023-05-26 10:10:17 +0530
commit512d5337c480a2a2704881d3fe1c40b6e0445cf0 (patch)
tree99b03358883223a69f48b2d0e5b9387f3abae517 /test_napi/tests/napi_tests.rs
parent7ae55e75d812edc93251357465f8d49fc2fb5d26 (diff)
fix(napi): clear currently registering module slot (#19249)
This commit fixes problem with loading N-API modules that use the "old" way of registration (using "napi_module_register" API). The slot was not cleared after loading modules, causing subsequent calls that use the new way of registration (using "napi_register_module_v1" API) to try and load the previous module. Ref https://github.com/denoland/deno/issues/16460 --------- Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'test_napi/tests/napi_tests.rs')
-rw-r--r--test_napi/tests/napi_tests.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/test_napi/tests/napi_tests.rs b/test_napi/tests/napi_tests.rs
index 3e3989436..c3ce285e0 100644
--- a/test_napi/tests/napi_tests.rs
+++ b/test_napi/tests/napi_tests.rs
@@ -18,6 +18,35 @@ fn build() {
}
let build_plugin_output = build_plugin.output().unwrap();
assert!(build_plugin_output.status.success());
+
+ // cc module.c -undefined dynamic_lookup -shared -Wl,-no_fixup_chains -dynamic -o module.dylib
+ #[cfg(not(target_os = "windows"))]
+ {
+ let out = if cfg!(target_os = "macos") {
+ "module.dylib"
+ } else {
+ "module.so"
+ };
+
+ let mut cc = Command::new("cc");
+
+ #[cfg(not(target_os = "macos"))]
+ let c_module = cc.arg("module.c").arg("-shared").arg("-o").arg(out);
+
+ #[cfg(target_os = "macos")]
+ let c_module = {
+ cc.arg("module.c")
+ .arg("-undefined")
+ .arg("dynamic_lookup")
+ .arg("-shared")
+ .arg("-Wl,-no_fixup_chains")
+ .arg("-dynamic")
+ .arg("-o")
+ .arg(out)
+ };
+ let c_module_output = c_module.output().unwrap();
+ assert!(c_module_output.status.success());
+ }
}
#[test]