@rspack/test-tools 2.0.2 → 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.
Files changed (118) hide show
  1. package/dist/case/builtin.js +106 -66
  2. package/dist/case/cache.js +136 -122
  3. package/dist/case/common.d.ts +4 -4
  4. package/dist/case/common.js +162 -157
  5. package/dist/case/compiler.d.ts +4 -4
  6. package/dist/case/compiler.js +75 -64
  7. package/dist/case/config.js +112 -74
  8. package/dist/case/defaults.js +136 -83
  9. package/dist/case/diagnostic.js +112 -84
  10. package/dist/case/error.d.ts +4 -4
  11. package/dist/case/error.js +105 -89
  12. package/dist/case/esm-output.js +118 -87
  13. package/dist/case/example.js +73 -35
  14. package/dist/case/hash.js +74 -59
  15. package/dist/case/hook.js +151 -138
  16. package/dist/case/hot-step.js +130 -161
  17. package/dist/case/hot.js +148 -134
  18. package/dist/case/incremental.js +91 -58
  19. package/dist/case/index.js +134 -51
  20. package/dist/case/multi-compiler.d.ts +4 -4
  21. package/dist/case/multi-compiler.js +81 -56
  22. package/dist/case/native-watcher.js +62 -30
  23. package/dist/case/normal.js +253 -185
  24. package/dist/case/runner.js +80 -51
  25. package/dist/case/serial.js +47 -16
  26. package/dist/case/stats-api.d.ts +4 -4
  27. package/dist/case/stats-api.js +63 -43
  28. package/dist/case/stats-output.d.ts +3 -3
  29. package/dist/case/stats-output.js +147 -152
  30. package/dist/case/treeshaking.js +66 -35
  31. package/dist/case/watch.d.ts +3 -19
  32. package/dist/case/watch.js +204 -224
  33. package/dist/compiler.js +222 -195
  34. package/dist/helper/directory.js +83 -71
  35. package/dist/helper/disable-iconv-lite-warning.js +35 -9
  36. package/dist/helper/expect/diff.js +39 -10
  37. package/dist/helper/expect/error.js +62 -30
  38. package/dist/helper/expect/placeholder.js +47 -21
  39. package/dist/helper/expect/rspack.js +35 -13
  40. package/dist/helper/expect/to-be-typeof.js +39 -7
  41. package/dist/helper/expect/to-end-with.js +40 -8
  42. package/dist/helper/expect/to-match-file-snapshot.js +103 -80
  43. package/dist/helper/hot-update/index.js +35 -4
  44. package/dist/helper/hot-update/loader.d.ts +1 -0
  45. package/dist/helper/hot-update/loader.js +39 -4
  46. package/dist/helper/hot-update/plugin.d.ts +1 -1
  47. package/dist/helper/hot-update/plugin.js +87 -74
  48. package/dist/helper/index.js +138 -24
  49. package/dist/helper/is.js +51 -10
  50. package/dist/helper/legacy/EventSourceForNode.d.ts +11 -3
  51. package/dist/helper/legacy/EventSourceForNode.js +83 -37
  52. package/dist/helper/legacy/LogTestPlugin.d.ts +2 -3
  53. package/dist/helper/legacy/LogTestPlugin.js +39 -6
  54. package/dist/helper/legacy/asModule.d.ts +3 -3
  55. package/dist/helper/legacy/asModule.js +68 -19
  56. package/dist/helper/legacy/captureStdio.d.ts +1 -2
  57. package/dist/helper/legacy/captureStdio.js +69 -29
  58. package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -2
  59. package/dist/helper/legacy/checkArrayExpectation.js +132 -121
  60. package/dist/helper/legacy/copyDiff.d.ts +1 -2
  61. package/dist/helper/legacy/copyDiff.js +86 -42
  62. package/dist/helper/legacy/createFakeWorker.d.ts +2 -3
  63. package/dist/helper/legacy/createFakeWorker.js +90 -47
  64. package/dist/helper/legacy/createLazyTestEnv.d.ts +2 -3
  65. package/dist/helper/legacy/createLazyTestEnv.js +70 -59
  66. package/dist/helper/legacy/currentScript.d.ts +2 -2
  67. package/dist/helper/legacy/currentScript.js +35 -2
  68. package/dist/helper/legacy/deprecationTracking.d.ts +1 -1
  69. package/dist/helper/legacy/deprecationTracking.js +53 -28
  70. package/dist/helper/legacy/expectSource.d.ts +3 -2
  71. package/dist/helper/legacy/expectSource.js +42 -18
  72. package/dist/helper/legacy/fakeSystem.d.ts +12 -9
  73. package/dist/helper/legacy/fakeSystem.js +68 -58
  74. package/dist/helper/legacy/findOutputFiles.d.ts +7 -2
  75. package/dist/helper/legacy/findOutputFiles.js +60 -13
  76. package/dist/helper/legacy/parseResource.d.ts +1 -1
  77. package/dist/helper/legacy/parseResource.js +36 -6
  78. package/dist/helper/legacy/regexEscape.d.ts +1 -2
  79. package/dist/helper/legacy/regexEscape.js +39 -5
  80. package/dist/helper/legacy/supportDefaultAssignment.d.ts +1 -2
  81. package/dist/helper/legacy/supportDefaultAssignment.js +40 -7
  82. package/dist/helper/legacy/supportsTextDecoder.d.ts +1 -2
  83. package/dist/helper/legacy/supportsTextDecoder.js +40 -6
  84. package/dist/helper/legacy/supportsUsing.d.ts +1 -2
  85. package/dist/helper/legacy/supportsUsing.js +40 -7
  86. package/dist/helper/legacy/urlToRelativePath.d.ts +2 -2
  87. package/dist/helper/legacy/urlToRelativePath.js +56 -7
  88. package/dist/helper/parse-modules.js +52 -42
  89. package/dist/helper/read-config-file.js +60 -18
  90. package/dist/helper/serializers.js +62 -33
  91. package/dist/helper/setup-env.js +81 -91
  92. package/dist/helper/setup-expect.js +13 -13
  93. package/dist/helper/setup-wasm.js +18 -9
  94. package/dist/helper/stringify-config.js +44 -26
  95. package/dist/helper/update-snapshot.js +35 -3
  96. package/dist/helper/util/checkSourceMap.js +119 -80
  97. package/dist/helper/util/checkStats.d.ts +1 -1
  98. package/dist/helper/util/checkStats.js +42 -17
  99. package/dist/helper/util/expectWarningFactory.d.ts +1 -2
  100. package/dist/helper/util/expectWarningFactory.js +41 -8
  101. package/dist/helper/util/filterUtil.d.ts +9 -8
  102. package/dist/helper/util/filterUtil.js +63 -23
  103. package/dist/helper/win.js +46 -7
  104. package/dist/index.js +115 -23
  105. package/dist/plugin/index.js +55 -14
  106. package/dist/plugin/lazy-compilation-test-plugin.js +55 -41
  107. package/dist/reporter/index.js +55 -14
  108. package/dist/reporter/streamed-events-reporter.js +51 -77
  109. package/dist/runner/index.js +62 -15
  110. package/dist/runner/node/index.js +365 -431
  111. package/dist/runner/web/index.js +278 -263
  112. package/dist/test/context.js +67 -41
  113. package/dist/test/creator.js +135 -167
  114. package/dist/test/debug.js +89 -58
  115. package/dist/test/tester.js +94 -74
  116. package/dist/type.d.ts +10 -9
  117. package/dist/type.js +43 -9
  118. package/package.json +21 -20
