vona-cli-set-api 1.1.128 → 1.1.130
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/dist/index.js +6 -9
- package/dist-toolsIsolate/test.js +72 -33
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -991,15 +991,12 @@ class CliBinTest extends BeanCliBase {
|
|
|
991
991
|
}
|
|
992
992
|
args = args.concat([getImportEsm(), testFile, projectPath, (!!argv.coverage).toString(), patterns.join(',')]);
|
|
993
993
|
// args = args.concat(['--experimental-transform-types', getImportEsm(), testFile, projectPath, (!!argv.coverage).toString(), patterns.join(',')]);
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
cwd: projectPath
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
994
|
+
await this.helper.spawnExe({
|
|
995
|
+
cmd: 'node',
|
|
996
|
+
args,
|
|
997
|
+
options: {
|
|
998
|
+
cwd: projectPath
|
|
999
|
+
}
|
|
1003
1000
|
});
|
|
1004
1001
|
}
|
|
1005
1002
|
async _outputCoverageReportViewer(projectPath) {
|
|
@@ -5,6 +5,7 @@ import { globby } from 'globby';
|
|
|
5
5
|
import { createWriteStream } from 'node:fs';
|
|
6
6
|
import os from 'node:os';
|
|
7
7
|
import path from 'node:path';
|
|
8
|
+
import { pipeline } from 'node:stream/promises';
|
|
8
9
|
import { run } from 'node:test';
|
|
9
10
|
import { lcov, spec } from 'node:test/reporters';
|
|
10
11
|
import { fileURLToPath } from 'node:url';
|
|
@@ -59,9 +60,27 @@ async function testRun(projectPath, coverage, patterns) {
|
|
|
59
60
|
];
|
|
60
61
|
// app
|
|
61
62
|
const app = await createGeneralApp(projectPath);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
let testError;
|
|
64
|
+
let closeError;
|
|
65
|
+
let closePromise;
|
|
66
|
+
const closeApplication = async () => {
|
|
67
|
+
const [_, error] = await catchError(() => app.close());
|
|
68
|
+
closeError = error;
|
|
69
|
+
// handles
|
|
70
|
+
if (process.env.TEST_WHYISNODERUNNING === 'true') {
|
|
71
|
+
await sleep(2000);
|
|
72
|
+
const handles = process._getActiveHandles();
|
|
73
|
+
if (handles.length > 3) {
|
|
74
|
+
whyIsNodeRunning();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const closeApplicationOnce = () => {
|
|
79
|
+
return (closePromise ??= closeApplication());
|
|
80
|
+
};
|
|
81
|
+
try {
|
|
82
|
+
// concurrency
|
|
83
|
+
const concurrency = await prepareConcurrency(app);
|
|
65
84
|
const testStream = run({
|
|
66
85
|
isolation: 'none',
|
|
67
86
|
concurrency,
|
|
@@ -76,49 +95,69 @@ async function testRun(projectPath, coverage, patterns) {
|
|
|
76
95
|
.on('test:coverage', data => {
|
|
77
96
|
outputCoverageReport(data.summary.totals);
|
|
78
97
|
})
|
|
79
|
-
.on('test:
|
|
80
|
-
resolve(undefined);
|
|
81
|
-
})
|
|
82
|
-
.on('test:pass', async (t) => {
|
|
98
|
+
.on('test:pass', t => {
|
|
83
99
|
if (t.name === '---done---') {
|
|
84
|
-
|
|
85
|
-
return app.close();
|
|
86
|
-
});
|
|
87
|
-
if (err) {
|
|
88
|
-
console.error(err);
|
|
89
|
-
}
|
|
90
|
-
// handles
|
|
91
|
-
if (process.env.TEST_WHYISNODERUNNING === 'true') {
|
|
92
|
-
await sleep(2000);
|
|
93
|
-
const handles = process._getActiveHandles();
|
|
94
|
-
if (handles.length > 3) {
|
|
95
|
-
whyIsNodeRunning();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
100
|
+
void closeApplicationOnce();
|
|
98
101
|
}
|
|
99
102
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
const summaryPromise = waitForTestSummary(testStream);
|
|
104
|
+
const reporterPromise = coverage
|
|
105
|
+
? (() => {
|
|
106
|
+
const reporterDir = path.join(projectPath, 'coverage');
|
|
107
|
+
fse.ensureDirSync(reporterDir);
|
|
108
|
+
const reporterLcov = createWriteStream(path.join(reporterDir, 'lcov.info'));
|
|
109
|
+
return pipeline(testStream.compose(lcov), reporterLcov);
|
|
110
|
+
})()
|
|
111
|
+
: pipeline(testStream.compose(spec), process.stdout, { end: false });
|
|
112
|
+
const [summarySuccess, [, reporterError]] = await Promise.all([
|
|
113
|
+
summaryPromise,
|
|
114
|
+
catchError(() => reporterPromise),
|
|
115
|
+
]);
|
|
116
|
+
if (!summarySuccess) {
|
|
117
|
+
throw new Error('node:test reported failed tests');
|
|
105
118
|
}
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
if (reporterError) {
|
|
120
|
+
throw reporterError;
|
|
108
121
|
}
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
testError = error;
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
await closeApplicationOnce();
|
|
128
|
+
}
|
|
129
|
+
if (testError) {
|
|
130
|
+
if (closeError)
|
|
131
|
+
console.error(closeError);
|
|
132
|
+
throw toError(testError);
|
|
133
|
+
}
|
|
134
|
+
if (closeError) {
|
|
135
|
+
throw toError(closeError);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function toError(error) {
|
|
139
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
140
|
+
}
|
|
141
|
+
function waitForTestSummary(testStream) {
|
|
142
|
+
return new Promise((resolve, reject) => {
|
|
143
|
+
testStream.once('test:summary', summary => resolve(summary.success)).once('error', reject);
|
|
109
144
|
});
|
|
110
145
|
}
|
|
111
146
|
async function prepareConcurrency(app) {
|
|
112
147
|
// check
|
|
148
|
+
const configured = process.env.TEST_CONCURRENCY;
|
|
113
149
|
let concurrency = 1;
|
|
114
|
-
if (
|
|
115
|
-
concurrency = os.cpus().length;
|
|
116
|
-
}
|
|
117
|
-
else if (process.env.TEST_CONCURRENCY === 'false') {
|
|
150
|
+
if (configured === 'false') {
|
|
118
151
|
concurrency = 1;
|
|
119
152
|
}
|
|
153
|
+
else if (configured === undefined || configured === 'true') {
|
|
154
|
+
concurrency = Math.max(1, os.cpus().length);
|
|
155
|
+
}
|
|
120
156
|
else {
|
|
121
|
-
concurrency = Number.parseInt(
|
|
157
|
+
concurrency = Number.parseInt(configured, 10);
|
|
158
|
+
if (!Number.isSafeInteger(concurrency) || concurrency < 1) {
|
|
159
|
+
throw new Error(`TEST_CONCURRENCY must be true, false, or a positive integer; received ${configured}`);
|
|
160
|
+
}
|
|
122
161
|
}
|
|
123
162
|
if (concurrency === 1)
|
|
124
163
|
return concurrency;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-cli-set-api",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "1.1.130",
|
|
4
|
+
"gitHead": "94b4f86ba6b9015d9add7de4e03e19db9a084fd2",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"framework",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"ts-node-maintained": "^10.9.6",
|
|
74
74
|
"urllib": "^4.9.0",
|
|
75
75
|
"uuid": "^11.1.0",
|
|
76
|
-
"vona-core": "^5.1.
|
|
76
|
+
"vona-core": "^5.1.33",
|
|
77
77
|
"why-is-node-running": "^3.2.2",
|
|
78
78
|
"yargs-parser": "^22.0.0"
|
|
79
79
|
}
|