Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 3.16 KB

DEVELOP.md

File metadata and controls

68 lines (47 loc) · 3.16 KB

node-ffi-packager logotype, impossible cubes in green

README · Changelog · Development

  • Follow git-flow and use git-flow-avh.
  • Tests are required for both bug fixes and features.
    • For bugs, please first commit a test proving the bug.

Setup

git flow init -d

npm install

# NOTE: exporting for temporary use during development.
export LD_LIBRARY_PATH="$(llvm-config --libdir)"

npm run --silent test

# NOTE: when done with development.
unset LD_LIBRARY_PATH

Testing

  • Using ffi-generate requires the path to libclang.so (or .dylib, .dll on other systems) to be set, so the dynamic linker (used via ffi-napi) can find it.
    • Setting LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH on macOS) is required to load the ffi-generate library (from index.js).
    • The ffi-generate executable (in bin/ffi-generate.js) sets the environment variable automatically.
  • Tests are executed using ava.
# NOTE: run all tests in a single directory.
npm run --silent test:ava -- test/unit/struct/*.js

Debug logging

  • Enable (some) additional debugging output to stderr by setting the DEBUG environment variable to ffi-generate:*.
  • Uses debug, and can also be used to debug other packages which also use debug.
    • Enable all debug logging with DEBUG='*'. Will yield a lot more output.
# NOTE: exporting for temporary use during development.
export DEBUG='ffi-generate:*'

./bin/ffi-generate.js --library 'mylibrary' --file ./examples/programmatic-usage/simple/mylibrary.h

# NOTE: when done with development.
unset DEBUG

Code coverage

  • At the end of the tests, you will see a code coverage report generated by nyc.
    • The total code coverage percentages are enforced. See .nycrc.json.
  • If you have executed the tests locally, there should also be a code coverage report (link only works locally) in the coverage/ directory.
    • Ensure that your added or changed lines of code in each commit are executed at least once.

node-ffi-generate Copyright © 2011, 2012, 2013, 2014 Timothy J Fontaine, © 2020, 2021 Joel Purra. Released under MIT License.