@rstest/core 0.8.2 → 0.8.4
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/0~130.js +1 -2
- package/dist/0~1472.js +2 -3
- package/dist/0~1981.js +1 -2
- package/dist/0~2173.js +6 -4
- package/dist/0~2255.js +2 -3
- package/dist/0~3062.js +1 -2
- package/dist/0~3346.js +1 -2
- package/dist/0~3919.js +1 -2
- package/dist/0~4403.js +1 -2
- package/dist/0~4809.js +1 -2
- package/dist/0~5835.js +6 -10
- package/dist/0~62.js +1 -2
- package/dist/0~6588.js +5 -5
- package/dist/0~6907.js +1 -2
- package/dist/0~6923.js +6 -10
- package/dist/0~7583.js +3 -4
- package/dist/0~7882.js +7 -8
- package/dist/0~8426.js +1 -2
- package/dist/0~89.js +212 -15
- package/dist/0~9348.js +1 -2
- package/dist/0~9634.js +5 -5
- package/dist/1157.js +4 -97
- package/dist/1294.js +1 -2
- package/dist/1672.js +1 -2
- package/dist/3160.js +106 -10
- package/dist/4397.js +1 -2
- package/dist/4484.js +1 -2
- package/dist/487.js +3 -4
- package/dist/4881.js +1 -2
- package/dist/4899.js +2 -2
- package/dist/5734.js +1 -2
- package/dist/6151.js +9 -2
- package/dist/6198.js +1 -2
- package/dist/6973.js +2 -3
- package/dist/7011.js +1 -2
- package/dist/721.js +1 -2
- package/dist/9131.js +35 -32
- package/dist/{3216.js → 9869.js} +20 -3
- package/dist/browser-runtime/389.js +9 -0
- package/dist/browser-runtime/389.js.LICENSE.txt +22 -0
- package/dist/browser-runtime/index.d.ts +27 -1
- package/dist/browser.d.ts +29 -1
- package/dist/browser.js +1 -2
- package/dist/globalSetupWorker.js +5 -6
- package/dist/index.d.ts +27 -1
- package/dist/index.js +1 -2
- package/dist/mockRuntimeCode.js +63 -174
- package/dist/rslib-runtime.js +1 -2
- package/dist/worker.d.ts +27 -1
- package/dist/worker.js +30 -20
- package/package.json +2 -2
- /package/dist/{1157.js.LICENSE.txt → 3160.js.LICENSE.txt} +0 -0
package/dist/0~130.js
CHANGED
package/dist/0~1472.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { createRequire } from "./4881.js";
|
|
4
3
|
import { pathToFileURL } from "./6198.js";
|
|
5
4
|
import "./1157.js";
|
|
6
5
|
import { logger as logger_logger, color } from "./3160.js";
|
|
7
6
|
async function loadBrowserModule(options = {}) {
|
|
8
|
-
const coreVersion = "0.8.
|
|
7
|
+
const coreVersion = "0.8.4";
|
|
9
8
|
const { projectRoots = [] } = options;
|
|
10
9
|
let browserModule;
|
|
11
10
|
let browserVersion;
|
package/dist/0~1981.js
CHANGED
package/dist/0~2173.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { resolveShardedEntries, getTestEntries } from "./1157.js";
|
|
4
3
|
import { createCoverageProvider } from "./5734.js";
|
|
5
4
|
import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~89.js";
|
|
@@ -148,9 +147,10 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
148
147
|
}
|
|
149
148
|
async function runBrowserModeTests(context, browserProjects, options) {
|
|
150
149
|
const projectRoots = browserProjects.map((p)=>p.rootPath);
|
|
151
|
-
const { runBrowserTests } = await loadBrowserModule({
|
|
150
|
+
const { validateBrowserConfig, runBrowserTests } = await loadBrowserModule({
|
|
152
151
|
projectRoots
|
|
153
152
|
});
|
|
153
|
+
validateBrowserConfig(context);
|
|
154
154
|
return runBrowserTests(context, options);
|
|
155
155
|
}
|
|
156
156
|
async function runTests(context) {
|
|
@@ -166,7 +166,7 @@ async function runTests(context) {
|
|
|
166
166
|
const browserResult = await runBrowserModeTests(context, browserProjects, {
|
|
167
167
|
skipOnTestRunEnd: false
|
|
168
168
|
});
|
|
169
|
-
if (coverage.enabled && browserResult?.results) {
|
|
169
|
+
if (coverage.enabled && browserResult?.results.length && !browserResult.unhandledErrors?.length) {
|
|
170
170
|
const coverageProvider = await createCoverageProvider(coverage, context.rootPath);
|
|
171
171
|
if (coverageProvider) {
|
|
172
172
|
const { generateCoverage } = await import("./0~4403.js").then((mod)=>({
|
|
@@ -214,6 +214,7 @@ async function runTests(context) {
|
|
|
214
214
|
skipOnTestRunEnd: shouldUnifyReporter,
|
|
215
215
|
shardedEntries: shard ? browserEntries : void 0
|
|
216
216
|
});
|
|
217
|
+
browserResultPromise.catch(()=>{});
|
|
217
218
|
}
|
|
218
219
|
if (!hasNodeTestsToRun) {
|
|
219
220
|
if (browserResultPromise) await browserResultPromise;
|
|
@@ -339,6 +340,7 @@ async function runTests(context) {
|
|
|
339
340
|
const errors = returns.flatMap((r)=>r.errors || []);
|
|
340
341
|
if (shouldUnifyReporter && browserResult?.results) results.push(...browserResult.results);
|
|
341
342
|
if (shouldUnifyReporter && browserResult?.testResults) testResults.push(...browserResult.testResults);
|
|
343
|
+
if (shouldUnifyReporter && browserResult?.unhandledErrors) errors.push(...browserResult.unhandledErrors);
|
|
342
344
|
context.updateReporterResultState(results, testResults, currentDeletedEntries);
|
|
343
345
|
const nodeHasFailure = results.some((r)=>'fail' === r.status) || errors.length;
|
|
344
346
|
const browserHasFailure = shouldUnifyReporter && browserResult?.hasFailure;
|
package/dist/0~2255.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
3
|
import "./3160.js";
|
|
5
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
4
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
6
5
|
const pluginCoverageCore = (coverageOptions)=>({
|
|
7
6
|
name: 'rstest:coverage-core',
|
|
8
7
|
setup: (api)=>{
|
package/dist/0~3062.js
CHANGED
package/dist/0~3346.js
CHANGED
package/dist/0~3919.js
CHANGED
package/dist/0~4403.js
CHANGED
package/dist/0~4809.js
CHANGED
package/dist/0~5835.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
3
|
import { logger as logger_logger } from "./3160.js";
|
|
5
4
|
import { createRequire as external_node_module_createRequire } from "./4881.js";
|
|
6
5
|
import { pathToFileURL } from "./6198.js";
|
|
7
6
|
import { node_vm, asModule, shouldInterop, interopModule } from "./0~3346.js";
|
|
8
7
|
import { posix } from "./7011.js";
|
|
9
|
-
const external_node_path_ = __webpack_require__("path");
|
|
10
|
-
let latestAssetFiles = {};
|
|
11
|
-
const updateLatestAssetFiles = (assetFiles)=>{
|
|
12
|
-
latestAssetFiles = assetFiles;
|
|
13
|
-
};
|
|
8
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
14
9
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
15
10
|
const createRequire = (filename, distPath, rstestContext, assetFiles, interopDefault)=>{
|
|
16
11
|
const _require = (()=>{
|
|
@@ -23,7 +18,7 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
23
18
|
const require = (id)=>{
|
|
24
19
|
const currentDirectory = posix.dirname(distPath);
|
|
25
20
|
const joinedPath = isRelativePath(id) ? posix.join(currentDirectory, id) : id;
|
|
26
|
-
const content = assetFiles[joinedPath]
|
|
21
|
+
const content = assetFiles[joinedPath];
|
|
27
22
|
if (content) try {
|
|
28
23
|
return cacheableLoadModule({
|
|
29
24
|
codeContent: content,
|
|
@@ -105,7 +100,7 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
|
|
|
105
100
|
require: createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
|
|
106
101
|
readWasmFile: (wasmPath, callback)=>{
|
|
107
102
|
const joinedPath = isRelativePath(wasmPath) ? posix.join(posix.dirname(distPath), wasmPath) : wasmPath;
|
|
108
|
-
const content = assetFiles[posix.normalize(joinedPath)]
|
|
103
|
+
const content = assetFiles[posix.normalize(joinedPath)];
|
|
109
104
|
if (content) callback(null, Buffer.from(content, 'base64'));
|
|
110
105
|
else callback(new Error(`WASM file ${joinedPath} not found in asset files.`));
|
|
111
106
|
},
|
|
@@ -146,4 +141,5 @@ const cacheableLoadModule = ({ codeContent, distPath, testPath, rstestContext, a
|
|
|
146
141
|
moduleCache.set(testPath, mod);
|
|
147
142
|
return mod;
|
|
148
143
|
};
|
|
149
|
-
|
|
144
|
+
const clearModuleCache = ()=>moduleCache.clear();
|
|
145
|
+
export { cacheableLoadModule, clearModuleCache, loadModule };
|
package/dist/0~62.js
CHANGED
package/dist/0~6588.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import { logger as logger_logger,
|
|
3
|
+
import { color, logger as logger_logger, isTTY } from "./3160.js";
|
|
5
4
|
import { runRest } from "./9131.js";
|
|
6
5
|
import "./1157.js";
|
|
7
6
|
const GLOB_REGEX = /[*?{}[\]()!@+|]/;
|
|
@@ -28,13 +27,14 @@ async function createChokidar(pathOrGlobs, root, options) {
|
|
|
28
27
|
}
|
|
29
28
|
return chokidar.watch(Array.from(watchFiles), options);
|
|
30
29
|
}
|
|
31
|
-
const external_node_path_ = __webpack_require__("path");
|
|
30
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
31
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
32
32
|
let cleaners = [];
|
|
33
33
|
const onBeforeRestart = (cleaner)=>{
|
|
34
34
|
cleaners.push(cleaner);
|
|
35
35
|
};
|
|
36
36
|
const clearConsole = ()=>{
|
|
37
|
-
if (isTTY() && !process.env.DEBUG &&
|
|
37
|
+
if (isTTY() && !process.env.DEBUG && picocolors.isColorSupported) process.stdout.write('\x1B[H\x1B[2J');
|
|
38
38
|
};
|
|
39
39
|
const beforeRestart = async ({ filePath, root, clear = true })=>{
|
|
40
40
|
if (clear) clearConsole();
|
package/dist/0~6907.js
CHANGED
package/dist/0~6923.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
3
|
import { logger as logger_logger } from "./3160.js";
|
|
5
4
|
import { pathToFileURL } from "./6198.js";
|
|
6
5
|
import { node_vm, interopModule, shouldInterop } from "./0~3346.js";
|
|
7
6
|
import { posix } from "./7011.js";
|
|
8
|
-
const external_node_path_ = __webpack_require__("path");
|
|
7
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
9
8
|
var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
|
|
10
9
|
EsmMode[EsmMode["Unknown"] = 0] = "Unknown";
|
|
11
10
|
EsmMode[EsmMode["Evaluated"] = 1] = "Evaluated";
|
|
@@ -13,14 +12,10 @@ var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
|
|
|
13
12
|
return EsmMode;
|
|
14
13
|
}({});
|
|
15
14
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
16
|
-
let latestAssetFiles = {};
|
|
17
|
-
const updateLatestAssetFiles = (assetFiles)=>{
|
|
18
|
-
latestAssetFiles = assetFiles;
|
|
19
|
-
};
|
|
20
15
|
const defineRstestDynamicImport = ({ distPath, testPath, assetFiles, interopDefault, returnModule, esmMode })=>async (specifier, importAttributes)=>{
|
|
21
16
|
const currentDirectory = posix.dirname(distPath);
|
|
22
17
|
const joinedPath = isRelativePath(specifier) ? posix.join(currentDirectory, specifier) : specifier;
|
|
23
|
-
const content = assetFiles[joinedPath]
|
|
18
|
+
const content = assetFiles[joinedPath];
|
|
24
19
|
if (content) try {
|
|
25
20
|
return await loadModule({
|
|
26
21
|
codeContent: content,
|
|
@@ -118,7 +113,7 @@ const loadModule = async ({ codeContent, distPath, testPath, assetFiles, interop
|
|
|
118
113
|
});
|
|
119
114
|
meta.readWasmFile = (wasmPath, callback)=>{
|
|
120
115
|
const joinedPath = isRelativePath(wasmPath.pathname) ? posix.join(posix.dirname(distPath), wasmPath.pathname) : wasmPath.pathname;
|
|
121
|
-
const content = assetFiles[posix.normalize(joinedPath)]
|
|
116
|
+
const content = assetFiles[posix.normalize(joinedPath)];
|
|
122
117
|
if (content) callback(null, Buffer.from(content, 'base64'));
|
|
123
118
|
else callback(new Error(`WASM file ${joinedPath} not found in asset files.`));
|
|
124
119
|
};
|
|
@@ -151,4 +146,5 @@ const loadModule = async ({ codeContent, distPath, testPath, assetFiles, interop
|
|
|
151
146
|
const ns = esm.namespace;
|
|
152
147
|
return ns.default && ns.default instanceof Promise ? ns.default : ns;
|
|
153
148
|
};
|
|
154
|
-
|
|
149
|
+
const clearModuleCache = ()=>esmCache.clear();
|
|
150
|
+
export { asModule, clearModuleCache, loadEsModule_EsmMode, loadModule };
|
package/dist/0~7583.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/*! For license information please see 0~7583.js.LICENSE.txt */
|
|
2
|
-
import
|
|
3
|
-
/*#__PURE__*/ import.meta.url;
|
|
2
|
+
import "node:module";
|
|
4
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
5
4
|
import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "fs/promises";
|
|
6
5
|
import "./3160.js";
|
|
7
6
|
import { readdir as promises_readdir, lstat as promises_lstat, promises_stat as promises_promises_stat, realpath as external_node_fs_promises_realpath } from "./1157.js";
|
|
8
7
|
import { Readable } from "./0~1981.js";
|
|
9
8
|
import { EventEmitter } from "./9131.js";
|
|
10
|
-
const external_node_path_ = __webpack_require__("path");
|
|
9
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
11
10
|
const EntryTypes = {
|
|
12
11
|
FILE_TYPE: 'files',
|
|
13
12
|
DIR_TYPE: 'directories',
|
|
@@ -221,7 +220,7 @@ function readdirp(root, options = {}) {
|
|
|
221
220
|
options.root = root;
|
|
222
221
|
return new ReaddirpStream(options);
|
|
223
222
|
}
|
|
224
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
223
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
225
224
|
const external_node_os_ = __webpack_require__("node:os");
|
|
226
225
|
const STR_DATA = 'data';
|
|
227
226
|
const STR_END = 'end';
|
package/dist/0~7882.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import { color } from "./3160.js";
|
|
3
|
+
import { determineAgent, color } from "./3160.js";
|
|
5
4
|
import { detect, resolveCommand } from "./9131.js";
|
|
6
5
|
import { Ie, Me, ye, M, dist_Y, Se, ve, pD, xe } from "./0~9348.js";
|
|
7
|
-
import
|
|
8
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
9
|
-
const external_node_path_ = __webpack_require__("path");
|
|
6
|
+
import "./1157.js";
|
|
7
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
8
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
10
9
|
function getUniqueBaseName(dir, baseName, ext) {
|
|
11
10
|
const fullPath = external_node_path_["default"].join(dir, `${baseName}${ext}`);
|
|
12
11
|
if (!external_node_fs_["default"].existsSync(fullPath)) return baseName;
|
|
@@ -373,7 +372,7 @@ async function createInteractive(cwd, projectInfo, isAgent) {
|
|
|
373
372
|
}
|
|
374
373
|
const provider = providerSelection;
|
|
375
374
|
const preview = computeFilePreview(cwd, projectInfo);
|
|
376
|
-
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.8.
|
|
375
|
+
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.8.4");
|
|
377
376
|
const depsList = Object.entries(deps).map(([name, version])=>`${name}@${version}`).join(', ');
|
|
378
377
|
const previewLines = [
|
|
379
378
|
`${color.cyan('+')} Create ${preview.configFile}`,
|
|
@@ -451,7 +450,7 @@ async function generateFiles(cwd, projectInfo, provider) {
|
|
|
451
450
|
updatePackageJsonScripts(cwd, {
|
|
452
451
|
'test:browser': 'rstest --config=rstest.browser.config.ts'
|
|
453
452
|
});
|
|
454
|
-
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.8.
|
|
453
|
+
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.8.4");
|
|
455
454
|
updatePackageJsonDevDeps(cwd, deps);
|
|
456
455
|
return createdFiles;
|
|
457
456
|
}
|
package/dist/0~8426.js
CHANGED
package/dist/0~89.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
3
|
import node_events from "node:events";
|
|
5
4
|
import { Tinypool } from "tinypool";
|
|
6
5
|
import node_inspector from "node:inspector";
|
|
7
6
|
import { basename, needFlagExperimentalDetectModule, isDeno, dirname, castArray, resolve as pathe_M_eThtNZ_resolve, serializableConfig, node_process, isDebug, color, getForceColorEnv, ADDITIONAL_NODE_BUILTINS, bgColor, join } from "./3160.js";
|
|
8
7
|
import { fileURLToPath } from "./6198.js";
|
|
9
|
-
import { node_v8, createBirpc } from "./
|
|
8
|
+
import { node_v8, parseWorkerMetaMessage, createBirpc } from "./9869.js";
|
|
10
9
|
import { TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB } from "./1157.js";
|
|
11
10
|
import { posix } from "./7011.js";
|
|
12
11
|
import { isBuiltin } from "./4881.js";
|
|
@@ -22,9 +21,184 @@ function memory_isMemorySufficient(options) {
|
|
|
22
21
|
const isMemorySufficient = memoryUsageRatio < memoryThreshold && heapUsed < maxHeapSize;
|
|
23
22
|
return isMemorySufficient;
|
|
24
23
|
}
|
|
24
|
+
const MAX_CAPTURED_STDERR_BYTES = 131072;
|
|
25
|
+
const STDERR_SETTLE_MAX_WAIT = 200;
|
|
26
|
+
const WORKER_EXIT_ERROR = 'Worker exited unexpectedly';
|
|
27
|
+
const MAX_STDERR_MESSAGE_BYTES = 65536;
|
|
28
|
+
const createDeferred = ()=>{
|
|
29
|
+
let resolvePromise = ()=>void 0;
|
|
30
|
+
const deferred = {
|
|
31
|
+
settled: false,
|
|
32
|
+
resolve (value) {
|
|
33
|
+
if (deferred.settled) return;
|
|
34
|
+
deferred.settled = true;
|
|
35
|
+
resolvePromise(value);
|
|
36
|
+
},
|
|
37
|
+
promise: new Promise((resolve)=>{
|
|
38
|
+
resolvePromise = resolve;
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
return deferred;
|
|
42
|
+
};
|
|
43
|
+
const withTimeout = (promise, timeout)=>new Promise((resolve)=>{
|
|
44
|
+
let finished = false;
|
|
45
|
+
const timer = setTimeout(()=>{
|
|
46
|
+
if (finished) return;
|
|
47
|
+
finished = true;
|
|
48
|
+
resolve(void 0);
|
|
49
|
+
}, timeout);
|
|
50
|
+
timer.unref();
|
|
51
|
+
promise.then((value)=>{
|
|
52
|
+
if (finished) return;
|
|
53
|
+
finished = true;
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
resolve(value);
|
|
56
|
+
}, ()=>{
|
|
57
|
+
if (finished) return;
|
|
58
|
+
finished = true;
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
resolve(void 0);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const formatCapturedStderr = (text)=>{
|
|
64
|
+
const bytes = Buffer.byteLength(text);
|
|
65
|
+
if (bytes <= MAX_STDERR_MESSAGE_BYTES) return text;
|
|
66
|
+
const half = Math.floor(MAX_STDERR_MESSAGE_BYTES / 2);
|
|
67
|
+
const head = text.slice(0, half);
|
|
68
|
+
const tail = text.slice(-half);
|
|
69
|
+
const hiddenBytes = bytes - Buffer.byteLength(head) - Buffer.byteLength(tail);
|
|
70
|
+
return `${head}\n\n... [truncated ${hiddenBytes} bytes of stderr] ...\n\n${tail}`;
|
|
71
|
+
};
|
|
72
|
+
const getChildProcessByPid = (pool, pid)=>{
|
|
73
|
+
for (const worker of pool.threads){
|
|
74
|
+
const childProcess = worker.process;
|
|
75
|
+
if (childProcess?.pid === pid) return childProcess;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const createWorkerStderrCapture = (pool)=>{
|
|
79
|
+
const workerStates = new Map();
|
|
80
|
+
const taskBindings = new Map();
|
|
81
|
+
const taskBindingWaiters = new Map();
|
|
82
|
+
const workerCloseWaiters = new Map();
|
|
83
|
+
const trackedWorkers = new Map();
|
|
84
|
+
const getWorkerState = (pid)=>{
|
|
85
|
+
let state = workerStates.get(pid);
|
|
86
|
+
if (!state) {
|
|
87
|
+
state = {
|
|
88
|
+
bytes: 0,
|
|
89
|
+
chunks: [],
|
|
90
|
+
seq: 0
|
|
91
|
+
};
|
|
92
|
+
workerStates.set(pid, state);
|
|
93
|
+
}
|
|
94
|
+
return state;
|
|
95
|
+
};
|
|
96
|
+
const appendStderr = (pid, text)=>{
|
|
97
|
+
if (!text) return;
|
|
98
|
+
const state = getWorkerState(pid);
|
|
99
|
+
const bytes = Buffer.byteLength(text);
|
|
100
|
+
state.seq += 1;
|
|
101
|
+
state.bytes += bytes;
|
|
102
|
+
state.chunks.push({
|
|
103
|
+
bytes,
|
|
104
|
+
seq: state.seq,
|
|
105
|
+
text
|
|
106
|
+
});
|
|
107
|
+
while(state.bytes > MAX_CAPTURED_STDERR_BYTES && state.chunks.length > 0){
|
|
108
|
+
const dropped = state.chunks.shift();
|
|
109
|
+
if (dropped) state.bytes -= dropped.bytes;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const attachWorker = (pid)=>{
|
|
113
|
+
if (trackedWorkers.has(pid)) return;
|
|
114
|
+
const childProcess = getChildProcessByPid(pool, pid);
|
|
115
|
+
const stderr = childProcess?.stderr;
|
|
116
|
+
if (!childProcess || !stderr) return;
|
|
117
|
+
const closeWaiter = createDeferred();
|
|
118
|
+
workerCloseWaiters.set(pid, closeWaiter);
|
|
119
|
+
const onData = (chunk)=>{
|
|
120
|
+
const text = 'string' == typeof chunk ? chunk : chunk.toString();
|
|
121
|
+
appendStderr(pid, text);
|
|
122
|
+
};
|
|
123
|
+
stderr.on('data', onData);
|
|
124
|
+
trackedWorkers.set(pid, {
|
|
125
|
+
onData,
|
|
126
|
+
stream: stderr
|
|
127
|
+
});
|
|
128
|
+
const detachTrackedWorker = ()=>{
|
|
129
|
+
const tracked = trackedWorkers.get(pid);
|
|
130
|
+
if (!tracked) return;
|
|
131
|
+
tracked.stream.off('data', tracked.onData);
|
|
132
|
+
trackedWorkers.delete(pid);
|
|
133
|
+
};
|
|
134
|
+
childProcess.once('close', ()=>{
|
|
135
|
+
detachTrackedWorker();
|
|
136
|
+
closeWaiter.resolve(void 0);
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
const bindTaskToPid = (taskId, pid)=>{
|
|
140
|
+
attachWorker(pid);
|
|
141
|
+
const binding = {
|
|
142
|
+
pid,
|
|
143
|
+
startSeq: getWorkerState(pid).seq
|
|
144
|
+
};
|
|
145
|
+
taskBindings.set(taskId, binding);
|
|
146
|
+
taskBindingWaiters.get(taskId)?.resolve(binding);
|
|
147
|
+
};
|
|
148
|
+
const waitForTaskBinding = async (taskId)=>{
|
|
149
|
+
const binding = taskBindings.get(taskId);
|
|
150
|
+
if (binding) return binding;
|
|
151
|
+
const waiter = taskBindingWaiters.get(taskId);
|
|
152
|
+
if (!waiter) return;
|
|
153
|
+
return withTimeout(waiter.promise, STDERR_SETTLE_MAX_WAIT);
|
|
154
|
+
};
|
|
155
|
+
const waitForWorkerClose = async (pid)=>{
|
|
156
|
+
attachWorker(pid);
|
|
157
|
+
const waiter = workerCloseWaiters.get(pid);
|
|
158
|
+
if (!waiter) return;
|
|
159
|
+
await withTimeout(waiter.promise, STDERR_SETTLE_MAX_WAIT);
|
|
160
|
+
};
|
|
161
|
+
const getTaskStderr = (taskId)=>{
|
|
162
|
+
const binding = taskBindings.get(taskId);
|
|
163
|
+
if (!binding) return '';
|
|
164
|
+
const state = workerStates.get(binding.pid);
|
|
165
|
+
if (!state || 0 === state.chunks.length) return '';
|
|
166
|
+
return state.chunks.filter((chunk)=>chunk.seq > binding.startSeq).map((chunk)=>chunk.text).join('').trim();
|
|
167
|
+
};
|
|
168
|
+
const enhanceWorkerExitError = async (taskId, err)=>{
|
|
169
|
+
if (!(err instanceof Error) || !err.message.includes(WORKER_EXIT_ERROR)) return;
|
|
170
|
+
const binding = taskBindings.get(taskId) ?? await waitForTaskBinding(taskId);
|
|
171
|
+
if (!binding) return;
|
|
172
|
+
await waitForWorkerClose(binding.pid);
|
|
173
|
+
const stderr = formatCapturedStderr(getTaskStderr(taskId));
|
|
174
|
+
if (stderr.length > 0) err.message += `\n\nMaybe related stderr:\n${stderr}`;
|
|
175
|
+
};
|
|
176
|
+
const createTask = (taskId)=>{
|
|
177
|
+
if (!taskBindingWaiters.has(taskId)) taskBindingWaiters.set(taskId, createDeferred());
|
|
178
|
+
};
|
|
179
|
+
const clearTask = (taskId)=>{
|
|
180
|
+
taskBindings.delete(taskId);
|
|
181
|
+
taskBindingWaiters.delete(taskId);
|
|
182
|
+
};
|
|
183
|
+
const cleanup = ()=>{
|
|
184
|
+
for (const { onData, stream } of trackedWorkers.values())stream.off('data', onData);
|
|
185
|
+
trackedWorkers.clear();
|
|
186
|
+
workerStates.clear();
|
|
187
|
+
taskBindings.clear();
|
|
188
|
+
taskBindingWaiters.clear();
|
|
189
|
+
workerCloseWaiters.clear();
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
createTask,
|
|
193
|
+
bindTaskToPid,
|
|
194
|
+
clearTask,
|
|
195
|
+
enhanceWorkerExitError,
|
|
196
|
+
cleanup
|
|
197
|
+
};
|
|
198
|
+
};
|
|
25
199
|
const forks_filename = fileURLToPath(import.meta.url);
|
|
26
200
|
const forks_dirname = dirname(forks_filename);
|
|
27
|
-
function createChannel(rpcMethods) {
|
|
201
|
+
function createChannel(rpcMethods, onWorkerMeta) {
|
|
28
202
|
const emitter = new node_events();
|
|
29
203
|
const cleanup = ()=>emitter.removeAllListeners();
|
|
30
204
|
const events = {
|
|
@@ -36,6 +210,8 @@ function createChannel(rpcMethods) {
|
|
|
36
210
|
emitter.on(events.message, callback);
|
|
37
211
|
},
|
|
38
212
|
postMessage: (message)=>{
|
|
213
|
+
const workerMeta = parseWorkerMetaMessage(message);
|
|
214
|
+
if (workerMeta) return void onWorkerMeta?.(workerMeta);
|
|
39
215
|
emitter.emit(events.response, message);
|
|
40
216
|
}
|
|
41
217
|
};
|
|
@@ -67,29 +243,50 @@ const createForksPool = (poolOptions)=>{
|
|
|
67
243
|
isolateWorkers: isolate
|
|
68
244
|
};
|
|
69
245
|
const pool = new Tinypool(options);
|
|
246
|
+
const stderrCapture = createWorkerStderrCapture(pool);
|
|
247
|
+
let nextTaskId = 0;
|
|
70
248
|
return {
|
|
71
249
|
name: 'forks',
|
|
72
250
|
runTest: async ({ options, rpcMethods })=>{
|
|
73
|
-
const
|
|
251
|
+
const taskId = ++nextTaskId;
|
|
252
|
+
stderrCapture.createTask(taskId);
|
|
253
|
+
const { channel, cleanup } = createChannel(rpcMethods, ({ pid })=>{
|
|
254
|
+
stderrCapture.bindTaskToPid(taskId, pid);
|
|
255
|
+
});
|
|
74
256
|
try {
|
|
75
257
|
return await pool.run(options, {
|
|
76
258
|
channel
|
|
77
259
|
});
|
|
260
|
+
} catch (err) {
|
|
261
|
+
await stderrCapture.enhanceWorkerExitError(taskId, err);
|
|
262
|
+
throw err;
|
|
78
263
|
} finally{
|
|
79
264
|
cleanup();
|
|
265
|
+
stderrCapture.clearTask(taskId);
|
|
80
266
|
}
|
|
81
267
|
},
|
|
82
268
|
collectTests: async ({ options, rpcMethods })=>{
|
|
83
|
-
const
|
|
269
|
+
const taskId = ++nextTaskId;
|
|
270
|
+
stderrCapture.createTask(taskId);
|
|
271
|
+
const { channel, cleanup } = createChannel(rpcMethods, ({ pid })=>{
|
|
272
|
+
stderrCapture.bindTaskToPid(taskId, pid);
|
|
273
|
+
});
|
|
84
274
|
try {
|
|
85
275
|
return await pool.run(options, {
|
|
86
276
|
channel
|
|
87
277
|
});
|
|
278
|
+
} catch (err) {
|
|
279
|
+
await stderrCapture.enhanceWorkerExitError(taskId, err);
|
|
280
|
+
throw err;
|
|
88
281
|
} finally{
|
|
89
282
|
cleanup();
|
|
283
|
+
stderrCapture.clearTask(taskId);
|
|
90
284
|
}
|
|
91
285
|
},
|
|
92
|
-
close: ()=>
|
|
286
|
+
close: async ()=>{
|
|
287
|
+
stderrCapture.cleanup();
|
|
288
|
+
await pool.destroy();
|
|
289
|
+
}
|
|
93
290
|
};
|
|
94
291
|
};
|
|
95
292
|
const external_node_os_ = __webpack_require__("node:os");
|
|
@@ -182,8 +379,8 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
182
379
|
],
|
|
183
380
|
env: {
|
|
184
381
|
NODE_ENV: 'test',
|
|
185
|
-
...
|
|
186
|
-
...
|
|
382
|
+
...getForceColorEnv(),
|
|
383
|
+
...process.env
|
|
187
384
|
}
|
|
188
385
|
});
|
|
189
386
|
const rpcMethods = {
|
|
@@ -353,8 +550,8 @@ async function createSetupPool() {
|
|
|
353
550
|
isolateWorkers: false,
|
|
354
551
|
env: {
|
|
355
552
|
NODE_ENV: 'test',
|
|
356
|
-
...
|
|
357
|
-
...
|
|
553
|
+
...getForceColorEnv(),
|
|
554
|
+
...process.env
|
|
358
555
|
}
|
|
359
556
|
};
|
|
360
557
|
const pool = new Tinypool(options);
|
|
@@ -400,7 +597,7 @@ async function runGlobalTeardown() {
|
|
|
400
597
|
process.exitCode = 1;
|
|
401
598
|
}
|
|
402
599
|
}
|
|
403
|
-
const external_node_path_ = __webpack_require__("path");
|
|
600
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
404
601
|
const RUNTIME_CHUNK_NAME = 'runtime';
|
|
405
602
|
const requireShim = `// Rstest ESM shims
|
|
406
603
|
import __rstest_shim_module__ from 'node:module';
|
|
@@ -680,7 +877,7 @@ const pluginInspect = (options)=>{
|
|
|
680
877
|
}
|
|
681
878
|
} : null;
|
|
682
879
|
};
|
|
683
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
880
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
684
881
|
const mockRuntime_dirname = external_node_path_["default"].dirname(fileURLToPath(import.meta.url));
|
|
685
882
|
class MockRuntimeRspackPlugin {
|
|
686
883
|
outputModule;
|
|
@@ -701,11 +898,11 @@ class MockRuntimeRspackPlugin {
|
|
|
701
898
|
compiler.hooks.compilation.tap('RstestMockPlugin', (compilation)=>{
|
|
702
899
|
compilation.hooks.runtimeModule.tap('RstestMockChunkLoadingRuntimePlugin', (module)=>{
|
|
703
900
|
if ('require_chunk_loading' === module.name) {
|
|
704
|
-
const finalSource = module.source.source.toString('utf-8').replace('for (var moduleId in moreModules) {', "for (var moduleId in moreModules) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;");
|
|
901
|
+
const finalSource = module.source.source.toString('utf-8').replace('for (var moduleId in moreModules) {', "for (var moduleId in moreModules) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId) || Object.keys(__webpack_require__.rstest_original_module_factories).includes(moduleId)) continue;");
|
|
705
902
|
module.source.source = Buffer.from(finalSource);
|
|
706
903
|
}
|
|
707
904
|
if ('module_chunk_loading' === module.name) {
|
|
708
|
-
const finalSource = module.source.source.toString('utf-8').replace('for (moduleId in __webpack_modules__) {', "for (moduleId in __webpack_modules__) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;");
|
|
905
|
+
const finalSource = module.source.source.toString('utf-8').replace('for (moduleId in __webpack_modules__) {', "for (moduleId in __webpack_modules__) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId) || Object.keys(__webpack_require__.rstest_original_module_factories).includes(moduleId)) continue;");
|
|
709
906
|
module.source.source = Buffer.from(finalSource);
|
|
710
907
|
}
|
|
711
908
|
if ('define_property_getters' === module.name) {
|
package/dist/0~9348.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
1
|
+
import "node:module";
|
|
3
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
3
|
import node_readline, { clearLine, createInterface, emitKeypressEvents, moveCursor } from "node:readline";
|
|
5
4
|
import { stdout, node_process, stdin } from "./3160.js";
|