package/dist/compiler.js CHANGED
@@ -1,221 +1,248 @@
1
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.TestCompilerManager = exports.ECompilerEvent = void 0;
7
- const node_events_1 = __importDefault(require("node:events"));
8
- const core_1 = require("@rspack/core");
9
- const rspack_merge_1 = __importDefault(require("rspack-merge"));
10
- const debug_1 = require("./test/debug");
11
- var ECompilerEvent;
12
- (function (ECompilerEvent) {
13
- ECompilerEvent["Build"] = "build";
14
- ECompilerEvent["Option"] = "option";
15
- ECompilerEvent["Create"] = "create";
16
- ECompilerEvent["Close"] = "close";
17
- })(ECompilerEvent || (exports.ECompilerEvent = ECompilerEvent = {}));
18
- class TestCompilerManager {
19
- constructor(context) {
20
- this.context = context;
21
- this.compilerOptions = {};
22
- this.compilerInstance = null;
23
- this.compilerStats = null;
24
- this.emitter = new node_events_1.default();
25
- }
26
- getOptions() {
27
- return this.compilerOptions;
28
- }
29
- setOptions(newOptions) {
30
- this.compilerOptions = newOptions;
31
- this.emitter.emit(ECompilerEvent.Option, this.compilerOptions);
32
- return this.compilerOptions;
2
+ var __webpack_modules__ = {
3
+ "@rspack/core" (module) {
4
+ module.exports = require("@rspack/core");
33
5
  }
34
- mergeOptions(newOptions) {
35
- this.compilerOptions = (0, rspack_merge_1.default)(this.compilerOptions, newOptions);
36
- this.emitter.emit(ECompilerEvent.Option, this.compilerOptions);
37
- return this.compilerOptions;
38
- }
39
- getCompiler() {
40
- return this.compilerInstance;
41
- }
42
- createCompiler() {
43
- this.compilerInstance = require('@rspack/core')(this.compilerOptions);
44
- if (__DEBUG__) {
45
- const context = this.context;
46
- this.compilerInstance = new Proxy(this.compilerInstance, {
47
- get(target, p, receiver) {
48
- const value = Reflect.get(target, p, receiver);
49
- if (typeof value === 'function' &&
50
- core_1.Compiler.prototype.hasOwnProperty(p)) {
51
- return value.bind(target);
52
- }
53
- return value;
54
- },
55
- set(target, p, value, receiver) {
56
- const debugSetProperties = context.getValue(debug_1.DEBUG_SCOPES.CreateCompilerSetProperties) || [];
57
- debugSetProperties.push(`${p} ${new Error().stack?.split('\n')[2]?.trim()}`);
58
- context.setValue(debug_1.DEBUG_SCOPES.CreateCompilerSetProperties, debugSetProperties);
59
- return Reflect.set(target, p, value, receiver);
60
- },
61
- });
62
- this.context.setValue(debug_1.DEBUG_SCOPES.CreateCompilerInstance, {
63
- path: require.resolve('@rspack/core'),
64
- mode: 'no-callback',
65
- });
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, definition)=>{
28
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
+ enumerable: true,
30
+ get: definition[key]
31
+ });
32
+ };
33
+ })();
34
+ (()=>{
35
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
36
+ })();
37
+ (()=>{
38
+ __webpack_require__.r = (exports1)=>{
39
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
40
+ value: 'Module'
41
+ });
42
+ Object.defineProperty(exports1, '__esModule', {
43
+ value: true
44
+ });
45
+ };
46
+ })();
47
+ var __webpack_exports__ = {};
48
+ (()=>{
49
+ __webpack_require__.r(__webpack_exports__);
50
+ __webpack_require__.d(__webpack_exports__, {
51
+ ECompilerEvent: ()=>compiler_ECompilerEvent,
52
+ TestCompilerManager: ()=>TestCompilerManager
53
+ });
54
+ const external_node_events_namespaceObject = require("node:events");
55
+ var external_node_events_default = /*#__PURE__*/ __webpack_require__.n(external_node_events_namespaceObject);
56
+ var core_ = __webpack_require__("@rspack/core");
57
+ const external_rspack_merge_namespaceObject = require("rspack-merge");
58
+ var external_rspack_merge_default = /*#__PURE__*/ __webpack_require__.n(external_rspack_merge_namespaceObject);
59
+ const debug_js_namespaceObject = require("./test/debug.js");
60
+ var compiler_ECompilerEvent = /*#__PURE__*/ function(ECompilerEvent) {
61
+ ECompilerEvent["Build"] = "build";
62
+ ECompilerEvent["Option"] = "option";
63
+ ECompilerEvent["Create"] = "create";
64
+ ECompilerEvent["Close"] = "close";
65
+ return ECompilerEvent;
66
+ }({});
67
+ class TestCompilerManager {
68
+ context;
69
+ compilerOptions = {};
70
+ compilerInstance = null;
71
+ compilerStats = null;
72
+ emitter = new (external_node_events_default())();
73
+ constructor(context){
74
+ this.context = context;
66
75
  }
67
- this.emitter.emit(ECompilerEvent.Create, this.compilerInstance);
68
- return this.compilerInstance;
69
- }
70
- createCompilerWithCallback(callback) {
71
- this.compilerInstance = require('@rspack/core')(this.compilerOptions, callback);
72
- if (__DEBUG__) {
73
- const context = this.context;
74
- this.compilerInstance = new Proxy(this.compilerInstance, {
75
- get(target, p, receiver) {
76
- const value = Reflect.get(target, p, receiver);
77
- if (typeof value === 'function' &&
78
- core_1.Compiler.prototype.hasOwnProperty(p)) {
79
- return value.bind(target);
76
+ getOptions() {
77
+ return this.compilerOptions;
78
+ }
79
+ setOptions(newOptions) {
80
+ this.compilerOptions = newOptions;
81
+ this.emitter.emit("option", this.compilerOptions);
82
+ return this.compilerOptions;
83
+ }
84
+ mergeOptions(newOptions) {
85
+ this.compilerOptions = external_rspack_merge_default()(this.compilerOptions, newOptions);
86
+ this.emitter.emit("option", this.compilerOptions);
87
+ return this.compilerOptions;
88
+ }
89
+ getCompiler() {
90
+ return this.compilerInstance;
91
+ }
92
+ createCompiler() {
93
+ this.compilerInstance = __webpack_require__("@rspack/core")(this.compilerOptions);
94
+ if (__DEBUG__) {
95
+ const context = this.context;
96
+ this.compilerInstance = new Proxy(this.compilerInstance, {
97
+ get (target, p, receiver) {
98
+ const value = Reflect.get(target, p, receiver);
99
+ if ('function' == typeof value && core_.Compiler.prototype.hasOwnProperty(p)) return value.bind(target);
100
+ return value;
101
+ },
102
+ set (target, p, value, receiver) {
103
+ const debugSetProperties = context.getValue(debug_js_namespaceObject.DEBUG_SCOPES.CreateCompilerSetProperties) || [];
104
+ debugSetProperties.push(`${p} ${new Error().stack?.split('\n')[2]?.trim()}`);
105
+ context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.CreateCompilerSetProperties, debugSetProperties);
106
+ return Reflect.set(target, p, value, receiver);
80
107
  }
81
- return value;
82
- },
83
- set(target, p, value, receiver) {
84
- const debugSetProperties = context.getValue(debug_1.DEBUG_SCOPES.CreateCompilerSetProperties) || [];
85
- debugSetProperties.push(`${p} ${new Error().stack?.split('\n')[2]?.trim()}`);
86
- context.setValue(debug_1.DEBUG_SCOPES.CreateCompilerSetProperties, debugSetProperties);
87
- return Reflect.set(target, p, value, receiver);
88
- },
89
- });
90
- this.context.setValue(debug_1.DEBUG_SCOPES.CreateCompilerInstance, {
91
- path: require.resolve('@rspack/core'),
92
- mode: 'callback',
93
- });
108
+ });
109
+ this.context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.CreateCompilerInstance, {
110
+ path: require.resolve('@rspack/core'),
111
+ mode: 'no-callback'
112
+ });
113
+ }
114
+ this.emitter.emit("create", this.compilerInstance);
115
+ return this.compilerInstance;
94
116
  }
95
- this.emitter.emit(ECompilerEvent.Create, this.compilerInstance);
96
- return this.compilerInstance;
97
- }
98
- build() {
99
- if (!this.compilerInstance)
100
- throw new Error('Compiler should be created before build');
101
- return new Promise((resolve, reject) => {
102
- try {
117
+ createCompilerWithCallback(callback) {
118
+ this.compilerInstance = __webpack_require__("@rspack/core")(this.compilerOptions, callback);
119
+ if (__DEBUG__) {
103
120
  const context = this.context;
104
- if (__DEBUG__) {
105
- context.setValue(debug_1.DEBUG_SCOPES.BuildMethod, {
106
- method: 'run',
121
+ this.compilerInstance = new Proxy(this.compilerInstance, {
122
+ get (target, p, receiver) {
123
+ const value = Reflect.get(target, p, receiver);
124
+ if ('function' == typeof value && core_.Compiler.prototype.hasOwnProperty(p)) return value.bind(target);
125
+ return value;
126
+ },
127
+ set (target, p, value, receiver) {
128
+ const debugSetProperties = context.getValue(debug_js_namespaceObject.DEBUG_SCOPES.CreateCompilerSetProperties) || [];
129
+ debugSetProperties.push(`${p} ${new Error().stack?.split('\n')[2]?.trim()}`);
130
+ context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.CreateCompilerSetProperties, debugSetProperties);
131
+ return Reflect.set(target, p, value, receiver);
132
+ }
133
+ });
134
+ this.context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.CreateCompilerInstance, {
135
+ path: require.resolve('@rspack/core'),
136
+ mode: 'callback'
137
+ });
138
+ }
139
+ this.emitter.emit("create", this.compilerInstance);
140
+ return this.compilerInstance;
141
+ }
142
+ build() {
143
+ if (!this.compilerInstance) throw new Error('Compiler should be created before build');
144
+ return new Promise((resolve, reject)=>{
145
+ try {
146
+ const context = this.context;
147
+ if (__DEBUG__) context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildMethod, {
148
+ method: 'run'
107
149
  });
108
- }
109
- this.compilerInstance.run((error, newStats) => {
110
- this.emitter.emit(ECompilerEvent.Build, error, newStats);
111
- if (error) {
112
- if (__DEBUG__) {
113
- context.setValue(debug_1.DEBUG_SCOPES.BuildError, {
150
+ this.compilerInstance.run((error, newStats)=>{
151
+ this.emitter.emit("build", error, newStats);
152
+ if (error) {
153
+ if (__DEBUG__) context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildError, {
114
154
  type: 'fatal',
115
- errors: [error],
155
+ errors: [
156
+ error
157
+ ]
116
158
  });
159
+ return reject(error);
117
160
  }
118
- return reject(error);
119
- }
120
- this.compilerStats = newStats;
121
- if (__DEBUG__) {
122
- if (newStats?.hasErrors()) {
123
- context.setValue(debug_1.DEBUG_SCOPES.BuildError, {
161
+ this.compilerStats = newStats;
162
+ if (__DEBUG__) {
163
+ if (newStats?.hasErrors()) context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildError, {
124
164
  type: 'stats',
125
165
  errors: newStats.toJson({
126
- errors: true,
127
- }).errors || [],
166
+ errors: true
167
+ }).errors || []
128
168
  });
129
- }
130
- if (newStats?.hasWarnings()) {
131
- context.setValue(debug_1.DEBUG_SCOPES.BuildWarning, newStats.toJson({
132
- warnings: true,
169
+ if (newStats?.hasWarnings()) context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildWarning, newStats.toJson({
170
+ warnings: true
133
171
  }).warnings || []);
134
172
  }
135
- }
136
- resolve(newStats);
137
- });
138
- }
139
- catch (e) {
140
- reject(e);
141
- }
142
- });
143
- }
144
- watch(timeout = 1000) {
145
- if (!this.compilerInstance)
146
- throw new Error('Compiler should be created before watch');
147
- const context = this.context;
148
- const watchOptions = {
149
- // IMPORTANT:
150
- // This is a workaround for the issue that watchpack cannot detect the file change in time
151
- // so we set the poll to 300ms to make it more sensitive to the file change
152
- poll: 300,
153
- // Rspack ignored node_modules and .git by default for better performance, but for tests we
154
- // want to watch all files, which aligns with webpack's default behavior
155
- ignored: [],
156
- aggregateTimeout: timeout,
157
- };
158
- if (__DEBUG__) {
159
- context.setValue(debug_1.DEBUG_SCOPES.BuildMethod, {
160
- method: 'watch',
161
- options: watchOptions,
162
- });
163
- }
164
- this.compilerInstance.watch(watchOptions, (error, newStats) => {
165
- this.emitter.emit(ECompilerEvent.Build, error, newStats);
166
- if (__DEBUG__) {
167
- if (error) {
168
- context.setValue(debug_1.DEBUG_SCOPES.BuildError, {
169
- type: 'fatal',
170
- errors: [error],
173
+ resolve(newStats);
171
174
  });
172
- return error;
175
+ } catch (e) {
176
+ reject(e);
173
177
  }
174
- }
175
- if (newStats) {
178
+ });
179
+ }
180
+ watch(timeout = 1000) {
181
+ if (!this.compilerInstance) throw new Error('Compiler should be created before watch');
182
+ const context = this.context;
183
+ const watchOptions = {
184
+ poll: 300,
185
+ ignored: [],
186
+ aggregateTimeout: timeout
187
+ };
188
+ if (__DEBUG__) context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildMethod, {
189
+ method: 'watch',
190
+ options: watchOptions
191
+ });
192
+ this.compilerInstance.watch(watchOptions, (error, newStats)=>{
193
+ this.emitter.emit("build", error, newStats);
176
194
  if (__DEBUG__) {
177
- if (newStats.hasErrors()) {
178
- context.setValue(debug_1.DEBUG_SCOPES.BuildError, {
195
+ if (error) {
196
+ context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildError, {
197
+ type: 'fatal',
198
+ errors: [
199
+ error
200
+ ]
201
+ });
202
+ return error;
203
+ }
204
+ }
205
+ if (newStats) {
206
+ if (__DEBUG__) {
207
+ if (newStats.hasErrors()) context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildError, {
179
208
  type: 'stats',
180
209
  errors: newStats.toJson({
181
- errors: true,
182
- }).errors || [],
210
+ errors: true
211
+ }).errors || []
183
212
  });
184
- }
185
- if (newStats.hasWarnings()) {
186
- context.setValue(debug_1.DEBUG_SCOPES.BuildWarning, newStats.toJson({
187
- warnings: true,
213
+ if (newStats.hasWarnings()) context.setValue(debug_js_namespaceObject.DEBUG_SCOPES.BuildWarning, newStats.toJson({
214
+ warnings: true
188
215
  }).warnings || []);
189
216
  }
217
+ this.compilerStats = newStats;
190
218
  }
191
- this.compilerStats = newStats;
192
- }
193
- return newStats;
194
- });
195
- }
196
- getStats() {
197
- return this.compilerStats;
198
- }
199
- getEmitter() {
200
- return this.emitter;
201
- }
202
- close() {
203
- return new Promise((resolve, reject) => {
204
- if (this.compilerInstance) {
205
- this.compilerInstance.close((e) => {
206
- this.emitter.emit(ECompilerEvent.Close, e);
207
- if (e) {
208
- reject(e);
209
- }
210
- else {
211
- resolve();
212
- }
219
+ return newStats;
220
+ });
221
+ }
222
+ getStats() {
223
+ return this.compilerStats;
224
+ }
225
+ getEmitter() {
226
+ return this.emitter;
227
+ }
228
+ close() {
229
+ return new Promise((resolve, reject)=>{
230
+ if (this.compilerInstance) this.compilerInstance.close((e)=>{
231
+ this.emitter.emit("close", e);
232
+ if (e) reject(e);
233
+ else resolve();
213
234
  });
214
- }
215
- else {
216
- resolve();
217
- }
218
- });
235
+ else resolve();
236
+ });
237
+ }
219
238
  }
220
- }
221
- exports.TestCompilerManager = TestCompilerManager;
239
+ })();
240
+ exports.ECompilerEvent = __webpack_exports__.ECompilerEvent;
241
+ exports.TestCompilerManager = __webpack_exports__.TestCompilerManager;
242
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
243
+ "ECompilerEvent",
244
+ "TestCompilerManager"
245
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
246
+ Object.defineProperty(exports, '__esModule', {
247
+ value: true
248
+ });
@@ -1,98 +1,110 @@
1
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.isValidCaseDirectory = exports.isFile = exports.isDirectory = void 0;
7
- exports.describeByWalk = describeByWalk;
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const _1 = require(".");
11
- const isDirectory = (p) => node_fs_1.default.lstatSync(p).isDirectory();
12
- exports.isDirectory = isDirectory;
13
- const isFile = (p) => node_fs_1.default.lstatSync(p).isFile();
14
- exports.isFile = isFile;
15
- const isValidCaseDirectory = (name) => !name.startsWith('_') && !name.startsWith('.') && name !== 'node_modules';
16
- exports.isValidCaseDirectory = isValidCaseDirectory;
17
- function describeByWalk(
18
- /**
19
- * The test file absolute path.
20
- */
21
- testFile, createCase, options = {}) {
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
+ describeByWalk: ()=>describeByWalk,
37
+ isDirectory: ()=>isDirectory,
38
+ isFile: ()=>isFile,
39
+ isValidCaseDirectory: ()=>isValidCaseDirectory
40
+ });
41
+ const external_node_fs_namespaceObject = require("node:fs");
42
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
43
+ const external_node_path_namespaceObject = require("node:path");
44
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
45
+ const external_index_js_namespaceObject = require("./index.js");
46
+ const isDirectory = (p)=>external_node_fs_default().lstatSync(p).isDirectory();
47
+ const isFile = (p)=>external_node_fs_default().lstatSync(p).isFile();
48
+ const isValidCaseDirectory = (name)=>!name.startsWith('_') && !name.startsWith('.') && 'node_modules' !== name;
49
+ function describeByWalk(testFile, createCase, options = {}) {
22
50
  const describeFn = options.describe || describe;
23
- const testBasename = node_path_1.default
24
- .basename(testFile)
25
- .replace(/(\.part\d+)?\.(diff|hot)?test\.(j|t)s/, '');
51
+ const testBasename = external_node_path_default().basename(testFile).replace(/(\.part\d+)?\.(diff|hot)?test\.(j|t)s/, '');
26
52
  const testId = testBasename.charAt(0).toLowerCase() + testBasename.slice(1);
27
- const sourceBase = options.source || node_path_1.default.join(node_path_1.default.dirname(testFile), `${testId}Cases`);
28
- const testSourceId = node_path_1.default.basename(sourceBase);
29
- const absoluteTestDir = node_path_1.default.dirname(testFile);
30
- const distBase = options.dist || node_path_1.default.join(node_path_1.default.dirname(testFile), 'js', testId);
53
+ const sourceBase = options.source || external_node_path_default().join(external_node_path_default().dirname(testFile), `${testId}Cases`);
54
+ const testSourceId = external_node_path_default().basename(sourceBase);
55
+ const absoluteTestDir = external_node_path_default().dirname(testFile);
56
+ const distBase = options.dist || external_node_path_default().join(external_node_path_default().dirname(testFile), 'js', testId);
31
57
  const level = options.level || 2;
32
58
  const type = options.type || 'directory';
33
59
  const absoluteDist = options.absoluteDist ?? true;
34
60
  function describeDirectory(dirname, currentLevel) {
35
- node_fs_1.default.readdirSync(node_path_1.default.join(sourceBase, dirname))
36
- .filter(exports.isValidCaseDirectory)
37
- .filter((folder) => {
61
+ external_node_fs_default().readdirSync(external_node_path_default().join(sourceBase, dirname)).filter(isValidCaseDirectory).filter((folder)=>{
38
62
  if (options.exclude) {
39
- if (options.exclude.some((exclude) => {
40
- return exclude.test(node_path_1.default.join(dirname, folder).replace(/\\/g, '/'));
41
- })) {
42
- return false;
43
- }
63
+ if (options.exclude.some((exclude)=>exclude.test(external_node_path_default().join(dirname, folder).replace(/\\/g, '/')))) return false;
44
64
  }
45
65
  return true;
46
- })
47
- .filter((folder) => {
48
- const p = node_path_1.default.join(sourceBase, dirname, folder);
49
- if (type === 'file' && currentLevel === 1) {
50
- return (0, exports.isFile)(p);
51
- }
52
- if (type === 'directory' || currentLevel > 1) {
53
- return (0, exports.isDirectory)(p);
54
- }
66
+ }).filter((folder)=>{
67
+ const p = external_node_path_default().join(sourceBase, dirname, folder);
68
+ if ('file' === type && 1 === currentLevel) return isFile(p);
69
+ if ('directory' === type || currentLevel > 1) return isDirectory(p);
55
70
  return false;
56
- })
57
- .map((folder) => {
58
- const caseName = node_path_1.default.join(dirname, folder);
59
- if (currentLevel > 1) {
60
- describeDirectory(caseName, currentLevel - 1);
61
- }
71
+ }).map((folder)=>{
72
+ const caseName = external_node_path_default().join(dirname, folder);
73
+ if (currentLevel > 1) describeDirectory(caseName, currentLevel - 1);
62
74
  else {
63
- const name = (0, _1.escapeSep)(node_path_1.default
64
- .join(`${testId}Cases-${testSourceId}`, caseName)
65
- .split('.')
66
- .shift());
75
+ const name = (0, external_index_js_namespaceObject.escapeSep)(external_node_path_default().join(`${testId}Cases-${testSourceId}`, caseName).split('.').shift());
67
76
  let suiteName = name;
68
- // support filter test by absolute path
69
77
  if (process.env.testFilter?.includes(absoluteTestDir)) {
70
- const fullCasePath = node_path_1.default.join(absoluteTestDir, testSourceId, caseName);
71
- if (fullCasePath.includes(process.env.testFilter)) {
72
- suiteName = fullCasePath;
73
- }
78
+ const fullCasePath = external_node_path_default().join(absoluteTestDir, testSourceId, caseName);
79
+ if (fullCasePath.includes(process.env.testFilter)) suiteName = fullCasePath;
74
80
  }
75
- describeFn(suiteName, () => {
76
- const source = node_path_1.default.join(sourceBase, caseName);
81
+ describeFn(suiteName, ()=>{
82
+ const source = external_node_path_default().join(sourceBase, caseName);
77
83
  let dist = '';
78
- if (absoluteDist) {
79
- dist = node_path_1.default.join(distBase, caseName);
80
- }
84
+ if (absoluteDist) dist = external_node_path_default().join(distBase, caseName);
81
85
  else {
82
86
  const relativeDist = options.dist || 'dist';
83
- if (node_path_1.default.isAbsolute(relativeDist)) {
84
- dist = node_path_1.default.join(relativeDist, caseName);
85
- }
86
- else {
87
- dist = node_path_1.default.join(sourceBase, caseName, relativeDist);
88
- }
87
+ dist = external_node_path_default().isAbsolute(relativeDist) ? external_node_path_default().join(relativeDist, caseName) : external_node_path_default().join(sourceBase, caseName, relativeDist);
89
88
  }
90
89
  createCase(suiteName, source, dist);
91
90
  });
92
91
  }
93
92
  });
94
93
  }
95
- describeFn(testId, () => {
94
+ describeFn(testId, ()=>{
96
95
  describeDirectory('', level);
97
96
  });
98
97
  }
98
+ exports.describeByWalk = __webpack_exports__.describeByWalk;
99
+ exports.isDirectory = __webpack_exports__.isDirectory;
100
+ exports.isFile = __webpack_exports__.isFile;
101
+ exports.isValidCaseDirectory = __webpack_exports__.isValidCaseDirectory;
102
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
103
+ "describeByWalk",
104
+ "isDirectory",
105
+ "isFile",
106
+ "isValidCaseDirectory"
107
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
108
+ Object.defineProperty(exports, '__esModule', {
109
+ value: true
110
+ });