| 1 | // Entry point for the Bazel js_test (//node/test:node_test): run node/test.js |
| 2 | // with Node's built-in test runner (node:test) against the self-contained |
| 3 | // sandbox assembled next to this file. The test has no npm dependencies at all: |
| 4 | // node:test ships with Node, and node/opencc.js locates the addon with a plain |
| 5 | // filesystem lookup (no node-gyp-build). |
| 6 | // |
| 7 | // The sandbox mirrors an npm-install layout (node/*.js + build/Release/<addon> + |
| 8 | // assets + test/testcases + scripts), so node/opencc.js resolves the addon and |
| 9 | // its resources from its own location, exactly as it does after `npm install`. |
| 10 | const path = require('path'); |
| 11 | |
| 12 | // Staged at <runfiles>/_main/node/test/test_entry.js. |
| 13 | const sandbox = path.join(__dirname, 'sandbox'); |
| 14 | process.chdir(sandbox); |
| 15 | |
| 16 | // node/test.js registers tests via node:test; requiring it lets the built-in |
| 17 | // runner execute them and set a non-zero exit code on failure. |
| 18 | require(path.join(sandbox, 'node', 'test.js')); |