infinyon / infinyon/node-bindgen

Unable to run Rust unittests on binded library

Open
#170 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug question
Dominant language
Rust
Stars
587
Forks
43
PR merge metrics
No merged PRs in 30d

Description

Running Rust testing on binded library generate errors.

Reproduction:
https://github.com/ziv/node-bindgen-unitest-error-reproduction

Expected behavior:

Running tests should pass.

Actual behavior:

Error

 %  cargo test --verbose
 
    Compiling node-bindgen-unitest-error-reproduction v0.1.0 (...)
     Running `rustc ...`
error: cannot find attribute `node_bindgen` in this scope
 --> src/lib.rs:6:7
  |
6 |     #[node_bindgen]
  |       ^^^^^^^^^^^^

warning: unused import: `node_bindgen::derive::node_bindgen`
 --> src/lib.rs:1:5
  |
1 | use node_bindgen::derive::node_bindgen;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: aborting due to previous error; 1 warning emitted

error: could not compile `node-bindgen-unitest-error-reproduction`

Caused by:
  process didn't exit successfully: `rustc --crate-name node_bindgen_unitest_error_reproduction --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --test -C metadata=51601585b678e8bc -C extra-filename=-51601585b678e8bc --out-dir /Users/ziv.perry/zivcode/node-bindgen-unitest-error-reproduction/target/debug/deps -C incremental=/Users/ziv.perry/zivcode/node-bindgen-unitest-error-reproduction/target/debug/incremental -L dependency=/Users/ziv.perry/zivcode/node-bindgen-unitest-error-reproduction/target/debug/deps --extern node_bindgen=/Users/ziv.perry/zivcode/node-bindgen-unitest-error-reproduction/target/debug/deps/libnode_bindgen-553b1a9a13c1f95a.rlib -C link-arg=-undefined -C link-arg=dynamic_lookup` (exit status: 1)
 

Workaround

Removing #[node_bindgen] decorator works.
Example for output after commented the decorator:

 % cargo test
   Compiling node-bindgen-unitest-error-reproduction v0.1.0 (...)
    Finished test [unoptimized + debuginfo] target(s) in 0.91s
     Running unittests (target/debug/deps/node_bindgen_unitest_error_reproduction-51601585b678e8bc)

running 1 test
test testing::should_sum_numbers ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and run cargo test --verbose to reproduce the failure in src/lib.rs. Inspect the node_bindgen import and attribute usage shown in the error. Done means the unit tests pass without removing the #[node_bindgen] decorator.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, rust
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.