Skip to content

Instantly share code, notes, and snippets.

@dherman
Created September 16, 2022 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dherman/481036ff5a0f51b8f824234d09293f53 to your computer and use it in GitHub Desktop.
Save dherman/481036ff5a0f51b8f824234d09293f53 to your computer and use it in GitHub Desktop.
dherman@dherman-mn2 neon % npm test
> test
> npm run test:rust && npm run test:js
> test:rust
> cargo neon-test
Compiling neon v1.0.0-alpha.1 (/Users/dherman/Sources/neon/crates/neon)
Compiling electron-tests v0.1.0 (/Users/dherman/Sources/neon/test/electron)
Compiling napi-tests v0.1.0 (/Users/dherman/Sources/neon/test/napi)
Finished test [unoptimized + debuginfo] target(s) in 7.25s
Running unittests src/lib.rs (target/debug/deps/electron_tests-8b0d2f0b3ce5c43d)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running unittests src/lib.rs (target/debug/deps/napi_tests-abac05b78faeeedb)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running unittests src/lib.rs (target/debug/deps/neon-3d5673fed701f528)
running 3 tests
test types_impl::buffer::lock::tests::test_overlapping_borrows ... ok
test types_impl::buffer::lock::tests::test_nonoverlapping_borrows ... ok
test types_impl::buffer::lock::tests::test_overlapping_immutable_borrows ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running unittests src/lib.rs (target/debug/deps/neon_macros-c4af9b7dc7fd5b44)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests neon
running 52 tests
test src/lib.rs - (line 46) - compile ... ok
test src/context/mod.rs - context::Context::boxed (line 411) ... ok
test src/context/mod.rs - context (line 48) ... ok
test src/handle/mod.rs - handle (line 34) ... ok
test src/event/mod.rs - event (line 31) ... ok
test src/context/mod.rs - context (line 16) ... ok
test src/event/channel.rs - event::channel::Channel (line 59) ... ok
test src/context/mod.rs - context (line 80) ... ok
test src/handle/mod.rs - handle::Handle::is_a (line 162) - compile ... ok
test src/event/task.rs - event::task::TaskBuilder (line 17) ... ok
test src/lib.rs - (line 64) ... ok
test src/context/mod.rs - context (line 27) ... ok
test src/context/mod.rs - context::Context::task (line 488) ... ok
test src/handle/root.rs - handle::root::Root<T>::clone (line 110) ... ok
test src/handle/mod.rs - handle (line 19) ... ok
test src/event/mod.rs - event (line 61) ... ok
test src/result/mod.rs - result (line 25) ... ok
test src/thread/mod.rs - thread (line 11) ... ok
test src/object/mod.rs - object (line 17) ... ok
test src/thread/mod.rs - thread (line 61) ... ok
test src/types_docs.rs - types_docs::exports (line 30) ... ok
test src/thread/mod.rs - thread (line 34) ... ok
test src/types_docs.rs - types_docs::exports (line 42) ... ok
test src/types_impl/boxed.rs - types_impl::boxed::Finalize (line 292) ... ok
test src/context/mod.rs - context::Context::promise (line 465) ... ok
test src/types_impl/boxed.rs - types_impl::boxed::JsBox (line 93) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::Handle::region (line 254) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsTypedArray<T>::len (line 705) ... ignored
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsArrayBuffer (line 188) ... ok
test src/types_impl/boxed.rs - types_impl::boxed::JsBox (line 57) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsFloat32Array (line 800) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsBigUint64Array (line 824) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsBigInt64Array (line 816) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsInt32Array (line 798) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsFloat64Array (line 808) ... ok
test src/types_impl/buffer/mod.rs - types_impl::buffer::TypedArray (line 35) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsBuffer (line 32) ... ok
test src/types_impl/buffer/mod.rs - types_impl::buffer::Region (line 207) ... ok
test src/types_impl/boxed.rs - types_impl::boxed::JsBox (line 71) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsInt16Array (line 796) ... ok
test src/types_impl/boxed.rs - types_impl::boxed::Finalize (line 302) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsInt8Array (line 787) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsTypedArray (line 408) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsUint16Array (line 797) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsUint32Array (line 799) ... ok
test src/types_impl/buffer/types.rs - types_impl::buffer::types::JsUint8Array (line 788) ... ok
test src/types_impl/function/mod.rs - types_impl::function::CallOptions (line 18) ... ok
test src/types_impl/function/mod.rs - types_impl::function::ConstructOptions (line 77) ... ok
test src/types_impl/mod.rs - types_impl::JsFunction (line 596) ... ok
test src/types_impl/mod.rs - types_impl::JsFunction (line 617) ... ok
test src/types_impl/mod.rs - types_impl::JsFunction (line 639) ... ok
test src/types_impl/promise.rs - types_impl::promise::Deferred::settle_with (line 261) ... ok
test result: ok. 51 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 10.96s
Doc-tests neon-macros
running 1 test
test src/lib.rs - main (line 10) ... ignored
test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s
> test:js
> npm test --workspaces --if-present
> cargo-cp-artifact@0.1.7 test
> mocha test
Argument Parsing
✔ throws on invalid artifact type
✔ npm must have an environment variable
✔ must provide a command
✔ cannot provide invalid option
✔ should be able to use --artifact
✔ should be able to use --npm
✔ should be able to use short-hand for crate type with -a
✔ should be able to use short-hand for crate type with -n
✔ should remove namespace from package name
✔ should be able to provide multiple artifacts
10 passing (8ms)
> create-neon@0.2.0 pretest
> npm run build
> create-neon@0.2.0 build
> tsc && cp -r data/templates dist/data
> create-neon@0.2.0 test
> mocha
Command-line argument validation
✔ requires an argument
✔ fails if the directory already exists
Project creation
✔ succeeds with all default answers (1162ms)
✔ handles quotation marks in author and description (1153ms)
4 passing (2s)
> electron-tests@0.1.0 test
> playwright test
Running 1 test using 1 worker
✓ main.test.js:9:1 › greeting (1s)
1 passed (2s)
> napi-tests@0.1.0 test
> mocha --v8-expose-gc --timeout 5000 --recursive lib
JsArray
✔ return a JsArray built in Rust
✔ return a JsArray with a number at index 0
✔ return a JsArray with an string at index 0
✔ can read from a JsArray
✔ returns undefined when accessing outside JsArray bounds
boxed
✔ can call methods
✔ can call methods wrapped in a RefCell
✔ can mutate with ref cell
thread '<unnamed>' panicked at 'already borrowed: BorrowMutError', test/napi/src/js/boxed.rs:67:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
✔ should dynamically check borrowing rules
✔ should type check externals
✔ should type check dynamic type
coercions
✔ can stringify
JsDate
✔ should create a date
✔ should create date from time
✔ should check if date is valid
✔ should try new date
✔ should try new lossy date
✔ should handle nan dates
✔ should check if date is invalid
✔ should get date value
errors
✔ should be able to create an error
✔ should be able to create a type error
✔ should be able to create a range error
✔ should be able to throw an error
✔ should be able to stringify a downcast error
JsFunction
✔ return a JsFunction built in Rust
✔ return a JsFunction built in Rust that implements x => x + 1
✔ call a JsFunction built in JS that implements x => x + 1
✔ call a JsFunction built in JS with call_with
✔ call a JsFunction with zero args
✔ call a JsFunction with one arg
✔ call a JsFunction with two args
✔ call a JsFunction with three args
✔ call a JsFunction with four args
✔ call a JsFunction with a custom this
✔ call a JsFunction with the default this
✔ exec a JsFunction with the default this
✔ call a JsFunction with a heterogeneously typed tuple
✔ new a JsFunction
✔ new a JsFunction with construct_with
✔ new a JsFunction with construct_with to create an array
✔ got two parameters, a string and a number
thread '<unnamed>' panicked at 'zomg', test/napi/src/js/functions.rs:148:5
✔ converts a Rust panic to a throw in a function
thread '<unnamed>' panicked at 'this should override the RangeError', test/napi/src/js/functions.rs:154:5
✔ lets panic override a throw
✔ computes the right number of arguments
✔ gets the right `this`-value
✔ can manipulate an object `this` binding
✔ implicitly gets global
✔ exposes an argument via arguments_opt iff it is there
✔ correctly casts an argument via cx.arguments
✔ executes a scoped computation
✔ computes a value in a scoped computation
✔ catches an exception with cx.try_catch
✔ gets a regular value with cx.try_catch
✔ can return Rust type from cx.try_catch
✔ distinguishes calls from constructs
✔ should be able to call a function from a closure
✔ should drop function when going out of scope
Futures
Channel
✔ should be able to await channel result
✔ exceptions should be handled
JsFuture
✔ should be able to convert a promise to a future
✔ should catch promise rejection
hello
✔ should export a greeting
✔ should export global singletons for JS primitives
✔ should export numbers
✔ should be able to create JS objects in rust
✔ should export a Rust function
JsNumber
✔ return a JsNumber built in Rust
✔ return a JsNumber for a large int built in Rust
✔ return a negative JsNumber int built in Rust
✔ return a JsNumber float built in Rust
✔ return a negative JsNumber float built in Rust
round trips
✔ accept and return a number
✔ accept and return a large number as a JsNumber
✔ will be safe below Number.MAX_SAFE_INTEGER
✔ will not be save above Number.MAX_SAFE_INTEGER
✔ accept and return a float as a JsNumber
✔ accept and return a negative number as a JsNumber
JsObject
✔ return the v8::Global object
✔ return a JsObject built in Rust
✔ return a JsObject with a number key value pair
✔ return a JsObject with an string key value pair
✔ return a JsObject with mixed content key value pairs
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `PendingException`,
right: `Ok`', crates/neon/src/sys/error.rs:49:5
✔ freeze a JsObject
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `PendingException`,
right: `Ok`', crates/neon/src/sys/error.rs:49:5
✔ seal a JsObject
✔ returns only own properties from get_own_property_names
✔ does not return Symbols from get_own_property_names
✔ data borrowed on the heap can be held longer than the handle
✔ calling Object::call_with() properly calls object methods
✔ calling Object::call_with() with a symbol method name works
JsString
✔ should return a JsString built in Rust
run_as_script
✔ should return the evaluated value
✔ should throw if the script throws
✔ should throw SyntaxError if the string has invalid syntax
sync
✔ can create and deref a root
✔ should be able to callback from another thread
✔ should be able to callback from multiple threads
✔ should be able to use an async greeter
✔ should run callback on drop
✔ should be able to unref channel
✔ should drop leaked Root from the global queue
✔ should be able to join on the result of a channel (103ms)
✔ should be able to sum numbers on the libuv pool
✔ should be able to resolve a promise manually
✔ should be able to resolve a promise from a rust thread
✔ should reject promise if leaked
thread '<unnamed>' panicked at 'Hello, Panic!', test/napi/src/js/threads.rs:266:13
✔ should throw an unhandledRejection when panicking in a channel
✔ should throw an unhandledRejection when throwing in a channel
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `PendingException`,
right: `Ok`', crates/neon/src/sys/error.rs:49:5
✔ should throw an unhandledRejection when panicking and throwing in a channel
thread '<unnamed>' panicked at 'Box<dyn Any>', test/napi/src/js/threads.rs:313:13
✔ should be able to downcast a panic in a channel
thread '<unnamed>' panicked at 'Hello, Panic!', test/napi/src/js/threads.rs:329:21
✔ should throw an unhandledRejection when panicking in a task
thread '<unnamed>' panicked at 'Hello, Panic!', test/napi/src/js/threads.rs:337:41
✔ should throw an unhandledRejection when panicking in a task complete
✔ should throw an unhandledRejection when throwing in a task complete
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `PendingException`,
right: `Ok`', crates/neon/src/sys/error.rs:49:5
✔ should throw an unhandledRejection when panicking and throwing in a task complete
thread '<unnamed>' panicked at 'Box<dyn Any>', test/napi/src/js/threads.rs:371:21
✔ should be able to downcast a panic in a task
✔ should be able to reject a promise in a task
thread '<unnamed>' panicked at 'Rejected!', test/napi/src/js/threads.rs:389:23
✔ panic in a task should reject the promise
thread '<unnamed>' panicked at 'Rejected!', test/napi/src/js/threads.rs:399:44
✔ panic in a task should reject the promise
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `PendingException`,
right: `Ok`', crates/neon/src/sys/error.rs:49:5
✔ panic and exception in a task should reject the promise
✔ should be able to reject a promise settling with a channel
✔ should reject a promise when panicking while settling with a channel
thread '<unnamed>' panicked at 'Rejected!', test/napi/src/js/threads.rs:441:13
✔ should reject a promise when panicking and throwing while settling with a channel
Typed arrays
✔ correctly reads a TypedArray using the borrow API
✔ correctly writes to a TypedArray using the borrow_mut API
✔ correctly reads a Buffer as a typed array
✔ copies the contents of one typed array to another
✔ cannot borrow overlapping buffers
✔ gets a 16-byte, zeroed ArrayBuffer
✔ correctly reads an ArrayBuffer using the lock API
✔ correctly reads an ArrayBuffer using the borrow API
✔ correctly writes to an ArrayBuffer using the lock API
✔ correctly writes to an ArrayBuffer using the borrow_mut API
✔ gets a 16-byte, uninitialized Buffer
✔ gets a 16-byte, zeroed Buffer
✔ gets a 16-byte buffer initialized from a slice
✔ gets an external Buffer
✔ gets an external ArrayBuffer
✔ gets a typed array constructed from an ArrayBuffer
✔ gets a new typed array
✔ gets a typed array copied from a slice
✔ gets correct typed array info
✔ correctly constructs a view over a slice of a buffer
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `GenericFailure`,
right: `Ok`', crates/neon/src/sys/typedarray.rs:57:5
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `GenericFailure`,
right: `Ok`', crates/neon/src/sys/typedarray.rs:57:5
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `GenericFailure`,
right: `Ok`', crates/neon/src/sys/typedarray.rs:57:5
✔ properly fails to construct typed arrays with invalid arguments
✔ correctly reads a Buffer using the lock API
✔ correctly reads a Buffer using the borrow API
✔ correctly writes to a Buffer using the lock API
✔ correctly writes to a Buffer using the borrow_mut API
✔ zeroes the byteLength when an ArrayBuffer is detached
✔ provides correct metadata when detaching a typed array's buffer
✔ provides correct metadata when detaching an escaped typed array's buffer
✔ provides correct metadata when detaching a casted typed array's buffer
✔ provides correct metadata when detaching an un-rooted typed array's buffer
✔ doesn't validate regions without instantiating
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `GenericFailure`,
right: `Ok`', crates/neon/src/sys/typedarray.rs:57:5
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `GenericFailure`,
right: `Ok`', crates/neon/src/sys/typedarray.rs:57:5
✔ validates regions when instantiating
type checks
✔ is_array
✔ is_array_buffer
✔ is_uint32_array
✔ is_boolean
✔ is_buffer
✔ is_error
✔ is_null
✔ is_number
✔ is_object
✔ is_string
✔ is_undefined
✔ strict_equals
Worker / Root Tagging Tests
Single Threaded
✔ should be able to stash a global with `get_and_replace`
✔ should be able to lazily initialize with `get_or_init`
✔ should be able to lazily initialize with `get_or_init_clone`
Multi-Threaded
thread '<unnamed>' panicked at 'Attempted to dereference a `neon::handle::Root` from the wrong module ', /Users/dherman/Sources/neon/crates/neon/src/handle/root.rs:182:13
✔ should fail to use `get_and_replace` (51ms)
thread '<unnamed>' panicked at 'Attempted to dereference a `neon::handle::Root` from the wrong module ', /Users/dherman/Sources/neon/crates/neon/src/handle/root.rs:182:13
✔ should fail to use `get_or_init` (50ms)
thread '<unnamed>' panicked at 'Attempted to dereference a `neon::handle::Root` from the wrong module ', /Users/dherman/Sources/neon/crates/neon/src/handle/root.rs:182:13
✔ should fail to use `get_or_init` (52ms)
Instance-local storage
✔ should be able to read an instance local from the main thread
✔ should be able to store rooted objects in instance locals
thread '<unnamed>' panicked at 'attempt to reinitialize Local during initialization', /Users/dherman/Sources/neon/crates/neon/src/lifecycle.rs:94:34
✔ should gracefully panic upon reentrant get_or_try_init
✔ should allocate separate locals for each addon instance (48ms)
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
left: `PendingException`,
right: `Ok`', /Users/dherman/Sources/neon/crates/neon/src/sys/fun.rs:57:9
fatal runtime error: failed to initiate panic, error 5
/Users/dherman/.volta/tools/image/npm/8.3.2/bin/npm: line 10: 23684 Abort trap: 6 node "$basedir/npm-cli.js" "$@"
dherman@dherman-mn2 neon % echo $?
134
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment