supertape 10.6.0 → 10.7.0
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/ChangeLog +17 -0
- package/bin/communication.mjs +3 -0
- package/bin/subscribe.mjs +32 -4
- package/bin/supertape.mjs +15 -2
- package/lib/formatter/harness.js +1 -0
- package/lib/worker/create-console-log.js +47 -0
- package/package.json +6 -6
package/ChangeLog
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
2024.06.04, v10.7.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- dcb4dfb supertape: add ability to use console.log in worker mode
|
|
5
|
+
- 188ab81 @supertape/formatter-progress-bar: add comment
|
|
6
|
+
- 79a0e2f supertape: rm unused quiet
|
|
7
|
+
- 5f3d825 @putout/formatter-progress-bar: ✅ ok in WebStorm
|
|
8
|
+
|
|
9
|
+
2024.06.04, v10.6.1
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 9113041 supertape: @supertape/formatter-progress-bar v6.0.0
|
|
13
|
+
- a61477a formatter-progress-bar: get rid of WebStorm hacks
|
|
14
|
+
- 342cda0 supertape: check-dts v0.8.0
|
|
15
|
+
- adfb128 supertape: husky v9.0.11
|
|
16
|
+
- c6f3052 supertape: @putout/eslint-flat v2.0.0
|
|
17
|
+
|
|
1
18
|
2024.05.09, v10.6.0
|
|
2
19
|
|
|
3
20
|
feature:
|
package/bin/communication.mjs
CHANGED
|
@@ -2,12 +2,14 @@ import {EventEmitter} from 'node:events';
|
|
|
2
2
|
import {parentPort, workerData} from 'node:worker_threads';
|
|
3
3
|
|
|
4
4
|
const {assign} = Object;
|
|
5
|
+
const returns = (a) => () => a;
|
|
5
6
|
|
|
6
7
|
export const createCommunication = (argv) => {
|
|
7
8
|
if (parentPort)
|
|
8
9
|
return {
|
|
9
10
|
parentPort,
|
|
10
11
|
workerData,
|
|
12
|
+
isMaster: returns(false),
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
const {newWorker, newParentPort} = fakeWorkers();
|
|
@@ -16,6 +18,7 @@ export const createCommunication = (argv) => {
|
|
|
16
18
|
worker: newWorker,
|
|
17
19
|
parentPort: newParentPort,
|
|
18
20
|
workerData: argv,
|
|
21
|
+
isMaster: returns(true),
|
|
19
22
|
};
|
|
20
23
|
};
|
|
21
24
|
|
package/bin/subscribe.mjs
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import keyPress from '@putout/cli-keypress';
|
|
2
2
|
import harnessCreator from '../lib/formatter/harness.js';
|
|
3
|
+
import {parse} from 'flatted';
|
|
4
|
+
import {
|
|
5
|
+
SPLITTER,
|
|
6
|
+
CONSOLE_LOG,
|
|
7
|
+
CONSOLE_ERROR,
|
|
8
|
+
} from '../lib/worker/create-console-log.js';
|
|
3
9
|
|
|
4
|
-
const
|
|
10
|
+
const one = (fn) => (a) => fn(a);
|
|
5
11
|
|
|
12
|
+
const {createHarness} = harnessCreator;
|
|
6
13
|
const resolveFormatter = async (name) => await import(`@supertape/formatter-${name}`);
|
|
7
14
|
|
|
8
|
-
export async function subscribe({name,
|
|
15
|
+
export async function subscribe({name, exit, worker, stdout}) {
|
|
9
16
|
const {isStop} = keyPress();
|
|
10
17
|
const harness = createHarness(await resolveFormatter(name));
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
harness.pipe(stdout);
|
|
19
|
+
harness.pipe(stdout);
|
|
14
20
|
|
|
15
21
|
worker.on('exit', (code) => {
|
|
16
22
|
exit(code);
|
|
17
23
|
});
|
|
18
24
|
|
|
19
25
|
worker.on('message', ([type, a]) => {
|
|
26
|
+
if (type === CONSOLE_LOG)
|
|
27
|
+
return consoleLog(a);
|
|
28
|
+
|
|
29
|
+
if (type === CONSOLE_ERROR)
|
|
30
|
+
return consoleError(a);
|
|
31
|
+
|
|
20
32
|
harness.write({
|
|
21
33
|
type,
|
|
22
34
|
...a,
|
|
@@ -26,3 +38,19 @@ export async function subscribe({name, quiet, exit, worker, stdout}) {
|
|
|
26
38
|
worker.postMessage(['stop']);
|
|
27
39
|
});
|
|
28
40
|
}
|
|
41
|
+
|
|
42
|
+
function consoleLog({message}) {
|
|
43
|
+
const messages = message
|
|
44
|
+
.split(SPLITTER)
|
|
45
|
+
.map(one(parse));
|
|
46
|
+
|
|
47
|
+
console.log(...messages);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function consoleError({message}) {
|
|
51
|
+
const messages = message
|
|
52
|
+
.split(SPLITTER)
|
|
53
|
+
.map(one(parse));
|
|
54
|
+
|
|
55
|
+
console.error(...messages);
|
|
56
|
+
}
|
package/bin/supertape.mjs
CHANGED
|
@@ -5,11 +5,16 @@ import {createIsStop} from './is-stop.mjs';
|
|
|
5
5
|
import {createFormatter} from './formatter.mjs';
|
|
6
6
|
import {parseArgs} from '../lib/cli/parse-args.js';
|
|
7
7
|
import cli from '../lib/cli.js';
|
|
8
|
+
import {
|
|
9
|
+
overrideConsoleError,
|
|
10
|
+
overrideConsoleLog,
|
|
11
|
+
} from '../lib/worker/create-console-log.js';
|
|
8
12
|
|
|
9
13
|
const {
|
|
10
14
|
worker,
|
|
11
15
|
parentPort,
|
|
12
16
|
workerData,
|
|
17
|
+
isMaster,
|
|
13
18
|
} = createCommunication(process.argv);
|
|
14
19
|
|
|
15
20
|
const args = parseArgs(process.argv.slice(2));
|
|
@@ -23,14 +28,22 @@ const {
|
|
|
23
28
|
const workerFormatter = createFormatter(parentPort);
|
|
24
29
|
const isStop = createIsStop(parentPort);
|
|
25
30
|
|
|
26
|
-
if (
|
|
31
|
+
if (isMaster()) {
|
|
27
32
|
subscribe({
|
|
28
33
|
name: args.format,
|
|
29
|
-
quiet: args.quiet,
|
|
30
34
|
exit,
|
|
31
35
|
worker,
|
|
32
36
|
stdout,
|
|
33
37
|
});
|
|
38
|
+
} else {
|
|
39
|
+
overrideConsoleLog(parentPort, {
|
|
40
|
+
console,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
overrideConsoleError(parentPort, {
|
|
44
|
+
console,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
34
47
|
|
|
35
48
|
export default await cli({
|
|
36
49
|
stdout,
|
package/lib/formatter/harness.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {stringify} = require('flatted');
|
|
4
|
+
const SPLITTER = '>[supertape-splitter]<';
|
|
5
|
+
const CONSOLE_LOG = 'console:log';
|
|
6
|
+
const CONSOLE_ERROR = 'console:error';
|
|
7
|
+
|
|
8
|
+
module.exports.CONSOLE_ERROR = CONSOLE_ERROR;
|
|
9
|
+
module.exports.CONSOLE_LOG = CONSOLE_LOG;
|
|
10
|
+
module.exports.SPLITTER = SPLITTER;
|
|
11
|
+
|
|
12
|
+
module.exports.overrideConsoleLog = (parentPort, {console = global.console} = {}) => {
|
|
13
|
+
const {log} = console;
|
|
14
|
+
|
|
15
|
+
console.log = createConsoleMethod(CONSOLE_LOG, parentPort);
|
|
16
|
+
return {
|
|
17
|
+
getBackConsoleLog: () => {
|
|
18
|
+
console.log = log;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports.overrideConsoleError = (parentPort, {console = global.console} = {}) => {
|
|
24
|
+
const {error} = console;
|
|
25
|
+
|
|
26
|
+
console.error = createConsoleMethod(CONSOLE_ERROR, parentPort);
|
|
27
|
+
return {
|
|
28
|
+
getBackConsoleError: () => {
|
|
29
|
+
console.error = error;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const createConsoleMethod = (type, parentPort) => (...messages) => {
|
|
35
|
+
const prepared = [];
|
|
36
|
+
|
|
37
|
+
for (const message of messages)
|
|
38
|
+
prepared.push(stringify(message));
|
|
39
|
+
|
|
40
|
+
parentPort.postMessage([
|
|
41
|
+
type, {
|
|
42
|
+
message: prepared.join(SPLITTER),
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports._createConsoleLog = createConsoleMethod;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supertape",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.7.0",
|
|
4
4
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
5
5
|
"description": "📼 Supertape simplest high speed test runner with superpowers",
|
|
6
6
|
"homepage": "http://github.com/coderaiser/supertape",
|
|
@@ -45,12 +45,13 @@
|
|
|
45
45
|
"@supertape/engine-loader": "^2.0.0",
|
|
46
46
|
"@supertape/formatter-fail": "^3.0.0",
|
|
47
47
|
"@supertape/formatter-json-lines": "^2.0.0",
|
|
48
|
-
"@supertape/formatter-progress-bar": "^
|
|
48
|
+
"@supertape/formatter-progress-bar": "^6.0.0",
|
|
49
49
|
"@supertape/formatter-short": "^2.0.0",
|
|
50
50
|
"@supertape/formatter-tap": "^3.0.0",
|
|
51
51
|
"@supertape/formatter-time": "^1.0.0",
|
|
52
52
|
"@supertape/operator-stub": "^3.0.0",
|
|
53
53
|
"cli-progress": "^3.8.2",
|
|
54
|
+
"flatted": "^3.3.1",
|
|
54
55
|
"fullstore": "^3.0.0",
|
|
55
56
|
"glob": "^10.3.10",
|
|
56
57
|
"jest-diff": "^29.0.1",
|
|
@@ -73,11 +74,10 @@
|
|
|
73
74
|
"testing"
|
|
74
75
|
],
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"@babel/core": "^8.0.0-alpha.5",
|
|
77
77
|
"@iocmd/wait": "^2.1.0",
|
|
78
|
-
"@putout/eslint-flat": "^
|
|
78
|
+
"@putout/eslint-flat": "^2.0.0",
|
|
79
79
|
"c8": "^9.0.0",
|
|
80
|
-
"check-dts": "^0.
|
|
80
|
+
"check-dts": "^0.8.0",
|
|
81
81
|
"currify": "^4.0.0",
|
|
82
82
|
"eslint": "^9.1.1",
|
|
83
83
|
"eslint-plugin-putout": "^22.0.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"pullout": "^5.0.1",
|
|
90
90
|
"putout": "^35.0.0",
|
|
91
91
|
"runsome": "^1.0.0",
|
|
92
|
-
"try-catch": "^3.0.
|
|
92
|
+
"try-catch": "^3.0.1",
|
|
93
93
|
"typescript": "^5.1.6"
|
|
94
94
|
},
|
|
95
95
|
"license": "MIT",
|