@rspack/test-tools 2.0.1 → 2.0.3
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/case/builtin.js +106 -66
- package/dist/case/cache.js +152 -132
- package/dist/case/common.d.ts +4 -4
- package/dist/case/common.js +162 -157
- package/dist/case/compiler.d.ts +4 -4
- package/dist/case/compiler.js +75 -64
- package/dist/case/config.js +112 -74
- package/dist/case/defaults.js +136 -83
- package/dist/case/diagnostic.js +112 -84
- package/dist/case/error.d.ts +4 -4
- package/dist/case/error.js +105 -89
- package/dist/case/esm-output.js +118 -87
- package/dist/case/example.js +73 -35
- package/dist/case/hash.js +74 -59
- package/dist/case/hook.js +151 -138
- package/dist/case/hot-step.js +130 -161
- package/dist/case/hot.js +148 -134
- package/dist/case/incremental.js +91 -58
- package/dist/case/index.js +134 -51
- package/dist/case/multi-compiler.d.ts +4 -4
- package/dist/case/multi-compiler.js +81 -56
- package/dist/case/native-watcher.js +62 -30
- package/dist/case/normal.js +253 -185
- package/dist/case/runner.js +80 -51
- package/dist/case/serial.js +47 -16
- package/dist/case/stats-api.d.ts +4 -4
- package/dist/case/stats-api.js +63 -43
- package/dist/case/stats-output.d.ts +3 -3
- package/dist/case/stats-output.js +147 -152
- package/dist/case/treeshaking.js +66 -35
- package/dist/case/watch.d.ts +3 -19
- package/dist/case/watch.js +204 -224
- package/dist/compiler.js +222 -195
- package/dist/helper/directory.js +83 -71
- package/dist/helper/disable-iconv-lite-warning.js +35 -9
- package/dist/helper/expect/diff.js +39 -10
- package/dist/helper/expect/error.js +62 -30
- package/dist/helper/expect/placeholder.js +47 -21
- package/dist/helper/expect/rspack.js +35 -13
- package/dist/helper/expect/to-be-typeof.js +39 -7
- package/dist/helper/expect/to-end-with.js +40 -8
- package/dist/helper/expect/to-match-file-snapshot.js +103 -80
- package/dist/helper/hot-update/index.js +35 -4
- package/dist/helper/hot-update/loader.d.ts +1 -0
- package/dist/helper/hot-update/loader.js +39 -4
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +87 -74
- package/dist/helper/index.js +138 -24
- package/dist/helper/is.js +51 -10
- package/dist/helper/legacy/EventSourceForNode.d.ts +11 -3
- package/dist/helper/legacy/EventSourceForNode.js +83 -37
- package/dist/helper/legacy/LogTestPlugin.d.ts +2 -3
- package/dist/helper/legacy/LogTestPlugin.js +39 -6
- package/dist/helper/legacy/asModule.d.ts +3 -3
- package/dist/helper/legacy/asModule.js +68 -19
- package/dist/helper/legacy/captureStdio.d.ts +1 -2
- package/dist/helper/legacy/captureStdio.js +69 -29
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -2
- package/dist/helper/legacy/checkArrayExpectation.js +132 -121
- package/dist/helper/legacy/copyDiff.d.ts +1 -2
- package/dist/helper/legacy/copyDiff.js +86 -42
- package/dist/helper/legacy/createFakeWorker.d.ts +2 -3
- package/dist/helper/legacy/createFakeWorker.js +90 -47
- package/dist/helper/legacy/createLazyTestEnv.d.ts +2 -3
- package/dist/helper/legacy/createLazyTestEnv.js +70 -59
- package/dist/helper/legacy/currentScript.d.ts +2 -2
- package/dist/helper/legacy/currentScript.js +35 -2
- package/dist/helper/legacy/deprecationTracking.d.ts +1 -1
- package/dist/helper/legacy/deprecationTracking.js +53 -28
- package/dist/helper/legacy/expectSource.d.ts +3 -2
- package/dist/helper/legacy/expectSource.js +42 -18
- package/dist/helper/legacy/fakeSystem.d.ts +12 -9
- package/dist/helper/legacy/fakeSystem.js +68 -58
- package/dist/helper/legacy/findOutputFiles.d.ts +7 -2
- package/dist/helper/legacy/findOutputFiles.js +60 -13
- package/dist/helper/legacy/parseResource.d.ts +1 -1
- package/dist/helper/legacy/parseResource.js +36 -6
- package/dist/helper/legacy/regexEscape.d.ts +1 -2
- package/dist/helper/legacy/regexEscape.js +39 -5
- package/dist/helper/legacy/supportDefaultAssignment.d.ts +1 -2
- package/dist/helper/legacy/supportDefaultAssignment.js +40 -7
- package/dist/helper/legacy/supportsTextDecoder.d.ts +1 -2
- package/dist/helper/legacy/supportsTextDecoder.js +40 -6
- package/dist/helper/legacy/supportsUsing.d.ts +1 -2
- package/dist/helper/legacy/supportsUsing.js +40 -7
- package/dist/helper/legacy/urlToRelativePath.d.ts +2 -2
- package/dist/helper/legacy/urlToRelativePath.js +56 -7
- package/dist/helper/parse-modules.js +52 -42
- package/dist/helper/read-config-file.js +60 -18
- package/dist/helper/serializers.js +62 -33
- package/dist/helper/setup-env.js +81 -91
- package/dist/helper/setup-expect.js +13 -13
- package/dist/helper/setup-wasm.js +18 -9
- package/dist/helper/stringify-config.js +44 -26
- package/dist/helper/update-snapshot.js +35 -3
- package/dist/helper/util/checkSourceMap.js +119 -80
- package/dist/helper/util/checkStats.d.ts +1 -1
- package/dist/helper/util/checkStats.js +42 -17
- package/dist/helper/util/expectWarningFactory.d.ts +1 -2
- package/dist/helper/util/expectWarningFactory.js +41 -8
- package/dist/helper/util/filterUtil.d.ts +9 -8
- package/dist/helper/util/filterUtil.js +63 -23
- package/dist/helper/win.js +46 -7
- package/dist/index.js +115 -23
- package/dist/plugin/index.js +55 -14
- package/dist/plugin/lazy-compilation-test-plugin.js +55 -41
- package/dist/reporter/index.js +55 -14
- package/dist/reporter/streamed-events-reporter.js +51 -77
- package/dist/runner/index.js +62 -15
- package/dist/runner/node/index.js +365 -431
- package/dist/runner/web/index.js +278 -263
- package/dist/test/context.js +67 -41
- package/dist/test/creator.js +135 -167
- package/dist/test/debug.js +89 -58
- package/dist/test/tester.js +94 -74
- package/dist/type.d.ts +10 -9
- package/dist/type.js +43 -9
- package/package.json +24 -23
package/dist/test/debug.js
CHANGED
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
DEBUG_SCOPES: ()=>DEBUG_SCOPES,
|
|
37
|
+
generateDebugReport: ()=>generateDebugReport
|
|
38
|
+
});
|
|
39
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
40
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
41
|
+
const external_fs_extra_namespaceObject = require("fs-extra");
|
|
42
|
+
var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
43
|
+
const external_javascript_stringify_namespaceObject = require("javascript-stringify");
|
|
44
|
+
const stringify_config_js_namespaceObject = require("../helper/stringify-config.js");
|
|
45
|
+
var stringify_config_js_default = /*#__PURE__*/ __webpack_require__.n(stringify_config_js_namespaceObject);
|
|
12
46
|
function generateDebugReport(context) {
|
|
13
47
|
const report = `
|
|
14
48
|
## Case Meta
|
|
@@ -49,8 +83,8 @@ ${generateRunErrorsReport(context)}
|
|
|
49
83
|
|
|
50
84
|
`;
|
|
51
85
|
const dist = context.getDist('debug.md');
|
|
52
|
-
|
|
53
|
-
|
|
86
|
+
external_fs_extra_default().ensureDirSync(external_node_path_default().dirname(dist));
|
|
87
|
+
external_fs_extra_default().writeFileSync(dist, report);
|
|
54
88
|
}
|
|
55
89
|
function generateCaseMetaPathReport(context) {
|
|
56
90
|
return `
|
|
@@ -66,21 +100,20 @@ function generateCaseMetaTestConfigReport(context) {
|
|
|
66
100
|
### Test Config
|
|
67
101
|
|
|
68
102
|
\`\`\`js
|
|
69
|
-
// ${
|
|
70
|
-
${(0,
|
|
103
|
+
// ${external_node_path_default().resolve(context.getSource(), './test.config.js')}
|
|
104
|
+
${(0, external_javascript_stringify_namespaceObject.stringify)(context.getTestConfig(), null, 2)}
|
|
71
105
|
\`\`\`
|
|
72
106
|
`;
|
|
73
107
|
}
|
|
74
108
|
function generateReadConfigFileReport(context) {
|
|
75
|
-
const configFileInfo = context.getValue(
|
|
76
|
-
if (!configFileInfo)
|
|
77
|
-
return '';
|
|
109
|
+
const configFileInfo = context.getValue(DEBUG_SCOPES.CompilerOptionsReadConfigFile);
|
|
110
|
+
if (!configFileInfo) return '';
|
|
78
111
|
return `
|
|
79
112
|
### Read Config File
|
|
80
113
|
|
|
81
114
|
\`\`\`js
|
|
82
115
|
// ${configFileInfo.file}
|
|
83
|
-
${(
|
|
116
|
+
${stringify_config_js_default()(configFileInfo.config)}
|
|
84
117
|
\`\`\`
|
|
85
118
|
`;
|
|
86
119
|
}
|
|
@@ -90,14 +123,13 @@ function generateFinalOptionsReport(context) {
|
|
|
90
123
|
### Final Options
|
|
91
124
|
|
|
92
125
|
\`\`\`js
|
|
93
|
-
${(
|
|
126
|
+
${stringify_config_js_default()(finalOptions)}
|
|
94
127
|
\`\`\`
|
|
95
128
|
`;
|
|
96
129
|
}
|
|
97
130
|
function generateCreateCompilerInstanceReport(context) {
|
|
98
|
-
const instanceInfo = context.getValue(
|
|
99
|
-
if (!instanceInfo)
|
|
100
|
-
return '';
|
|
131
|
+
const instanceInfo = context.getValue(DEBUG_SCOPES.CreateCompilerInstance);
|
|
132
|
+
if (!instanceInfo) return '';
|
|
101
133
|
return `
|
|
102
134
|
### Create Compiler Instance
|
|
103
135
|
|
|
@@ -106,91 +138,81 @@ function generateCreateCompilerInstanceReport(context) {
|
|
|
106
138
|
`;
|
|
107
139
|
}
|
|
108
140
|
function generateCreateCompilerSetPropertiesReport(context) {
|
|
109
|
-
const setPropertiesInfo = context.getValue(
|
|
110
|
-
if (!setPropertiesInfo || setPropertiesInfo.length
|
|
111
|
-
return '';
|
|
141
|
+
const setPropertiesInfo = context.getValue(DEBUG_SCOPES.CreateCompilerSetProperties);
|
|
142
|
+
if (!setPropertiesInfo || 0 === setPropertiesInfo.length) return '';
|
|
112
143
|
return `
|
|
113
144
|
### Set Properties
|
|
114
145
|
|
|
115
|
-
${setPropertiesInfo.map((p)
|
|
146
|
+
${setPropertiesInfo.map((p)=>`- ${p}`).join('\n')}
|
|
116
147
|
`;
|
|
117
148
|
}
|
|
118
149
|
function generateBuildMethodReport(context) {
|
|
119
|
-
const buildMethod = context.getValue(
|
|
120
|
-
if (!buildMethod)
|
|
121
|
-
return '';
|
|
150
|
+
const buildMethod = context.getValue(DEBUG_SCOPES.BuildMethod);
|
|
151
|
+
if (!buildMethod) return '';
|
|
122
152
|
return `
|
|
123
153
|
### Build Method
|
|
124
154
|
|
|
125
155
|
- Method: \`compiler.${buildMethod.method}()\`
|
|
126
|
-
${buildMethod.options ? `- Options:\n\`\`\`js\n${(0,
|
|
156
|
+
${buildMethod.options ? `- Options:\n\`\`\`js\n${(0, external_javascript_stringify_namespaceObject.stringify)(buildMethod.options, null, 2)}\n\`\`\`` : ''}
|
|
127
157
|
`;
|
|
128
158
|
}
|
|
129
159
|
function generateBuildErrorReport(context) {
|
|
130
|
-
const buildError = context.getValue(
|
|
131
|
-
if (!buildError)
|
|
132
|
-
return '';
|
|
160
|
+
const buildError = context.getValue(DEBUG_SCOPES.BuildError);
|
|
161
|
+
if (!buildError) return '';
|
|
133
162
|
return `
|
|
134
163
|
### Build Error
|
|
135
164
|
|
|
136
165
|
type: ${buildError.type}
|
|
137
166
|
|
|
138
|
-
${buildError.errors.map((e)
|
|
167
|
+
${buildError.errors.map((e)=>`\`\`\`\n// message:\n${e.message}\n// stack:\n${e.stack}\n\`\`\``).join('\n\n')}
|
|
139
168
|
`;
|
|
140
169
|
}
|
|
141
170
|
function generateBuildWarningReport(context) {
|
|
142
|
-
const buildWarning = context.getValue(
|
|
143
|
-
if (!buildWarning)
|
|
144
|
-
return '';
|
|
171
|
+
const buildWarning = context.getValue(DEBUG_SCOPES.BuildWarning);
|
|
172
|
+
if (!buildWarning) return '';
|
|
145
173
|
return `
|
|
146
174
|
### Build Warning
|
|
147
175
|
|
|
148
|
-
${buildWarning.map((w)
|
|
176
|
+
${buildWarning.map((w)=>`\`\`\`\n// message:\n${w.message}\n// stack:\n${w.stack}\n\`\`\``).join('\n\n')}
|
|
149
177
|
`;
|
|
150
178
|
}
|
|
151
179
|
function generateRunFindBundleReport(context) {
|
|
152
|
-
const runFindBundle = context.getValue(
|
|
153
|
-
if (!runFindBundle)
|
|
154
|
-
return '';
|
|
180
|
+
const runFindBundle = context.getValue(DEBUG_SCOPES.RunFindBundle);
|
|
181
|
+
if (!runFindBundle) return '';
|
|
155
182
|
return `
|
|
156
183
|
### Find Bundle
|
|
157
184
|
|
|
158
|
-
${runFindBundle.map((b)
|
|
185
|
+
${runFindBundle.map((b)=>`- ${context.getDist(b)}`).join('\n')}
|
|
159
186
|
`;
|
|
160
187
|
}
|
|
161
188
|
function generateRunGetRunnerReport(context) {
|
|
162
|
-
const getRunnerInfo = context.getValue(
|
|
163
|
-
if (!getRunnerInfo)
|
|
164
|
-
return '';
|
|
189
|
+
const getRunnerInfo = context.getValue(DEBUG_SCOPES.RunGetRunner);
|
|
190
|
+
if (!getRunnerInfo) return '';
|
|
165
191
|
return `
|
|
166
192
|
### Get Runner
|
|
167
193
|
|
|
168
|
-
${Object.entries(getRunnerInfo)
|
|
169
|
-
.map(([file, info]) => `- ${file}: ${info.runnerKey} (Reused: ${info.reused}, Type: \`${info.runnerType}\`)`)
|
|
170
|
-
.join('\n')}
|
|
194
|
+
${Object.entries(getRunnerInfo).map(([file, info])=>`- ${file}: ${info.runnerKey} (Reused: ${info.reused}, Type: \`${info.runnerType}\`)`).join('\n')}
|
|
171
195
|
`;
|
|
172
196
|
}
|
|
173
197
|
function generateRunLogsReport(context) {
|
|
174
|
-
const runLogs = context.getValue(
|
|
175
|
-
if (!runLogs)
|
|
176
|
-
return '';
|
|
198
|
+
const runLogs = context.getValue(DEBUG_SCOPES.RunLogs);
|
|
199
|
+
if (!runLogs) return '';
|
|
177
200
|
return `
|
|
178
201
|
### Run Logs
|
|
179
202
|
|
|
180
|
-
${runLogs.map((l)
|
|
203
|
+
${runLogs.map((l)=>`- ${l}`).join('\n')}
|
|
181
204
|
`;
|
|
182
205
|
}
|
|
183
206
|
function generateRunErrorsReport(context) {
|
|
184
|
-
const runErrors = context.getValue(
|
|
185
|
-
if (!runErrors)
|
|
186
|
-
return '';
|
|
207
|
+
const runErrors = context.getValue(DEBUG_SCOPES.RunErrors);
|
|
208
|
+
if (!runErrors) return '';
|
|
187
209
|
return `
|
|
188
210
|
### Run Errors
|
|
189
211
|
|
|
190
|
-
${runErrors.map((e)
|
|
212
|
+
${runErrors.map((e)=>`\`\`\`\n// message:\n${e.message}\n// stack:\n${e.stack}\n\`\`\``).join('\n\n')}
|
|
191
213
|
`;
|
|
192
214
|
}
|
|
193
|
-
|
|
215
|
+
const DEBUG_SCOPES = {
|
|
194
216
|
CompilerOptionsReadConfigFile: 'compiler-options:read-config-file',
|
|
195
217
|
CompilerOptionsFinalOptions: 'compiler-options:final-options',
|
|
196
218
|
CreateCompilerInstance: 'create-compiler:instance',
|
|
@@ -201,5 +223,14 @@ exports.DEBUG_SCOPES = {
|
|
|
201
223
|
RunFindBundle: 'run:find-bundle',
|
|
202
224
|
RunGetRunner: 'run:get-runner',
|
|
203
225
|
RunLogs: 'run:logs',
|
|
204
|
-
RunErrors: 'run:errors'
|
|
226
|
+
RunErrors: 'run:errors'
|
|
205
227
|
};
|
|
228
|
+
exports.DEBUG_SCOPES = __webpack_exports__.DEBUG_SCOPES;
|
|
229
|
+
exports.generateDebugReport = __webpack_exports__.generateDebugReport;
|
|
230
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
231
|
+
"DEBUG_SCOPES",
|
|
232
|
+
"generateDebugReport"
|
|
233
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
234
|
+
Object.defineProperty(exports, '__esModule', {
|
|
235
|
+
value: true
|
|
236
|
+
});
|
package/dist/test/tester.js
CHANGED
|
@@ -1,72 +1,100 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
Tester: ()=>Tester
|
|
37
|
+
});
|
|
38
|
+
const external_fs_extra_namespaceObject = require("fs-extra");
|
|
39
|
+
var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
40
|
+
const external_context_js_namespaceObject = require("./context.js");
|
|
41
|
+
const external_debug_js_namespaceObject = require("./debug.js");
|
|
10
42
|
class Tester {
|
|
11
|
-
|
|
43
|
+
config;
|
|
44
|
+
context;
|
|
45
|
+
steps = [];
|
|
46
|
+
step = 0;
|
|
47
|
+
total = 0;
|
|
48
|
+
constructor(config){
|
|
12
49
|
this.config = config;
|
|
13
|
-
this.
|
|
14
|
-
this.step = 0;
|
|
15
|
-
this.total = 0;
|
|
16
|
-
this.context = config.createContext
|
|
17
|
-
? config.createContext(config)
|
|
18
|
-
: new context_1.TestContext(config);
|
|
50
|
+
this.context = config.createContext ? config.createContext(config) : new external_context_js_namespaceObject.TestContext(config);
|
|
19
51
|
this.steps = config.steps || [];
|
|
20
52
|
this.step = 0;
|
|
21
53
|
this.total = config.steps?.length || 0;
|
|
22
|
-
if (config.contextValue)
|
|
23
|
-
for (const [key, value] of Array.from(Object.entries(config.contextValue))) {
|
|
24
|
-
this.context.setValue(key, value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
54
|
+
if (config.contextValue) for (const [key, value] of Array.from(Object.entries(config.contextValue)))this.context.setValue(key, value);
|
|
27
55
|
}
|
|
28
56
|
getContext() {
|
|
29
57
|
return this.context;
|
|
30
58
|
}
|
|
31
59
|
async prepare() {
|
|
32
|
-
|
|
60
|
+
external_fs_extra_default().mkdirSync(this.context.getDist(), {
|
|
61
|
+
recursive: true
|
|
62
|
+
});
|
|
33
63
|
const tempDir = this.context.getTemp();
|
|
34
|
-
if (tempDir) {
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
for (const i of this.steps)
|
|
38
|
-
if (typeof i.beforeAll === 'function') {
|
|
39
|
-
await i.beforeAll(this.context);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
64
|
+
if (tempDir) external_fs_extra_default().mkdirSync(tempDir, {
|
|
65
|
+
recursive: true
|
|
66
|
+
});
|
|
67
|
+
for (const i of this.steps)if ('function' == typeof i.beforeAll) await i.beforeAll(this.context);
|
|
42
68
|
}
|
|
43
69
|
async compile() {
|
|
44
70
|
const currentStep = this.steps[this.step];
|
|
45
|
-
if (!currentStep)
|
|
46
|
-
return;
|
|
71
|
+
if (!currentStep) return;
|
|
47
72
|
await this.runStepMethods(currentStep, [
|
|
48
73
|
'before',
|
|
49
74
|
'config',
|
|
50
75
|
'compiler',
|
|
51
|
-
'build'
|
|
76
|
+
'build'
|
|
52
77
|
]);
|
|
53
78
|
}
|
|
54
79
|
async check(env) {
|
|
55
80
|
const currentStep = this.steps[this.step];
|
|
56
|
-
if (!currentStep)
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
if (!currentStep) return;
|
|
82
|
+
await this.runCheckStepMethods(currentStep, env, this.context.hasError() ? [
|
|
83
|
+
'check'
|
|
84
|
+
] : [
|
|
85
|
+
'run',
|
|
86
|
+
'check'
|
|
87
|
+
]);
|
|
59
88
|
}
|
|
60
89
|
async after() {
|
|
61
90
|
const currentStep = this.steps[this.step];
|
|
62
|
-
if (!currentStep)
|
|
63
|
-
|
|
64
|
-
|
|
91
|
+
if (!currentStep) return;
|
|
92
|
+
await this.runStepMethods(currentStep, [
|
|
93
|
+
'after'
|
|
94
|
+
], true);
|
|
65
95
|
}
|
|
66
96
|
next() {
|
|
67
|
-
if (this.context.hasError())
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
97
|
+
if (this.context.hasError()) return false;
|
|
70
98
|
if (this.steps[this.step + 1]) {
|
|
71
99
|
this.step++;
|
|
72
100
|
return true;
|
|
@@ -74,53 +102,45 @@ class Tester {
|
|
|
74
102
|
return false;
|
|
75
103
|
}
|
|
76
104
|
async resume() {
|
|
77
|
-
for (const i of this.steps)
|
|
78
|
-
if (typeof i.afterAll === 'function') {
|
|
79
|
-
await i.afterAll(this.context);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
105
|
+
for (const i of this.steps)if ('function' == typeof i.afterAll) await i.afterAll(this.context);
|
|
82
106
|
try {
|
|
83
107
|
await this.context.closeCompiler();
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
108
|
+
} catch (e) {
|
|
86
109
|
console.warn(`Error occured while closing compilers of '${this.config.name}':\n${e.stack}`);
|
|
87
110
|
}
|
|
88
|
-
if (__DEBUG__) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
console.warn(`Generate debug report failed: ${e.message}`);
|
|
94
|
-
}
|
|
111
|
+
if (__DEBUG__) try {
|
|
112
|
+
(0, external_debug_js_namespaceObject.generateDebugReport)(this.context);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.warn(`Generate debug report failed: ${e.message}`);
|
|
95
115
|
}
|
|
96
116
|
}
|
|
97
117
|
async runStepMethods(step, methods, force = false) {
|
|
98
|
-
for (const i of methods)
|
|
99
|
-
if (!force && this.context.hasError())
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
this.context.emitError(e);
|
|
107
|
-
}
|
|
118
|
+
for (const i of methods){
|
|
119
|
+
if (!force && this.context.hasError()) return;
|
|
120
|
+
if ('function' == typeof step[i]) try {
|
|
121
|
+
await step[i](this.context);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
this.context.emitError(e);
|
|
108
124
|
}
|
|
109
125
|
}
|
|
110
126
|
}
|
|
111
127
|
async runCheckStepMethods(step, env, methods) {
|
|
112
128
|
try {
|
|
113
|
-
for (const i of methods)
|
|
114
|
-
|
|
115
|
-
await step[i](env, this.context);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch (e) {
|
|
129
|
+
for (const i of methods)if ('function' == typeof step[i]) await step[i](env, this.context);
|
|
130
|
+
} catch (e) {
|
|
120
131
|
const errors = this.context.getError();
|
|
121
|
-
console.error(new Error([
|
|
132
|
+
console.error(new Error([
|
|
133
|
+
...errors,
|
|
134
|
+
e
|
|
135
|
+
].map((e)=>e.message).join('\n')));
|
|
122
136
|
throw e;
|
|
123
137
|
}
|
|
124
138
|
}
|
|
125
139
|
}
|
|
126
|
-
exports.Tester = Tester;
|
|
140
|
+
exports.Tester = __webpack_exports__.Tester;
|
|
141
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
142
|
+
"Tester"
|
|
143
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
144
|
+
Object.defineProperty(exports, '__esModule', {
|
|
145
|
+
value: true
|
|
146
|
+
});
|
package/dist/type.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface ITestLoader {
|
|
|
32
32
|
walk(): Promise<void>;
|
|
33
33
|
}
|
|
34
34
|
export type TTestRunResult = Record<string, any>;
|
|
35
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
35
36
|
export interface ITesterConfig {
|
|
36
37
|
name: string;
|
|
37
38
|
src: string;
|
|
@@ -55,15 +56,15 @@ export interface ITester {
|
|
|
55
56
|
resume(): Promise<void>;
|
|
56
57
|
}
|
|
57
58
|
export interface ITestProcessor {
|
|
58
|
-
beforeAll?(context: ITestContext):
|
|
59
|
-
afterAll?(context: ITestContext):
|
|
60
|
-
before?(context: ITestContext):
|
|
61
|
-
after?(context: ITestContext):
|
|
62
|
-
config(context: ITestContext):
|
|
63
|
-
compiler(context: ITestContext):
|
|
64
|
-
build(context: ITestContext):
|
|
65
|
-
run(env: ITestEnv, context: ITestContext):
|
|
66
|
-
check(env: ITestEnv, context: ITestContext):
|
|
59
|
+
beforeAll?(context: ITestContext): MaybePromise<void>;
|
|
60
|
+
afterAll?(context: ITestContext): MaybePromise<void>;
|
|
61
|
+
before?(context: ITestContext): MaybePromise<void>;
|
|
62
|
+
after?(context: ITestContext): MaybePromise<void>;
|
|
63
|
+
config(context: ITestContext): MaybePromise<void>;
|
|
64
|
+
compiler(context: ITestContext): MaybePromise<void>;
|
|
65
|
+
build(context: ITestContext): MaybePromise<void>;
|
|
66
|
+
run(env: ITestEnv, context: ITestContext): MaybePromise<void>;
|
|
67
|
+
check(env: ITestEnv, context: ITestContext): MaybePromise<unknown>;
|
|
67
68
|
}
|
|
68
69
|
export interface ITestReporter {
|
|
69
70
|
init<T>(data?: T): Promise<void>;
|
package/dist/type.js
CHANGED
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
ECompareResultType: ()=>ECompareResultType,
|
|
28
|
+
EEsmMode: ()=>EEsmMode
|
|
29
|
+
});
|
|
30
|
+
var ECompareResultType = /*#__PURE__*/ function(ECompareResultType) {
|
|
7
31
|
ECompareResultType["Same"] = "same";
|
|
8
32
|
ECompareResultType["Missing"] = "missing";
|
|
9
33
|
ECompareResultType["OnlyDist"] = "only-dist";
|
|
10
34
|
ECompareResultType["OnlySource"] = "only-source";
|
|
11
35
|
ECompareResultType["Different"] = "different";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
36
|
+
return ECompareResultType;
|
|
37
|
+
}({});
|
|
38
|
+
var EEsmMode = /*#__PURE__*/ function(EEsmMode) {
|
|
15
39
|
EEsmMode[EEsmMode["Unknown"] = 0] = "Unknown";
|
|
16
40
|
EEsmMode[EEsmMode["Evaluated"] = 1] = "Evaluated";
|
|
17
41
|
EEsmMode[EEsmMode["Unlinked"] = 2] = "Unlinked";
|
|
18
|
-
|
|
42
|
+
return EEsmMode;
|
|
43
|
+
}({});
|
|
44
|
+
exports.ECompareResultType = __webpack_exports__.ECompareResultType;
|
|
45
|
+
exports.EEsmMode = __webpack_exports__.EEsmMode;
|
|
46
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
47
|
+
"ECompareResultType",
|
|
48
|
+
"EEsmMode"
|
|
49
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
50
|
+
Object.defineProperty(exports, '__esModule', {
|
|
51
|
+
value: true
|
|
52
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/test-tools",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"license": "MIT",
|
|
3
|
+
"version": "2.0.3",
|
|
5
4
|
"description": "Test tools for rspack",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"homepage": "https://rspack.rs",
|
|
6
|
+
"bugs": "https://github.com/web-infra-dev/rspack/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/web-infra-dev/rspack",
|
|
10
|
+
"directory": "packages/rspack-test-tools"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
8
13
|
"exports": {
|
|
9
14
|
".": {
|
|
10
15
|
"default": "./dist/index.js"
|
|
@@ -19,61 +24,57 @@
|
|
|
19
24
|
"./reporter": "./dist/reporter/index.js",
|
|
20
25
|
"./reporter/*": "./dist/reporter/*.js"
|
|
21
26
|
},
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
22
29
|
"files": [
|
|
23
30
|
"client",
|
|
24
31
|
"dist",
|
|
25
32
|
"template",
|
|
26
33
|
"rstest.d.ts"
|
|
27
34
|
],
|
|
28
|
-
"publishConfig": {
|
|
29
|
-
"access": "public",
|
|
30
|
-
"provenance": true
|
|
31
|
-
},
|
|
32
|
-
"homepage": "https://rspack.rs",
|
|
33
|
-
"bugs": "https://github.com/web-infra-dev/rspack/issues",
|
|
34
|
-
"repository": {
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "https://github.com/web-infra-dev/rspack",
|
|
37
|
-
"directory": "packages/rspack-test-tools"
|
|
38
|
-
},
|
|
39
35
|
"dependencies": {
|
|
40
36
|
"@babel/generator": "7.29.1",
|
|
41
|
-
"@babel/parser": "7.29.
|
|
37
|
+
"@babel/parser": "7.29.3",
|
|
42
38
|
"@babel/traverse": "7.29.0",
|
|
43
39
|
"@babel/types": "7.29.0",
|
|
44
40
|
"chalk": "^4.1.2",
|
|
45
41
|
"cross-env": "^10.1.0",
|
|
46
42
|
"filenamify": "4.3.0",
|
|
47
|
-
"fs-extra": "^11.3.
|
|
43
|
+
"fs-extra": "^11.3.5",
|
|
48
44
|
"iconv-lite": "^0.7.2",
|
|
49
45
|
"javascript-stringify": "^2.1.0",
|
|
50
46
|
"jest-diff": "^30.3.0",
|
|
51
47
|
"jest-snapshot": "29.7.0",
|
|
52
48
|
"jsdom": "^26.1.0",
|
|
53
|
-
"memfs": "4.
|
|
49
|
+
"memfs": "4.57.2",
|
|
54
50
|
"path-serializer": "0.6.0",
|
|
55
51
|
"pretty-format": "30.3.0",
|
|
56
52
|
"rimraf": "^5.0.10",
|
|
53
|
+
"rspack-merge": "0.1.1",
|
|
57
54
|
"source-map": "^0.7.6",
|
|
58
|
-
"terser-webpack-plugin": "^5.
|
|
55
|
+
"terser-webpack-plugin": "^5.5.0",
|
|
59
56
|
"wast-loader": "^1.14.1",
|
|
60
57
|
"webpack": "5.104.1",
|
|
61
|
-
"webpack-merge": "6.0.1",
|
|
62
58
|
"webpack-sources": "3.3.4"
|
|
63
59
|
},
|
|
64
60
|
"devDependencies": {
|
|
61
|
+
"@rslib/core": "^0.21.4",
|
|
65
62
|
"@types/babel__generator": "7.27.0",
|
|
66
63
|
"@types/babel__traverse": "7.28.0",
|
|
67
64
|
"@types/fs-extra": "11.0.4",
|
|
68
65
|
"@types/jsdom": "^21.1.7",
|
|
69
66
|
"typescript": "^6.0.3",
|
|
70
|
-
"@rspack/core": "2.0.
|
|
67
|
+
"@rspack/core": "2.0.3"
|
|
71
68
|
},
|
|
72
69
|
"peerDependencies": {
|
|
73
70
|
"@rspack/core": ">=1.0.0"
|
|
74
71
|
},
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public",
|
|
74
|
+
"provenance": true
|
|
75
|
+
},
|
|
75
76
|
"scripts": {
|
|
76
|
-
"build": "
|
|
77
|
-
"dev": "
|
|
77
|
+
"build": "rslib",
|
|
78
|
+
"dev": "rslib -w"
|
|
78
79
|
}
|
|
79
80
|
}
|