node-reinstall icon indicating copy to clipboard operation
node-reinstall copied to clipboard

Unit tests using BATS

Open brock opened this issue 7 years ago • 8 comments

I'd be very interested in setting up unit testing using BATS. If anyone has experience with this and can get a basic setup going, preferably with TravisCI, I'd be willing to offer a bounty of ~$10 via PayPal or Crypto~

Bounty has been raised to $50 USD, payable via PayPal, Venmo or Crypto.

brock avatar Jan 03 '19 00:01 brock

Screw it - unit tests matter. I'm bumping this bounty to $50.

brock avatar Jan 03 '19 00:01 brock

Submitted PR #58 for this bounty: https://github.com/brock/node-reinstall/pull/58

What it adds:

  • BATS smoke tests for safe command-line paths that exit before destructive reinstall operations
  • Travis CI setup that installs bats-core and runs make test
  • README instructions for running the tests locally

Validation:

  • PATH="/tmp/codex-bats-core-node-reinstall/bin:$PATH" make test passed with 4 tests

If accepted for the bounty, PayPal payout details can be provided privately.

LpcPaul avatar May 24 '26 05:05 LpcPaul

Submitted PR #59 for this bounty: https://github.com/brock/node-reinstall/pull/59

What it adds:

  • BATS test target plus both Travis CI and GitHub Actions coverage
  • Tests for safe CLI exits: help, version, and invalid option paths
  • Stubbed destructive-flow coverage for --force --nvm and --force --nave using isolated temp HOME/PREFIX values
  • Regression coverage for release tag extraction and global npm module basename handling
  • README instructions for running the test suite locally

Validation:

  • Ran the BATS suite locally through Git Bash with bats-core: 6 tests passed

If accepted for the bounty, payout details can be provided privately.

businesscurry123 avatar May 24 '26 11:05 businesscurry123

Submitted PR #60 for this bounty: https://github.com/brock/node-reinstall/pull/60\n\nIt adds BATS tests, Travis CI wiring, GitHub Actions on Ubuntu/macOS, and two small portability fixes that the tests exercise. Local verification: 8 BATS tests passing.\n\nIf accepted for the bounty, PayPal payout can go to [email protected].

absalonCRC avatar May 24 '26 11:05 absalonCRC

Update on PR #59: I pushed a follow-up commit (3802f9d) to make the test submission stronger.

Additional coverage now includes:

  • GitHub Actions matrix on Ubuntu and macOS
  • bash -n ./node-reinstall as part of make test
  • first-time install coverage when Node/npm are absent
  • --version pre-privilege exit coverage
  • a small --nvm-latest fix plus regression test so it uses the master install script instead of the stable release API

Local verification: 9 BATS tests pass against safe stubs (sudo, npm, curl, nvm, nave).

businesscurry123 avatar May 24 '26 11:05 businesscurry123

Quick check before I add more noise here: are you still accepting a fresh BATS implementation, or are you mainly reviewing the current submissions (#56, #58-#61)? I can either submit a smaller focused BATS-only PR or help compare the existing ones, but I do not want to duplicate work if one is already preferred.

thefuturrjfhejh avatar May 24 '26 13:05 thefuturrjfhejh

Update on PR #58: I pushed follow-up commit f4b609b to strengthen the submission after the new activity on this issue.

Additional coverage now includes:

  • GitHub Actions test workflow on Ubuntu and macOS
  • Stubbed --force --nvm coverage when Node/npm are absent
  • Stubbed --force --nave coverage with a requested Node version and global npm module reinstall
  • Temporary HOME and PREFIX paths so the destructive-flow tests stay isolated

Validation:

  • PATH="/tmp/codex-bats-core-node-reinstall/bin:$PATH" make test passes with 6 BATS tests.

LpcPaul avatar May 25 '26 01:05 LpcPaul

Hi! I'd like to work on this bounty — claiming via autonomous pipeline.

Account: jdjioe5-cpu ([email protected]) Skills: C / Python / Go / TypeScript / Bash + threat-model + code-review + perf-opt

Plan:

  1. Review linked source + any related issue context
  2. Reproduce or scope the work locally
  3. Push a focused PR (test plan + reproducibility notes)
  4. Submit for judgment

If a single solver per bounty is required, I'll wait for explicit assignment. Otherwise I'll start work after a brief scoping window.

Thanks!

jdjioe5-cpu avatar Jul 24 '26 04:07 jdjioe5-cpu

I reviewed the existing BATS proposals and found a specific case worth adding before a merge: preserving scoped global package names.

In #59 at 3802f9d (also #60), the revised extraction still uses basename. This read-only reproduction of that extraction:

printf '%s\n' /tmp/prefix/lib /tmp/prefix/lib/node_modules/@scope/example \
  | xargs -n 1 basename | sed -E '/^(lib|npm)$/d'

prints example, losing @scope/. The later npm install --global $GLOBAL_MODULES would therefore request the unscoped package instead of @scope/example. npm documents the scoped directory layout here. This is a synthetic extraction check; I have not run the destructive reinstall script or claimed Linux/macOS validation.

@brock, if you are still reviewing this bounty, would a $10 PayPal follow-up to your preferred existing PR be useful? I would preserve scoped names, add a focused regression, and document the tests actually run, within one hour of an agreed start. Please confirm the preferred PR, acceptance checks and payment timing first. This finding is shared freely, and I am not claiming the existing $50 award or duplicating the submitted test suites.

Parth

parthchilwerwar avatar Sep 12 '26 14:09 parthchilwerwar