@rspack-debug/test-tools 1.4.11 → 1.6.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/README.md +1 -1
- package/dist/case/builtin.d.ts +3 -0
- package/dist/case/builtin.js +152 -14
- package/dist/case/cache.d.ts +2 -2
- package/dist/case/cache.js +214 -12
- package/dist/case/common.d.ts +11 -0
- package/dist/case/common.js +249 -0
- package/dist/case/compiler.d.ts +17 -4
- package/dist/case/compiler.js +149 -12
- package/dist/case/config.d.ts +7 -2
- package/dist/case/config.js +106 -18
- package/dist/case/defaults.d.ts +13 -4
- package/dist/case/defaults.js +73 -18
- package/dist/case/diagnostic.d.ts +6 -0
- package/dist/case/diagnostic.js +121 -14
- package/dist/case/error.d.ts +15 -4
- package/dist/case/error.js +137 -12
- package/dist/case/esm-output.d.ts +1 -0
- package/dist/case/esm-output.js +117 -0
- package/dist/case/example.d.ts +1 -0
- package/dist/case/example.js +57 -0
- package/dist/case/hash.d.ts +2 -2
- package/dist/case/hash.js +72 -9
- package/dist/case/hook.d.ts +36 -4
- package/dist/case/hook.js +209 -20
- package/dist/case/hot-step.d.ts +2 -2
- package/dist/case/hot-step.js +309 -13
- package/dist/case/hot.d.ts +11 -2
- package/dist/case/hot.js +217 -12
- package/dist/case/incremental.d.ts +2 -2
- package/dist/case/incremental.js +24 -45
- package/dist/case/index.d.ts +31 -20
- package/dist/case/index.js +50 -34
- package/dist/case/multi-compiler.d.ts +19 -0
- package/dist/case/multi-compiler.js +97 -0
- package/dist/case/{nativeWatcher.js → native-watcher.js} +11 -23
- package/dist/case/normal.d.ts +3 -0
- package/dist/case/normal.js +202 -18
- package/dist/case/runner.d.ts +19 -0
- package/dist/case/runner.js +113 -0
- package/dist/case/serial.d.ts +2 -2
- package/dist/case/serial.js +10 -14
- package/dist/case/stats-api.d.ts +8 -3
- package/dist/case/stats-api.js +69 -10
- package/dist/case/stats-output.d.ts +11 -0
- package/dist/case/stats-output.js +199 -8
- package/dist/case/treeshaking.js +34 -7
- package/dist/case/watch.d.ts +27 -0
- package/dist/case/watch.js +318 -22
- package/dist/compiler.d.ts +16 -16
- package/dist/compiler.js +120 -15
- package/dist/helper/directory.d.ts +1 -1
- package/dist/helper/directory.js +6 -2
- package/dist/helper/disable-iconv-lite-warning.d.ts +1 -0
- package/dist/helper/disable-iconv-lite-warning.js +12 -0
- package/dist/helper/expect/error.js +1 -1
- package/dist/helper/expect/placeholder.js +7 -7
- package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -2
- package/dist/helper/expect/to-match-file-snapshot.js +3 -3
- package/dist/helper/hot-update/loader.d.ts +2 -1
- package/dist/helper/hot-update/loader.js +5 -30
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +14 -13
- package/dist/helper/index.d.ts +2 -1
- package/dist/helper/index.js +2 -1
- package/dist/helper/is.d.ts +2 -0
- package/dist/helper/is.js +15 -0
- package/dist/helper/legacy/LogTestPlugin.d.ts +6 -0
- package/dist/helper/legacy/LogTestPlugin.js +35 -0
- package/dist/helper/legacy/asModule.js +0 -2
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -1
- package/dist/helper/legacy/checkArrayExpectation.js +8 -8
- package/dist/helper/legacy/createFakeWorker.d.ts +2 -2
- package/dist/helper/legacy/createFakeWorker.js +44 -20
- package/dist/helper/legacy/createLazyTestEnv.d.ts +3 -2
- package/dist/helper/legacy/createLazyTestEnv.js +3 -3
- package/dist/helper/legacy/deprecationTracking.d.ts +1 -0
- package/dist/helper/legacy/deprecationTracking.js +41 -0
- package/dist/helper/legacy/expectSource.d.ts +10 -0
- package/dist/helper/legacy/expectSource.js +23 -0
- package/dist/helper/legacy/findOutputFiles.d.ts +6 -0
- package/dist/helper/legacy/findOutputFiles.js +14 -0
- package/dist/helper/legacy/regexEscape.d.ts +2 -0
- package/dist/helper/legacy/regexEscape.js +5 -0
- package/dist/helper/legacy/supportDefaultAssignment.js +13 -0
- package/dist/helper/legacy/supportsTextDecoder.d.ts +2 -0
- package/dist/helper/legacy/supportsTextDecoder.js +9 -0
- package/dist/helper/legacy/supportsUsing.d.ts +2 -0
- package/dist/helper/legacy/supportsUsing.js +26 -0
- package/dist/helper/legacy/urlToRelativePath.js +5 -2
- package/dist/helper/read-config-file.d.ts +3 -2
- package/dist/helper/read-config-file.js +12 -2
- package/dist/helper/setup-env.js +26 -4
- package/dist/helper/setup-expect.js +2 -2
- package/dist/helper/setup-wasm.js +2 -2
- package/dist/helper/stringify-config.d.ts +2 -0
- package/dist/helper/stringify-config.js +43 -0
- package/dist/helper/util/checkStats.d.ts +0 -1
- package/dist/helper/util/checkStats.js +0 -18
- package/dist/helper/util/expectWarningFactory.js +2 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +1 -4
- package/dist/plugin/index.d.ts +0 -3
- package/dist/plugin/index.js +0 -3
- package/dist/plugin/lazy-compilation-test-plugin.js +4 -4
- package/dist/runner/index.d.ts +2 -9
- package/dist/runner/index.js +2 -9
- package/dist/runner/node/index.d.ts +41 -0
- package/dist/runner/node/index.js +450 -0
- package/dist/runner/web/index.d.ts +30 -0
- package/dist/runner/web/index.js +343 -0
- package/dist/test/context.d.ts +15 -18
- package/dist/test/context.js +52 -57
- package/dist/test/creator.d.ts +20 -19
- package/dist/test/creator.js +69 -57
- package/dist/test/debug.d.ts +15 -0
- package/dist/test/debug.js +205 -0
- package/dist/test/tester.d.ts +1 -0
- package/dist/test/tester.js +44 -6
- package/dist/type.d.ts +94 -64
- package/dist/type.js +8 -12
- package/package.json +22 -61
- package/rstest.d.ts +24 -0
- package/dist/case/diff.d.ts +0 -3
- package/dist/case/diff.js +0 -126
- package/dist/compare/comparator.d.ts +0 -17
- package/dist/compare/comparator.js +0 -52
- package/dist/compare/compare.d.ts +0 -17
- package/dist/compare/compare.js +0 -175
- package/dist/compare/format-code.d.ts +0 -16
- package/dist/compare/format-code.js +0 -239
- package/dist/compare/index.d.ts +0 -5
- package/dist/compare/index.js +0 -21
- package/dist/compare/replace-module-argument.d.ts +0 -1
- package/dist/compare/replace-module-argument.js +0 -8
- package/dist/compare/replace-runtime-module-name.d.ts +0 -1
- package/dist/compare/replace-runtime-module-name.js +0 -71
- package/dist/helper/legacy/FakeDocument.d.ts +0 -54
- package/dist/helper/legacy/FakeDocument.js +0 -278
- package/dist/helper/legacy/createLogger.d.ts +0 -23
- package/dist/helper/legacy/createLogger.js +0 -20
- package/dist/helper/legacy/supportsImportFn.d.ts +0 -1
- package/dist/helper/legacy/supportsImportFn.js +0 -15
- package/dist/helper/legacy/supportsWorker.js +0 -17
- package/dist/helper/legacy/walkCssTokens.d.ts +0 -40
- package/dist/helper/legacy/walkCssTokens.js +0 -761
- package/dist/helper/legacy/warmup-webpack.d.ts +0 -1
- package/dist/helper/legacy/warmup-webpack.js +0 -26
- package/dist/helper/loaders/hot-update.d.ts +0 -1
- package/dist/helper/loaders/hot-update.js +0 -40
- package/dist/helper/plugins/hot-update.d.ts +0 -7
- package/dist/helper/plugins/hot-update.js +0 -40
- package/dist/helper/plugins/index.d.ts +0 -1
- package/dist/helper/plugins/index.js +0 -17
- package/dist/helper/util/currentWatchStep.d.ts +0 -1
- package/dist/helper/util/currentWatchStep.js +0 -2
- package/dist/helper/util/identifier.d.ts +0 -76
- package/dist/helper/util/identifier.js +0 -339
- package/dist/helper/util/replaceMitteDiagnostic.d.ts +0 -2
- package/dist/helper/util/replaceMitteDiagnostic.js +0 -17
- package/dist/plugin/rspack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/rspack-diff-config-plugin.js +0 -42
- package/dist/plugin/webpack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/webpack-diff-config-plugin.js +0 -41
- package/dist/plugin/webpack-module-placeholder-plugin.d.ts +0 -3
- package/dist/plugin/webpack-module-placeholder-plugin.js +0 -106
- package/dist/processor/basic.d.ts +0 -24
- package/dist/processor/basic.js +0 -146
- package/dist/processor/builtin.d.ts +0 -9
- package/dist/processor/builtin.js +0 -171
- package/dist/processor/cache.d.ts +0 -20
- package/dist/processor/cache.js +0 -128
- package/dist/processor/config.d.ts +0 -11
- package/dist/processor/config.js +0 -81
- package/dist/processor/defaults.d.ts +0 -30
- package/dist/processor/defaults.js +0 -72
- package/dist/processor/diagnostic.d.ts +0 -15
- package/dist/processor/diagnostic.js +0 -102
- package/dist/processor/diff.d.ts +0 -30
- package/dist/processor/diff.js +0 -140
- package/dist/processor/error.d.ts +0 -23
- package/dist/processor/error.js +0 -95
- package/dist/processor/hash.d.ts +0 -10
- package/dist/processor/hash.js +0 -63
- package/dist/processor/hook.d.ts +0 -44
- package/dist/processor/hook.js +0 -204
- package/dist/processor/hot-incremental.d.ts +0 -14
- package/dist/processor/hot-incremental.js +0 -43
- package/dist/processor/hot-step.d.ts +0 -18
- package/dist/processor/hot-step.js +0 -304
- package/dist/processor/hot.d.ts +0 -17
- package/dist/processor/hot.js +0 -140
- package/dist/processor/index.d.ts +0 -20
- package/dist/processor/index.js +0 -36
- package/dist/processor/multi.d.ts +0 -17
- package/dist/processor/multi.js +0 -73
- package/dist/processor/normal.d.ts +0 -12
- package/dist/processor/normal.js +0 -150
- package/dist/processor/simple.d.ts +0 -23
- package/dist/processor/simple.js +0 -49
- package/dist/processor/snapshot.d.ts +0 -12
- package/dist/processor/snapshot.js +0 -66
- package/dist/processor/stats-api.d.ts +0 -18
- package/dist/processor/stats-api.js +0 -48
- package/dist/processor/stats.d.ts +0 -18
- package/dist/processor/stats.js +0 -206
- package/dist/processor/treeshaking.d.ts +0 -10
- package/dist/processor/treeshaking.js +0 -33
- package/dist/processor/watch.d.ts +0 -30
- package/dist/processor/watch.js +0 -241
- package/dist/reporter/diff-html.d.ts +0 -15
- package/dist/reporter/diff-html.js +0 -69
- package/dist/reporter/diff-stats.d.ts +0 -24
- package/dist/reporter/diff-stats.js +0 -131
- package/dist/reporter/index.d.ts +0 -2
- package/dist/reporter/index.js +0 -18
- package/dist/runner/basic.d.ts +0 -10
- package/dist/runner/basic.js +0 -63
- package/dist/runner/cache.d.ts +0 -5
- package/dist/runner/cache.js +0 -90
- package/dist/runner/hot-step.d.ts +0 -5
- package/dist/runner/hot-step.js +0 -87
- package/dist/runner/hot.d.ts +0 -5
- package/dist/runner/hot.js +0 -83
- package/dist/runner/multiple.d.ts +0 -11
- package/dist/runner/multiple.js +0 -38
- package/dist/runner/normal.d.ts +0 -5
- package/dist/runner/normal.js +0 -20
- package/dist/runner/runner/basic.d.ts +0 -30
- package/dist/runner/runner/basic.js +0 -107
- package/dist/runner/runner/cjs.d.ts +0 -14
- package/dist/runner/runner/cjs.js +0 -151
- package/dist/runner/runner/esm.d.ts +0 -7
- package/dist/runner/runner/esm.js +0 -125
- package/dist/runner/runner/index.d.ts +0 -8
- package/dist/runner/runner/index.js +0 -24
- package/dist/runner/runner/normal.d.ts +0 -9
- package/dist/runner/runner/normal.js +0 -23
- package/dist/runner/runner/watch.d.ts +0 -16
- package/dist/runner/runner/watch.js +0 -27
- package/dist/runner/runner/web/fake.d.ts +0 -18
- package/dist/runner/runner/web/fake.js +0 -143
- package/dist/runner/runner/web/jsdom.d.ts +0 -26
- package/dist/runner/runner/web/jsdom.js +0 -219
- package/dist/runner/runner/web.d.ts +0 -15
- package/dist/runner/runner/web.js +0 -32
- package/dist/runner/type.d.ts +0 -42
- package/dist/runner/type.js +0 -9
- package/dist/runner/watch.d.ts +0 -7
- package/dist/runner/watch.js +0 -60
- package/dist/test/simple.d.ts +0 -5
- package/dist/test/simple.js +0 -43
- package/jest.d.ts +0 -25
- package/template/diff.bundle.css +0 -1
- package/template/diff.bundle.js +0 -144
- package/template/diff.html +0 -14
- package/template/editor.worker.js +0 -1
- /package/dist/case/{nativeWatcher.d.ts → native-watcher.d.ts} +0 -0
- /package/dist/helper/legacy/{supportsWorker.d.ts → supportDefaultAssignment.d.ts} +0 -0
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ECompilerType, type ITestReporter, type TModuleCompareResult } from "../type";
|
|
2
|
-
export interface IDiffStatsReporterOptions {
|
|
3
|
-
header?: string[];
|
|
4
|
-
footer?: string[];
|
|
5
|
-
file: string;
|
|
6
|
-
report?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export type TCompilerTypeId = ECompilerType.Rspack | ECompilerType.Webpack | "common";
|
|
9
|
-
export type TModuleTypeId = "normal" | "runtime";
|
|
10
|
-
export type TDimenTypeId = "modules" | "lines" | "lines-in-common";
|
|
11
|
-
export type TCaseSummaryId = `${TCompilerTypeId}|${TModuleTypeId}|${TDimenTypeId}`;
|
|
12
|
-
export type TCaseSummary = Record<TCaseSummaryId, number>;
|
|
13
|
-
export declare class DiffStatsReporter implements ITestReporter<TModuleCompareResult[]> {
|
|
14
|
-
private options;
|
|
15
|
-
private summary;
|
|
16
|
-
private failed;
|
|
17
|
-
constructor(options: IDiffStatsReporterOptions);
|
|
18
|
-
init(data?: TModuleCompareResult[]): Promise<void>;
|
|
19
|
-
failure(id: string): Promise<void>;
|
|
20
|
-
increment(id: string, data: TModuleCompareResult[]): Promise<void>;
|
|
21
|
-
output(): Promise<void>;
|
|
22
|
-
private stringifySummary;
|
|
23
|
-
private createSummary;
|
|
24
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DiffStatsReporter = void 0;
|
|
7
|
-
const csv_to_markdown_table_1 = __importDefault(require("csv-to-markdown-table"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
-
const type_1 = require("../type");
|
|
10
|
-
const toPercent = (d) => `${(d * 100).toFixed(2)}%`;
|
|
11
|
-
const toFirstLetterUpperCase = (s) => (s.charAt(0).toUpperCase() + s.slice(1)).split("-").join(" ");
|
|
12
|
-
const GITHUB_RUN_ID = process.env.GITHUB_RUN_ID;
|
|
13
|
-
class DiffStatsReporter {
|
|
14
|
-
constructor(options) {
|
|
15
|
-
this.options = options;
|
|
16
|
-
this.summary = new Map();
|
|
17
|
-
this.failed = new Set();
|
|
18
|
-
}
|
|
19
|
-
async init(data = []) { }
|
|
20
|
-
async failure(id) {
|
|
21
|
-
this.failed.add(id);
|
|
22
|
-
if (this.summary.has(id)) {
|
|
23
|
-
this.summary.delete(id);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async increment(id, data) {
|
|
27
|
-
if (this.failed.has(id))
|
|
28
|
-
return;
|
|
29
|
-
if (!this.summary.has(id)) {
|
|
30
|
-
this.summary.set(id, this.createSummary());
|
|
31
|
-
}
|
|
32
|
-
const current = this.summary.get(id);
|
|
33
|
-
for (const item of data) {
|
|
34
|
-
if (item.type === type_1.ECompareResultType.Missing)
|
|
35
|
-
continue;
|
|
36
|
-
const moduleType = item.name.startsWith("webpack/runtime")
|
|
37
|
-
? "runtime"
|
|
38
|
-
: "normal";
|
|
39
|
-
// handle modules
|
|
40
|
-
if (item.type === type_1.ECompareResultType.OnlySource) {
|
|
41
|
-
current[`${type_1.ECompilerType.Rspack}|${moduleType}|${"modules"}`]++;
|
|
42
|
-
}
|
|
43
|
-
else if (item.type === type_1.ECompareResultType.OnlyDist) {
|
|
44
|
-
current[`${type_1.ECompilerType.Webpack}|${moduleType}|${"modules"}`]++;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
current[`${"common"}|${moduleType}|${"modules"}`]++;
|
|
48
|
-
}
|
|
49
|
-
// handle lines
|
|
50
|
-
current[`${type_1.ECompilerType.Rspack}|${moduleType}|${"lines"}`] +=
|
|
51
|
-
item.lines?.source || 0;
|
|
52
|
-
current[`${type_1.ECompilerType.Webpack}|${moduleType}|${"lines"}`] +=
|
|
53
|
-
item.lines?.dist || 0;
|
|
54
|
-
current[`${"common"}|${moduleType}|${"lines"}`] +=
|
|
55
|
-
item.lines?.common || 0;
|
|
56
|
-
// handle lines in common modules
|
|
57
|
-
if (item.type === type_1.ECompareResultType.Same ||
|
|
58
|
-
item.type === type_1.ECompareResultType.Different) {
|
|
59
|
-
current[`${type_1.ECompilerType.Rspack}|${moduleType}|${"lines-in-common"}`] +=
|
|
60
|
-
item.lines?.source || 0;
|
|
61
|
-
current[`${type_1.ECompilerType.Webpack}|${moduleType}|${"lines-in-common"}`] += item.lines?.dist || 0;
|
|
62
|
-
current[`${"common"}|${moduleType}|${"lines-in-common"}`] +=
|
|
63
|
-
item.lines?.common || 0;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
async output() {
|
|
68
|
-
const chunks = [];
|
|
69
|
-
for (const [id, summary] of this.summary.entries()) {
|
|
70
|
-
chunks.push(this.stringifySummary(id, summary));
|
|
71
|
-
}
|
|
72
|
-
for (const id of this.failed.values()) {
|
|
73
|
-
chunks.push(`### ${id}\n\n> Failed\n\n`);
|
|
74
|
-
}
|
|
75
|
-
const output = [
|
|
76
|
-
...(this.options.header || []),
|
|
77
|
-
chunks.join("\n---\n"),
|
|
78
|
-
...(this.options.footer || [])
|
|
79
|
-
].join("\n\n");
|
|
80
|
-
fs_extra_1.default.ensureFileSync(this.options.file);
|
|
81
|
-
fs_extra_1.default.writeFileSync(this.options.file, output);
|
|
82
|
-
}
|
|
83
|
-
stringifySummary(id, summary) {
|
|
84
|
-
let output = `### ${id}\n\n`;
|
|
85
|
-
for (const moduleType of ["runtime", "normal"]) {
|
|
86
|
-
const csv = [];
|
|
87
|
-
csv.push(`${moduleType.charAt(0).toUpperCase() + moduleType.slice(1)} Modules,Rspack Only,Common,Webpack Only,Common Percent`);
|
|
88
|
-
for (const dimen of [
|
|
89
|
-
"modules",
|
|
90
|
-
"lines",
|
|
91
|
-
"lines-in-common"
|
|
92
|
-
]) {
|
|
93
|
-
const counts = [
|
|
94
|
-
type_1.ECompilerType.Rspack,
|
|
95
|
-
"common",
|
|
96
|
-
type_1.ECompilerType.Webpack
|
|
97
|
-
].map(i => summary[`${i}|${moduleType}|${dimen}`]);
|
|
98
|
-
csv.push(`${dimen === "lines-in-common"
|
|
99
|
-
? "Lines(Common Modules)"
|
|
100
|
-
: toFirstLetterUpperCase(dimen)},${counts.join(",")},${toPercent(counts[1] / (counts[0] + counts[1] + counts[2]))}`);
|
|
101
|
-
}
|
|
102
|
-
output += (0, csv_to_markdown_table_1.default)(csv.join("\n"), ",", true);
|
|
103
|
-
output += "\n\n";
|
|
104
|
-
}
|
|
105
|
-
if (this.options.report && GITHUB_RUN_ID) {
|
|
106
|
-
output += `> [View diff report](https://web-infra-dev.github.io/rspack-report-website/diff/${GITHUB_RUN_ID}/diff_${id}.html)`;
|
|
107
|
-
output += "\n\n";
|
|
108
|
-
}
|
|
109
|
-
return output;
|
|
110
|
-
}
|
|
111
|
-
createSummary() {
|
|
112
|
-
const result = {};
|
|
113
|
-
for (const i of [
|
|
114
|
-
type_1.ECompilerType.Rspack,
|
|
115
|
-
type_1.ECompilerType.Webpack,
|
|
116
|
-
"common"
|
|
117
|
-
]) {
|
|
118
|
-
for (const j of ["runtime", "normal"]) {
|
|
119
|
-
for (const k of [
|
|
120
|
-
"modules",
|
|
121
|
-
"lines",
|
|
122
|
-
"lines-in-common"
|
|
123
|
-
]) {
|
|
124
|
-
result[`${i}|${j}|${k}`] = 0;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.DiffStatsReporter = DiffStatsReporter;
|
package/dist/reporter/index.d.ts
DELETED
package/dist/reporter/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./diff-html"), exports);
|
|
18
|
-
__exportStar(require("./diff-stats"), exports);
|
package/dist/runner/basic.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ECompilerType, type ITestContext, type ITestEnv, type ITestRunner, type TCompilerOptions, type TCompilerStatsCompilation, type TRunnerFactory } from "../type";
|
|
2
|
-
export declare class BasicRunnerFactory<T extends ECompilerType> implements TRunnerFactory<T> {
|
|
3
|
-
protected name: string;
|
|
4
|
-
protected context: ITestContext;
|
|
5
|
-
constructor(name: string, context: ITestContext);
|
|
6
|
-
protected createStatsGetter(): () => TCompilerStatsCompilation<T>;
|
|
7
|
-
create(file: string, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
8
|
-
protected getRunnerKey(file: string): string;
|
|
9
|
-
protected createRunner(file: string, stats: () => TCompilerStatsCompilation<T>, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
10
|
-
}
|
package/dist/runner/basic.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BasicRunnerFactory = void 0;
|
|
4
|
-
const type_1 = require("../type");
|
|
5
|
-
const esm_1 = require("./runner/esm");
|
|
6
|
-
const web_1 = require("./runner/web");
|
|
7
|
-
class BasicRunnerFactory {
|
|
8
|
-
constructor(name, context) {
|
|
9
|
-
this.name = name;
|
|
10
|
-
this.context = context;
|
|
11
|
-
}
|
|
12
|
-
createStatsGetter() {
|
|
13
|
-
const compiler = this.context.getCompiler(this.name);
|
|
14
|
-
const statsGetter = (() => {
|
|
15
|
-
let cached = null;
|
|
16
|
-
return () => {
|
|
17
|
-
if (cached) {
|
|
18
|
-
return cached;
|
|
19
|
-
}
|
|
20
|
-
cached = compiler.getStats().toJson({
|
|
21
|
-
errorDetails: true
|
|
22
|
-
});
|
|
23
|
-
return cached;
|
|
24
|
-
};
|
|
25
|
-
})();
|
|
26
|
-
return statsGetter;
|
|
27
|
-
}
|
|
28
|
-
create(file, compilerOptions, env) {
|
|
29
|
-
const key = this.getRunnerKey(file);
|
|
30
|
-
const exists = this.context.getRunner(key);
|
|
31
|
-
if (exists) {
|
|
32
|
-
return exists;
|
|
33
|
-
}
|
|
34
|
-
const runner = this.createRunner(file, this.createStatsGetter(), compilerOptions, env);
|
|
35
|
-
this.context.setRunner(key, runner);
|
|
36
|
-
return runner;
|
|
37
|
-
}
|
|
38
|
-
getRunnerKey(file) {
|
|
39
|
-
return this.name;
|
|
40
|
-
}
|
|
41
|
-
createRunner(file, stats, compilerOptions, env) {
|
|
42
|
-
const runnerOptions = {
|
|
43
|
-
env,
|
|
44
|
-
stats,
|
|
45
|
-
name: this.name,
|
|
46
|
-
testConfig: this.context.getTestConfig(),
|
|
47
|
-
source: this.context.getSource(),
|
|
48
|
-
dist: this.context.getDist(),
|
|
49
|
-
compilerOptions
|
|
50
|
-
};
|
|
51
|
-
if (compilerOptions.target === "web" ||
|
|
52
|
-
compilerOptions.target === "webworker") {
|
|
53
|
-
return new web_1.WebRunner({
|
|
54
|
-
...runnerOptions,
|
|
55
|
-
runInNewContext: true,
|
|
56
|
-
cachable: true,
|
|
57
|
-
dom: this.context.getValue(this.name, "documentType") || type_1.EDocumentType.Fake
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return new esm_1.EsmRunner(runnerOptions);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.BasicRunnerFactory = BasicRunnerFactory;
|
package/dist/runner/cache.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type ECompilerType, type ITestEnv, type ITestRunner, type TCompilerOptions, type TCompilerStatsCompilation } from "../type";
|
|
2
|
-
import { BasicRunnerFactory } from "./basic";
|
|
3
|
-
export declare class CacheRunnerFactory<T extends ECompilerType> extends BasicRunnerFactory<T> {
|
|
4
|
-
protected createRunner(file: string, stats: TCompilerStatsCompilation<T>, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
5
|
-
}
|
package/dist/runner/cache.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CacheRunnerFactory = void 0;
|
|
7
|
-
const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
|
|
8
|
-
const type_1 = require("../type");
|
|
9
|
-
const basic_1 = require("./basic");
|
|
10
|
-
const web_1 = require("./runner/web");
|
|
11
|
-
const MAX_COMPILER_INDEX = 100;
|
|
12
|
-
class CacheRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
13
|
-
createRunner(file, stats, compilerOptions, env) {
|
|
14
|
-
const compiler = this.context.getCompiler(this.name);
|
|
15
|
-
let compilerIndex = 0;
|
|
16
|
-
const testConfig = this.context.getTestConfig();
|
|
17
|
-
const source = this.context.getSource();
|
|
18
|
-
const dist = this.context.getDist();
|
|
19
|
-
const updatePlugin = this.context.getValue(this.name, "hotUpdateContext");
|
|
20
|
-
const getWebRunner = () => {
|
|
21
|
-
return new web_1.WebRunner({
|
|
22
|
-
dom: this.context.getValue(this.name, "documentType") ||
|
|
23
|
-
type_1.EDocumentType.JSDOM,
|
|
24
|
-
env,
|
|
25
|
-
stats: this.createStatsGetter(),
|
|
26
|
-
cachable: false,
|
|
27
|
-
name: this.name,
|
|
28
|
-
runInNewContext: false,
|
|
29
|
-
testConfig: {
|
|
30
|
-
...testConfig,
|
|
31
|
-
moduleScope(ms, stats) {
|
|
32
|
-
const moduleScope = typeof testConfig.moduleScope === "function"
|
|
33
|
-
? testConfig.moduleScope(ms, stats)
|
|
34
|
-
: ms;
|
|
35
|
-
moduleScope.COMPILER_INDEX = compilerIndex;
|
|
36
|
-
moduleScope.NEXT_HMR = nextHmr;
|
|
37
|
-
moduleScope.NEXT_START = nextStart;
|
|
38
|
-
return moduleScope;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
source,
|
|
42
|
-
dist,
|
|
43
|
-
compilerOptions
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const nextHmr = async (m, options) => {
|
|
47
|
-
await updatePlugin.goNext();
|
|
48
|
-
const stats = await compiler.build();
|
|
49
|
-
if (!stats) {
|
|
50
|
-
throw new Error("Should generate stats during build");
|
|
51
|
-
}
|
|
52
|
-
const jsonStats = stats.toJson({
|
|
53
|
-
// errorDetails: true
|
|
54
|
-
});
|
|
55
|
-
const updateIndex = updatePlugin.getUpdateIndex();
|
|
56
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updateIndex}`, "Error");
|
|
57
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updateIndex}`, "Warning");
|
|
58
|
-
const updatedModules = await m.hot.check(options || true);
|
|
59
|
-
if (!updatedModules) {
|
|
60
|
-
throw new Error("No update available");
|
|
61
|
-
}
|
|
62
|
-
return jsonStats;
|
|
63
|
-
};
|
|
64
|
-
const nextStart = async () => {
|
|
65
|
-
await compiler.close();
|
|
66
|
-
compiler.createCompiler();
|
|
67
|
-
await updatePlugin.goNext();
|
|
68
|
-
const stats = await compiler.build();
|
|
69
|
-
if (!stats) {
|
|
70
|
-
throw new Error("Should generate stats during build");
|
|
71
|
-
}
|
|
72
|
-
const jsonStats = stats.toJson({
|
|
73
|
-
// errorDetails: true
|
|
74
|
-
});
|
|
75
|
-
const updateIndex = updatePlugin.getUpdateIndex();
|
|
76
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${updateIndex}`, "Error");
|
|
77
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${updateIndex}`, "Warning");
|
|
78
|
-
env.it(`NEXT_START run with compilerIndex==${compilerIndex + 1}`, async () => {
|
|
79
|
-
if (compilerIndex > MAX_COMPILER_INDEX) {
|
|
80
|
-
throw new Error("NEXT_START has been called more than the maximum times");
|
|
81
|
-
}
|
|
82
|
-
compilerIndex++;
|
|
83
|
-
return getWebRunner().run(file);
|
|
84
|
-
});
|
|
85
|
-
return jsonStats;
|
|
86
|
-
};
|
|
87
|
-
return getWebRunner();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.CacheRunnerFactory = CacheRunnerFactory;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type ECompilerType, type ITestEnv, type ITestRunner, type TCompilerOptions, type TCompilerStatsCompilation } from "../type";
|
|
2
|
-
import { HotRunnerFactory } from "./hot";
|
|
3
|
-
export declare class HotStepRunnerFactory<T extends ECompilerType> extends HotRunnerFactory<T> {
|
|
4
|
-
protected createRunner(file: string, stats: TCompilerStatsCompilation<T>, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
5
|
-
}
|
package/dist/runner/hot-step.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HotStepRunnerFactory = void 0;
|
|
7
|
-
const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
|
|
8
|
-
const type_1 = require("../type");
|
|
9
|
-
const hot_1 = require("./hot");
|
|
10
|
-
const web_1 = require("./runner/web");
|
|
11
|
-
class HotStepRunnerFactory extends hot_1.HotRunnerFactory {
|
|
12
|
-
createRunner(file, stats, compilerOptions, env) {
|
|
13
|
-
const compiler = this.context.getCompiler(this.name);
|
|
14
|
-
const testConfig = this.context.getTestConfig();
|
|
15
|
-
const source = this.context.getSource();
|
|
16
|
-
const dist = this.context.getDist();
|
|
17
|
-
const hotUpdateContext = this.context.getValue(this.name, "hotUpdateContext");
|
|
18
|
-
const next = async (callback) => {
|
|
19
|
-
const usePromise = typeof callback === "function";
|
|
20
|
-
try {
|
|
21
|
-
hotUpdateContext.updateIndex++;
|
|
22
|
-
const stats = await compiler.build();
|
|
23
|
-
if (!stats) {
|
|
24
|
-
throw new Error("Should generate stats during build");
|
|
25
|
-
}
|
|
26
|
-
const jsonStats = stats.toJson({
|
|
27
|
-
// errorDetails: true
|
|
28
|
-
});
|
|
29
|
-
const checker = this.context.getValue(this.name, jsonStats.errors?.length
|
|
30
|
-
? "hotUpdateStepErrorChecker"
|
|
31
|
-
: "hotUpdateStepChecker");
|
|
32
|
-
checker(hotUpdateContext, stats, runner.getGlobal("__HMR_UPDATED_RUNTIME__"));
|
|
33
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${hotUpdateContext.updateIndex}`, "Error");
|
|
34
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${hotUpdateContext.updateIndex}`, "Warning");
|
|
35
|
-
if (usePromise) {
|
|
36
|
-
// old callback style hmr cases
|
|
37
|
-
callback(null, jsonStats);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// new promise style hmr cases
|
|
41
|
-
return jsonStats;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
if (usePromise) {
|
|
46
|
-
callback(e);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const nextHMR = async (m, options) => {
|
|
54
|
-
const jsonStats = await next();
|
|
55
|
-
const updatedModules = await m.hot.check(options || true);
|
|
56
|
-
if (!updatedModules) {
|
|
57
|
-
throw new Error("No update available");
|
|
58
|
-
}
|
|
59
|
-
return jsonStats;
|
|
60
|
-
};
|
|
61
|
-
const runner = new web_1.WebRunner({
|
|
62
|
-
dom: this.context.getValue(this.name, "documentType") || type_1.EDocumentType.JSDOM,
|
|
63
|
-
env,
|
|
64
|
-
stats: this.createStatsGetter(),
|
|
65
|
-
name: this.name,
|
|
66
|
-
runInNewContext: false,
|
|
67
|
-
testConfig: {
|
|
68
|
-
...testConfig,
|
|
69
|
-
moduleScope(ms, stats) {
|
|
70
|
-
const moduleScope = ms;
|
|
71
|
-
if (typeof testConfig.moduleScope === "function") {
|
|
72
|
-
testConfig.moduleScope(moduleScope, stats);
|
|
73
|
-
}
|
|
74
|
-
moduleScope.NEXT = next;
|
|
75
|
-
moduleScope.NEXT_HMR = nextHMR;
|
|
76
|
-
return moduleScope;
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
cachable: true,
|
|
80
|
-
source,
|
|
81
|
-
dist,
|
|
82
|
-
compilerOptions
|
|
83
|
-
});
|
|
84
|
-
return runner;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.HotStepRunnerFactory = HotStepRunnerFactory;
|
package/dist/runner/hot.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type ECompilerType, type ITestEnv, type ITestRunner, type TCompilerOptions, type TCompilerStatsCompilation } from "../type";
|
|
2
|
-
import { BasicRunnerFactory } from "./basic";
|
|
3
|
-
export declare class HotRunnerFactory<T extends ECompilerType> extends BasicRunnerFactory<T> {
|
|
4
|
-
protected createRunner(file: string, stats: TCompilerStatsCompilation<T>, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
5
|
-
}
|
package/dist/runner/hot.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HotRunnerFactory = void 0;
|
|
7
|
-
const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
|
|
8
|
-
const type_1 = require("../type");
|
|
9
|
-
const basic_1 = require("./basic");
|
|
10
|
-
const web_1 = require("./runner/web");
|
|
11
|
-
class HotRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
12
|
-
createRunner(file, stats, compilerOptions, env) {
|
|
13
|
-
const compiler = this.context.getCompiler(this.name);
|
|
14
|
-
const testConfig = this.context.getTestConfig();
|
|
15
|
-
const source = this.context.getSource();
|
|
16
|
-
const dist = this.context.getDist();
|
|
17
|
-
const hotUpdateContext = this.context.getValue(this.name, "hotUpdateContext");
|
|
18
|
-
const next = async (callback) => {
|
|
19
|
-
const usePromise = typeof callback === "function";
|
|
20
|
-
try {
|
|
21
|
-
hotUpdateContext.updateIndex++;
|
|
22
|
-
const stats = await compiler.build();
|
|
23
|
-
if (!stats) {
|
|
24
|
-
throw new Error("Should generate stats during build");
|
|
25
|
-
}
|
|
26
|
-
const jsonStats = stats.toJson({
|
|
27
|
-
// errorDetails: true
|
|
28
|
-
});
|
|
29
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "error", `errors${hotUpdateContext.updateIndex}`, "Error");
|
|
30
|
-
await (0, checkArrayExpectation_1.default)(source, jsonStats, "warning", `warnings${hotUpdateContext.updateIndex}`, "Warning");
|
|
31
|
-
if (usePromise) {
|
|
32
|
-
// old callback style hmr cases
|
|
33
|
-
callback(null, jsonStats);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// new promise style hmr cases
|
|
37
|
-
return jsonStats;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
if (usePromise) {
|
|
42
|
-
callback(e);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
throw e;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const nextHMR = async (m, options) => {
|
|
50
|
-
const jsonStats = await next();
|
|
51
|
-
const updatedModules = await m.hot.check(options || true);
|
|
52
|
-
if (!updatedModules) {
|
|
53
|
-
throw new Error("No update available");
|
|
54
|
-
}
|
|
55
|
-
return jsonStats;
|
|
56
|
-
};
|
|
57
|
-
return new web_1.WebRunner({
|
|
58
|
-
dom: this.context.getValue(this.name, "documentType") || type_1.EDocumentType.JSDOM,
|
|
59
|
-
env,
|
|
60
|
-
stats: this.createStatsGetter(),
|
|
61
|
-
name: this.name,
|
|
62
|
-
runInNewContext: false,
|
|
63
|
-
testConfig: {
|
|
64
|
-
documentType: testConfig.documentType || type_1.EDocumentType.Fake,
|
|
65
|
-
...testConfig,
|
|
66
|
-
moduleScope(ms, stats) {
|
|
67
|
-
const moduleScope = ms;
|
|
68
|
-
if (typeof testConfig.moduleScope === "function") {
|
|
69
|
-
testConfig.moduleScope(moduleScope, stats);
|
|
70
|
-
}
|
|
71
|
-
moduleScope.NEXT = next;
|
|
72
|
-
moduleScope.NEXT_HMR = nextHMR;
|
|
73
|
-
return moduleScope;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
cachable: true,
|
|
77
|
-
source,
|
|
78
|
-
dist,
|
|
79
|
-
compilerOptions
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.HotRunnerFactory = HotRunnerFactory;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestEnv, ITestRunner, TCompilerOptions, TCompilerStatsCompilation } from "../type";
|
|
2
|
-
import { BasicRunnerFactory } from "./basic";
|
|
3
|
-
export declare class MultipleRunnerFactory<T extends ECompilerType> extends BasicRunnerFactory<T> {
|
|
4
|
-
protected runned: Set<string>;
|
|
5
|
-
protected getRunnerKey(file: string): string;
|
|
6
|
-
protected createRunner(file: string, stats: () => TCompilerStatsCompilation<T>, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
7
|
-
protected getFileIndexHandler(file: string): {
|
|
8
|
-
getIndex: () => number[];
|
|
9
|
-
flagIndex: () => Set<string>;
|
|
10
|
-
};
|
|
11
|
-
}
|
package/dist/runner/multiple.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MultipleRunnerFactory = void 0;
|
|
4
|
-
const basic_1 = require("./basic");
|
|
5
|
-
class MultipleRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.runned = new Set();
|
|
9
|
-
}
|
|
10
|
-
getRunnerKey(file) {
|
|
11
|
-
const { getIndex } = this.getFileIndexHandler(file);
|
|
12
|
-
const [index, seq] = getIndex();
|
|
13
|
-
return `${this.name}-${index}[${seq}]`;
|
|
14
|
-
}
|
|
15
|
-
createRunner(file, stats, compilerOptions, env) {
|
|
16
|
-
const multiCompilerOptions = this.context.getValue(this.name, "multiCompilerOptions") || [];
|
|
17
|
-
const { getIndex, flagIndex } = this.getFileIndexHandler(file);
|
|
18
|
-
const [index] = getIndex();
|
|
19
|
-
const runner = super.createRunner(file, () => stats().children[index], multiCompilerOptions[index], env);
|
|
20
|
-
flagIndex();
|
|
21
|
-
return runner;
|
|
22
|
-
}
|
|
23
|
-
getFileIndexHandler(file) {
|
|
24
|
-
const multiFileIndexMap = this.context.getValue(this.name, "multiFileIndexMap") || {};
|
|
25
|
-
if (typeof multiFileIndexMap[file] === "undefined") {
|
|
26
|
-
throw new Error("Unexpect file in multiple runner");
|
|
27
|
-
}
|
|
28
|
-
const indexList = multiFileIndexMap[file];
|
|
29
|
-
const seq = indexList.findIndex((index, n) => !this.runned.has(`${this.name}:${file}[${n}]`));
|
|
30
|
-
if (seq === -1) {
|
|
31
|
-
throw new Error(`File ${file} should run only ${indexList.length} times`);
|
|
32
|
-
}
|
|
33
|
-
const getIndex = () => [indexList[seq], seq];
|
|
34
|
-
const flagIndex = () => this.runned.add(`${this.name}:${file}[${seq}]`);
|
|
35
|
-
return { getIndex, flagIndex };
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.MultipleRunnerFactory = MultipleRunnerFactory;
|
package/dist/runner/normal.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestEnv, ITestRunner, TCompilerOptions, TCompilerStatsCompilation } from "../type";
|
|
2
|
-
import { BasicRunnerFactory } from "./basic";
|
|
3
|
-
export declare class NormalRunnerFactory<T extends ECompilerType> extends BasicRunnerFactory<T> {
|
|
4
|
-
protected createRunner(file: string, stats: () => TCompilerStatsCompilation<T>, compilerOptions: TCompilerOptions<T>, env: ITestEnv): ITestRunner;
|
|
5
|
-
}
|
package/dist/runner/normal.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NormalRunnerFactory = void 0;
|
|
4
|
-
const basic_1 = require("./basic");
|
|
5
|
-
const normal_1 = require("./runner/normal");
|
|
6
|
-
class NormalRunnerFactory extends basic_1.BasicRunnerFactory {
|
|
7
|
-
createRunner(file, stats, compilerOptions, env) {
|
|
8
|
-
return new normal_1.NormalRunner({
|
|
9
|
-
env,
|
|
10
|
-
cachable: true,
|
|
11
|
-
name: this.name,
|
|
12
|
-
runInNewContext: false,
|
|
13
|
-
testConfig: this.context.getTestConfig(),
|
|
14
|
-
source: this.context.getSource(),
|
|
15
|
-
dist: this.context.getDist(),
|
|
16
|
-
compilerOptions: compilerOptions
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.NormalRunnerFactory = NormalRunnerFactory;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ECompilerType, ITestEnv, ITestRunner, TCompilerOptions, TCompilerStatsCompilation, TTestConfig } from "../../type";
|
|
2
|
-
import type { IBasicGlobalContext, IBasicModuleScope, TBasicRunnerFile, TModuleObject, TRunnerRequirer } from "../type";
|
|
3
|
-
export interface IBasicRunnerOptions<T extends ECompilerType> {
|
|
4
|
-
env: ITestEnv;
|
|
5
|
-
stats?: () => TCompilerStatsCompilation<T>;
|
|
6
|
-
name: string;
|
|
7
|
-
runInNewContext?: boolean;
|
|
8
|
-
testConfig: TTestConfig<T>;
|
|
9
|
-
source: string;
|
|
10
|
-
dist: string;
|
|
11
|
-
compilerOptions: TCompilerOptions<T>;
|
|
12
|
-
cachable?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare abstract class BasicRunner<T extends ECompilerType = ECompilerType.Rspack> implements ITestRunner {
|
|
15
|
-
protected _options: IBasicRunnerOptions<T>;
|
|
16
|
-
protected globalContext: IBasicGlobalContext | null;
|
|
17
|
-
protected baseModuleScope: IBasicModuleScope | null;
|
|
18
|
-
protected requirers: Map<string, TRunnerRequirer>;
|
|
19
|
-
constructor(_options: IBasicRunnerOptions<T>);
|
|
20
|
-
run(file: string): Promise<unknown>;
|
|
21
|
-
getRequire(): TRunnerRequirer;
|
|
22
|
-
getGlobal(name: string): unknown;
|
|
23
|
-
protected abstract createGlobalContext(): IBasicGlobalContext;
|
|
24
|
-
protected abstract createBaseModuleScope(): IBasicModuleScope;
|
|
25
|
-
protected abstract createModuleScope(requireFn: TRunnerRequirer, m: TModuleObject, file: TBasicRunnerFile): IBasicModuleScope;
|
|
26
|
-
protected getFile(modulePath: string[] | string, currentDirectory: string): TBasicRunnerFile | null;
|
|
27
|
-
protected preExecute(code: string, file: TBasicRunnerFile): void;
|
|
28
|
-
protected postExecute(m: Object, file: TBasicRunnerFile): void;
|
|
29
|
-
protected createRunner(): void;
|
|
30
|
-
}
|