tape-six-proc 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/bin/tape6-proc-node.js +27 -120
- package/llms-full.txt +8 -5
- package/llms.txt +2 -0
- package/package.json +3 -3
- package/src/TestWorker.js +5 -15
package/README.md
CHANGED
|
@@ -88,6 +88,7 @@ LLM-friendly documentation is available:
|
|
|
88
88
|
|
|
89
89
|
The most recent releases:
|
|
90
90
|
|
|
91
|
+
- 1.2.5 _Synchronized with `tape-six` 1.7.6+. Simplified CLI via shared config utilities. Added `--info` flag. Fixed Deno stdout flush._
|
|
91
92
|
- 1.2.4 _Synchronized with `tape-six` 1.7.4. Added Min reporter support. Improved docs and npm keywords._
|
|
92
93
|
- 1.2.3 _Updated dependencies, cleaned up docs, added AI-friendly links and TS info._
|
|
93
94
|
- 1.2.2 _Synchronized the implementation with `tape-six` 1.7.0._
|
package/bin/tape6-proc-node.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import process from 'node:process';
|
|
4
|
-
import os from 'node:os';
|
|
5
4
|
import {fileURLToPath} from 'node:url';
|
|
6
5
|
|
|
7
|
-
import {
|
|
8
|
-
getReporterFileName,
|
|
9
|
-
getReporterType,
|
|
10
|
-
resolveTests,
|
|
11
|
-
resolvePatterns,
|
|
12
|
-
runtime
|
|
13
|
-
} from 'tape-six/utils/config.js';
|
|
6
|
+
import {getOptions, initFiles, initReporter, showInfo} from 'tape-six/utils/config.js';
|
|
14
7
|
|
|
15
8
|
import {getReporter, setReporter} from 'tape-six/test.js';
|
|
16
9
|
import {selectTimer} from 'tape-six/utils/timer.js';
|
|
17
10
|
|
|
18
11
|
import TestWorker from '../src/TestWorker.js';
|
|
19
12
|
|
|
20
|
-
const
|
|
21
|
-
rootFolder = process.cwd();
|
|
22
|
-
|
|
23
|
-
let flags = '',
|
|
24
|
-
parallel = '',
|
|
25
|
-
runFileArgs = [],
|
|
26
|
-
files = [];
|
|
13
|
+
const rootFolder = process.cwd();
|
|
27
14
|
|
|
28
15
|
const showSelf = () => {
|
|
29
16
|
const self = new URL(import.meta.url);
|
|
@@ -35,125 +22,44 @@ const showSelf = () => {
|
|
|
35
22
|
process.exit(0);
|
|
36
23
|
};
|
|
37
24
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
n: 'showAssertNumber',
|
|
48
|
-
m: 'monochrome',
|
|
49
|
-
c: 'dontCaptureConsole',
|
|
50
|
-
h: 'hideStreams'
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
let parIsSet = false;
|
|
54
|
-
|
|
55
|
-
for (let i = 2; i < process.argv.length; ++i) {
|
|
56
|
-
const arg = process.argv[i];
|
|
57
|
-
if (arg == '-f' || arg == '--flags') {
|
|
58
|
-
if (++i < process.argv.length) {
|
|
59
|
-
flags += process.argv[i];
|
|
60
|
-
}
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (arg == '-p' || arg == '--par') {
|
|
64
|
-
if (++i < process.argv.length) {
|
|
65
|
-
parallel = process.argv[i];
|
|
66
|
-
parIsSet = true;
|
|
67
|
-
if (!parallel || isNaN(parallel)) {
|
|
68
|
-
parallel = '';
|
|
69
|
-
parIsSet = false;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (arg == '-r' || arg == '--runFileArgs') {
|
|
75
|
-
if (++i < process.argv.length) {
|
|
76
|
-
runFileArgs.push(process.argv[i]);
|
|
77
|
-
}
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
files.push(arg);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
flags = (process.env.TAPE6_FLAGS || '') + flags;
|
|
84
|
-
for (let i = 0; i < flags.length; ++i) {
|
|
85
|
-
const option = flags[i].toLowerCase(),
|
|
86
|
-
name = optionNames[option];
|
|
87
|
-
if (typeof name == 'string') options[name] = option !== flags[i];
|
|
88
|
-
}
|
|
89
|
-
options.flags = flags;
|
|
90
|
-
|
|
91
|
-
if (!parIsSet) {
|
|
92
|
-
parallel = process.env.TAPE6_PAR || parallel;
|
|
93
|
-
}
|
|
94
|
-
if (parallel) {
|
|
95
|
-
parallel = Math.max(0, +parallel);
|
|
96
|
-
if (parallel === Infinity) parallel = 0;
|
|
97
|
-
} else {
|
|
98
|
-
parallel = 0;
|
|
99
|
-
}
|
|
100
|
-
if (!parallel) {
|
|
101
|
-
if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {
|
|
102
|
-
parallel = navigator.hardwareConcurrency;
|
|
103
|
-
} else {
|
|
104
|
-
try {
|
|
105
|
-
parallel = os.availableParallelism();
|
|
106
|
-
} catch (e) {
|
|
107
|
-
void e;
|
|
108
|
-
parallel = 1;
|
|
109
|
-
}
|
|
25
|
+
const main = async () => {
|
|
26
|
+
const runFileArgs = [];
|
|
27
|
+
const options = getOptions({
|
|
28
|
+
'--self': showSelf,
|
|
29
|
+
'--info': {isValueRequired: false},
|
|
30
|
+
'--runFileArgs': {
|
|
31
|
+
aliases: ['-r'],
|
|
32
|
+
isValueRequired: true,
|
|
33
|
+
fn: (_, _name, value) => runFileArgs.push(value)
|
|
110
34
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
options.runFileArgs = runFileArgs;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const init = async () => {
|
|
117
|
-
const currentReporter = getReporter();
|
|
118
|
-
if (!currentReporter) {
|
|
119
|
-
const reporterType = getReporterType(),
|
|
120
|
-
reporterFile = getReporterFileName(reporterType),
|
|
121
|
-
CustomReporter = (await import('tape-six/reporters/' + reporterFile)).default,
|
|
122
|
-
hasColors = !(
|
|
123
|
-
options.monochrome ||
|
|
124
|
-
process.env.NO_COLOR ||
|
|
125
|
-
process.env.NODE_DISABLE_COLORS ||
|
|
126
|
-
process.env.FORCE_COLOR === '0'
|
|
127
|
-
),
|
|
128
|
-
customOptions = reporterType === 'tap' ? {useJson: true, hasColors} : {...options, hasColors},
|
|
129
|
-
customReporter = new CustomReporter(customOptions);
|
|
130
|
-
setReporter(customReporter);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (files.length) {
|
|
134
|
-
files = await resolvePatterns(rootFolder, files);
|
|
135
|
-
} else {
|
|
136
|
-
files = await resolveTests(rootFolder, runtime.name);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
35
|
+
});
|
|
36
|
+
options.flags.runFileArgs = runFileArgs;
|
|
139
37
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
38
|
+
const [files] = await Promise.all([
|
|
39
|
+
initFiles(options.files, rootFolder),
|
|
40
|
+
initReporter(getReporter, setReporter, options.flags),
|
|
41
|
+
selectTimer()
|
|
42
|
+
]);
|
|
144
43
|
|
|
145
44
|
process.on('uncaughtException', (error, origin) => {
|
|
146
45
|
console.error('UNHANDLED ERROR:', origin, error);
|
|
147
46
|
process.exit(1);
|
|
148
47
|
});
|
|
149
48
|
|
|
49
|
+
if (options.optionFlags['--info'] === '') {
|
|
50
|
+
showInfo(options, files);
|
|
51
|
+
await new Promise(r => process.stdout.write('', r));
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
150
55
|
if (!files.length) {
|
|
151
56
|
console.log('No files found.');
|
|
57
|
+
await new Promise(r => process.stdout.write('', r));
|
|
152
58
|
process.exit(1);
|
|
153
59
|
}
|
|
154
60
|
|
|
155
61
|
const reporter = getReporter(),
|
|
156
|
-
worker = new TestWorker(reporter, parallel, options);
|
|
62
|
+
worker = new TestWorker(reporter, options.parallel, options.flags);
|
|
157
63
|
|
|
158
64
|
reporter.report({type: 'test', test: 0});
|
|
159
65
|
|
|
@@ -170,6 +76,7 @@ const main = async () => {
|
|
|
170
76
|
fail: hasFailed
|
|
171
77
|
});
|
|
172
78
|
|
|
79
|
+
await new Promise(r => process.stdout.write('', r));
|
|
173
80
|
process.exit(hasFailed ? 1 : 0);
|
|
174
81
|
};
|
|
175
82
|
|
package/llms-full.txt
CHANGED
|
@@ -55,8 +55,10 @@ tape6-proc [--flags FLAGS] [--par N] [--runFileArgs ARGS] [tests...]
|
|
|
55
55
|
- `--flags FLAGS` (`-f`) — output control flags (see Supported flags below).
|
|
56
56
|
- `--par N` (`-p`) — number of parallel processes. Default: all CPU cores (via `os.availableParallelism()` or `navigator.hardwareConcurrency`).
|
|
57
57
|
- `--runFileArgs ARGS` (`-r`) — extra arguments passed to the spawned interpreter. Can be specified multiple times. Mainly used for Deno permissions.
|
|
58
|
+
- `--info` — prints runtime, reporter, parallelism, flags, and test files, then exits.
|
|
58
59
|
- `--self` — prints the absolute path to `tape6-proc.js` and exits. Used in cross-runtime scripts.
|
|
59
60
|
- Positional arguments: test file glob patterns. If none given, reads from configuration.
|
|
61
|
+
- Options accept `--flags FO` or `--flags=FO`. The `=` form does not support quoting.
|
|
60
62
|
|
|
61
63
|
### Examples
|
|
62
64
|
|
|
@@ -161,9 +163,11 @@ Environment-specific subsections (`node`, `deno`, `bun`) are supported. The runn
|
|
|
161
163
|
|
|
162
164
|
### Main CLI (`bin/tape6-proc-node.js`)
|
|
163
165
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
Delegates argument parsing, reporter setup, and file resolution to `tape-six/utils/config.js`:
|
|
167
|
+
|
|
168
|
+
1. Calls `getOptions()` to parse CLI arguments (`--flags`, `--par`, `--runFileArgs`, `--info`, positional test patterns).
|
|
169
|
+
2. Calls `initReporter()` to select the reporter: TTY (default for terminals), TAP, JSONL, or Min (based on environment variables).
|
|
170
|
+
3. Calls `initFiles()` to resolve test files from configuration or CLI patterns.
|
|
167
171
|
4. Creates a `TestWorker` instance and executes all test files.
|
|
168
172
|
5. Reports final results and exits with code 0 (success) or 1 (failures).
|
|
169
173
|
|
|
@@ -174,7 +178,6 @@ Extends `EventServer` from `tape-six`. Manages parallel subprocess execution:
|
|
|
174
178
|
- **`constructor(reporter, numberOfTasks, options)`** — initializes with a reporter, concurrency limit, and options. Generates a UUID prefix for JSONL parsing.
|
|
175
179
|
- **`makeTask(fileName)`** — spawns a child process for a test file using `dollar-shell`. Sets up stream pipelines for stdout and stderr. Returns a task ID.
|
|
176
180
|
- **`destroyTask(id)`** — cleans up a completed task.
|
|
177
|
-
- **`getConcurrency()`** — static method, returns available CPU cores.
|
|
178
181
|
|
|
179
182
|
### Stream pipeline
|
|
180
183
|
|
|
@@ -205,7 +208,7 @@ process.stderr → TextDecoderStream → lines → wrap-lines → report
|
|
|
205
208
|
|
|
206
209
|
## Dependencies
|
|
207
210
|
|
|
208
|
-
- **`tape-six`** — the core test library. Imports: `
|
|
211
|
+
- **`tape-six`** — the core test library. Imports: `utils/config.js` (`getOptions`, `initFiles`, `initReporter`, `showInfo`), `test.js` (`getReporter`, `setReporter`), `utils/timer.js`, `State.js`, `utils/EventServer.js`, `utils/makeDeferred.js`.
|
|
209
212
|
- **`dollar-shell`** — cross-runtime process spawning. Imports: `spawn`, `currentExecPath`, `runFileArgs`.
|
|
210
213
|
|
|
211
214
|
## Writing tests
|
package/llms.txt
CHANGED
|
@@ -54,8 +54,10 @@ tape6-proc [--flags FLAGS] [--par N] [--runFileArgs ARGS] [tests...]
|
|
|
54
54
|
- `--flags FLAGS` (`-f`) — output control flags (same as tape6: F=failures only, T=time, B=banner, D=data, O=fail once, N=assert number, M=monochrome, C=don't capture console, H=hide streams). Can be specified multiple times.
|
|
55
55
|
- `--par N` (`-p`) — number of parallel processes (default: all CPU cores).
|
|
56
56
|
- `--runFileArgs ARGS` (`-r`) — extra arguments for the spawned interpreter. Can be specified multiple times. Mainly for Deno permissions.
|
|
57
|
+
- `--info` — prints runtime, reporter, parallelism, flags, and test files, then exits.
|
|
57
58
|
- `--self` — prints the path to `tape6-proc.js` (for cross-runtime scripts).
|
|
58
59
|
- No arguments: runs tests from configuration.
|
|
60
|
+
- Options accept `--flags FO` or `--flags=FO`. The `=` form does not support quoting.
|
|
59
61
|
|
|
60
62
|
### Cross-runtime usage
|
|
61
63
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tape-six-proc",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Process-isolated test runner for tape-six. Runs each test file in its own subprocess. Works with Node, Deno, and Bun. Supports TypeScript without transpilation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"llms-full.txt"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"dollar-shell": "^1.1.
|
|
60
|
-
"tape-six": "^1.7.
|
|
59
|
+
"dollar-shell": "^1.1.11",
|
|
60
|
+
"tape-six": "^1.7.8"
|
|
61
61
|
},
|
|
62
62
|
"tape6": {
|
|
63
63
|
"tests": [
|
package/src/TestWorker.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import os from 'node:os';
|
|
3
2
|
import {sep} from 'node:path';
|
|
4
3
|
import {pathToFileURL, fileURLToPath} from 'node:url';
|
|
5
4
|
import crypto from 'node:crypto';
|
|
@@ -17,7 +16,7 @@ import wrap from './streams/wrap-lines.js';
|
|
|
17
16
|
const baseName = pathToFileURL(process.cwd() + sep);
|
|
18
17
|
|
|
19
18
|
export default class TestWorker extends EventServer {
|
|
20
|
-
constructor(reporter, numberOfTasks
|
|
19
|
+
constructor(reporter, numberOfTasks, options) {
|
|
21
20
|
super(reporter, numberOfTasks, options);
|
|
22
21
|
this.counter = 0;
|
|
23
22
|
this.idToWorker = {};
|
|
@@ -38,7 +37,10 @@ export default class TestWorker extends EventServer {
|
|
|
38
37
|
TAPE6_TEST: id,
|
|
39
38
|
TAPE6_TEST_FILE_NAME: fileName,
|
|
40
39
|
TAPE6_JSONL: 'Y',
|
|
41
|
-
TAPE6_JSONL_PREFIX: this.prefix
|
|
40
|
+
TAPE6_JSONL_PREFIX: this.prefix,
|
|
41
|
+
TAPE6_MIN: '',
|
|
42
|
+
TAPE6_TAP: '',
|
|
43
|
+
TAPE6_TTY: ''
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
);
|
|
@@ -112,16 +114,4 @@ export default class TestWorker extends EventServer {
|
|
|
112
114
|
delete this.idToWorker[id];
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
|
-
static getConcurrency() {
|
|
116
|
-
if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {
|
|
117
|
-
return navigator.hardwareConcurrency;
|
|
118
|
-
}
|
|
119
|
-
try {
|
|
120
|
-
return os.availableParallelism();
|
|
121
|
-
} catch (e) {
|
|
122
|
-
void e;
|
|
123
|
-
// squelch
|
|
124
|
-
}
|
|
125
|
-
return 1;
|
|
126
|
-
}
|
|
127
117
|
}
|