From 5fc3c7424ad697d1df34cd485d567a7972b6beb5 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 30 Apr 2020 18:08:29 +0800 Subject: [PATCH 1/2] ci: add node14 to test matrix --- .github/workflows/linux.yaml | 2 +- .github/workflows/macos.yaml | 2 +- .github/workflows/windows.yaml | 2 +- README.md | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index 516c7854..4d7e3bc9 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - node: ['10', '12', '13'] + node: ['10', '12', '13', '14'] version: - stable - nightly diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index c020d38c..21f76d1f 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - node: ['10', '12', '13'] + node: ['10', '12', '13', '14'] version: - stable - nightly diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 8fa93ca4..3790f2e3 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - node: ['10', '12', '13'] + node: ['10', '12', '13', '14'] version: - stable - nightly diff --git a/README.md b/README.md index 4be6e387..ddebdf48 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ ## NodeJS -| Node10 | Node 12 | Node13 | -| --------- | --------- | --------- | -| ✓ | ✓ | ✓ | +| Node10 | Node 12 | Node13 | Node14 | +| ------ | ------- | ------ | ------ | +| ✓ | ✓ | ✓ | ✓ | A minimal library for building compiled Node add-ons in Rust. From 53f9157342c631592eb2b80b2d12b27d7b749688 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 30 Apr 2020 18:31:47 +0800 Subject: [PATCH 2/2] fix(test_module): avoid oom in test_scripts --- test_module/src/lib.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/test_module/src/lib.rs b/test_module/src/lib.rs index 949625cd..05b3384b 100644 --- a/test_module/src/lib.rs +++ b/test_module/src/lib.rs @@ -5,7 +5,7 @@ extern crate napi_rs_derive; extern crate futures; -use napi::{Any, Env, Error, Object, Result, Status, Value, CallContext}; +use napi::{Any, CallContext, Env, Error, Object, Result, Status, Value}; register_module!(test_module, init); @@ -13,21 +13,13 @@ fn init<'env>( env: &'env Env, exports: &'env mut Value<'env, Object>, ) -> Result>> { - exports.set_named_property( - "testSpawn", - env.create_function("testSpawn", test_spawn)?, - )?; - exports.set_named_property( - "testThrow", - env.create_function("testThrow", test_throw)?, - )?; + exports.set_named_property("testSpawn", env.create_function("testSpawn", test_spawn)?)?; + exports.set_named_property("testThrow", env.create_function("testThrow", test_throw)?)?; Ok(None) } #[js_function] -fn test_spawn<'a>( - ctx: CallContext<'a> -) -> Result> { +fn test_spawn<'a>(ctx: CallContext<'a>) -> Result> { use futures::executor::ThreadPool; use futures::StreamExt; let env = ctx.env; @@ -37,7 +29,7 @@ fn test_spawn<'a>( let (tx, rx) = futures::channel::mpsc::unbounded::(); let fut_values = async move { let fut_tx_result = async move { - (0..100).for_each(|v| { + (0..20).for_each(|v| { tx.unbounded_send(v).expect("Failed to send"); }) }; @@ -60,8 +52,6 @@ fn test_spawn<'a>( } #[js_function] -fn test_throw<'a>( - _ctx: CallContext<'a>, -) -> Result> { +fn test_throw<'a>(_ctx: CallContext<'a>) -> Result> { Err(Error::new(Status::GenericFailure)) }