Skip to content

Commit 801df1b

Browse files
committed
Add run_tests.js wrapper for proxy integration harness
Made-with: Cursor
1 parent 81c5bc2 commit 801df1b

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
],
6161
"scripts": {
6262
"test": "node test/test_proxy_headers.js core axios node-fetch got undici superagent ky wretch make-fetch-happen needle typed-rest-client",
63+
"test:run": "node run_tests.js",
6364
"test:verbose": "node test/test_proxy_headers.js -v",
6465
"test:ts": "tsx test/test_proxy_headers.ts core axios node-fetch got undici superagent ky wretch make-fetch-happen needle typed-rest-client",
6566
"test:ts:verbose": "tsx test/test_proxy_headers.ts -v",

run_tests.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Convenience wrapper for the proxy integration test harness.
4+
* Forwards all arguments to test/test_proxy_headers.js.
5+
*
6+
* @example
7+
* PROXY_URL='http://proxy:8080' node run_tests.js -v
8+
* node run_tests.js -l
9+
*/
10+
11+
import { spawn } from 'child_process';
12+
import { fileURLToPath } from 'url';
13+
import { dirname, join } from 'path';
14+
15+
const __dirname = dirname(fileURLToPath(import.meta.url));
16+
const testScript = join(__dirname, 'test', 'test_proxy_headers.js');
17+
const args = process.argv.slice(2);
18+
19+
const child = spawn(process.execPath, [testScript, ...args], {
20+
stdio: 'inherit',
21+
env: process.env,
22+
});
23+
24+
child.on('error', (err) => {
25+
console.error(err);
26+
process.exit(1);
27+
});
28+
29+
child.on('exit', (code, signal) => {
30+
if (signal) {
31+
process.kill(process.pid, signal);
32+
return;
33+
}
34+
process.exit(code ?? 1);
35+
});

0 commit comments

Comments
 (0)