@rspack/test-tools 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/case/builtin.js +106 -66
- package/dist/case/cache.js +136 -122
- 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 +21 -20
package/dist/case/esm-output.js
CHANGED
|
@@ -1,104 +1,135 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
createEsmOutputCase: ()=>createEsmOutputCase
|
|
28
|
+
});
|
|
29
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
30
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
31
|
+
const external_runner_js_namespaceObject = require("./runner.js");
|
|
32
|
+
const creator = new creator_js_namespaceObject.BasicCaseCreator({
|
|
8
33
|
clean: true,
|
|
9
34
|
describe: false,
|
|
10
|
-
testConfig: (testConfig)
|
|
35
|
+
testConfig: (testConfig)=>{
|
|
11
36
|
const oldModuleScope = testConfig.moduleScope;
|
|
12
|
-
testConfig.moduleScope = (ms, stats)
|
|
37
|
+
testConfig.moduleScope = (ms, stats)=>{
|
|
13
38
|
let res = ms;
|
|
14
|
-
|
|
15
|
-
if (typeof oldModuleScope === 'function') {
|
|
16
|
-
res = oldModuleScope(ms, stats);
|
|
17
|
-
}
|
|
39
|
+
if ('function' == typeof oldModuleScope) res = oldModuleScope(ms, stats);
|
|
18
40
|
return res;
|
|
19
41
|
};
|
|
20
42
|
},
|
|
21
|
-
steps: ({ name })
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
steps: ({ name })=>[
|
|
44
|
+
{
|
|
45
|
+
config: (context)=>{
|
|
46
|
+
(0, external_common_js_namespaceObject.configMultiCompiler)(context, name, [
|
|
47
|
+
'rspack.config.cjs',
|
|
48
|
+
'rspack.config.js',
|
|
49
|
+
'webpack.config.js'
|
|
50
|
+
], defaultOptions, ()=>{});
|
|
51
|
+
},
|
|
52
|
+
compiler: async (context)=>{
|
|
53
|
+
await (0, external_common_js_namespaceObject.compiler)(context, name);
|
|
54
|
+
},
|
|
55
|
+
build: async (context)=>{
|
|
56
|
+
await (0, external_common_js_namespaceObject.build)(context, name);
|
|
57
|
+
},
|
|
58
|
+
run: async (env, context)=>{
|
|
59
|
+
await (0, external_common_js_namespaceObject.run)(env, context, name, (context)=>(0, external_common_js_namespaceObject.findMultiCompilerBundle)(context, name, (_index, context, options)=>{
|
|
60
|
+
const testConfig = context.getTestConfig();
|
|
61
|
+
if ('function' == typeof testConfig.findBundle) return testConfig.findBundle(_index, options);
|
|
62
|
+
if (options.output?.filename === '[name].mjs') return [
|
|
63
|
+
'main.mjs'
|
|
64
|
+
];
|
|
65
|
+
return [
|
|
66
|
+
options.output.filename
|
|
67
|
+
];
|
|
68
|
+
}));
|
|
69
|
+
},
|
|
70
|
+
check: async (env, context)=>{
|
|
71
|
+
await (0, external_common_js_namespaceObject.check)(env, context, name);
|
|
34
72
|
const testConfig = context.getTestConfig();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return [options.output.filename];
|
|
43
|
-
}
|
|
44
|
-
}));
|
|
45
|
-
},
|
|
46
|
-
check: async (env, context) => {
|
|
47
|
-
await (0, common_1.check)(env, context, name);
|
|
48
|
-
const testConfig = context.getTestConfig();
|
|
49
|
-
await (0, common_1.checkSnapshot)(env, context, name, 'esm.snap.txt', testConfig.snapshotFileFilter);
|
|
50
|
-
},
|
|
51
|
-
after: async (context) => {
|
|
52
|
-
await (0, common_1.afterExecute)(context, name);
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
],
|
|
73
|
+
await (0, external_common_js_namespaceObject.checkSnapshot)(env, context, name, 'esm.snap.txt', testConfig.snapshotFileFilter);
|
|
74
|
+
},
|
|
75
|
+
after: async (context)=>{
|
|
76
|
+
await (0, external_common_js_namespaceObject.afterExecute)(context, name);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
56
80
|
runner: {
|
|
57
|
-
key:
|
|
58
|
-
runner:
|
|
81
|
+
key: external_runner_js_namespaceObject.getMultiCompilerRunnerKey,
|
|
82
|
+
runner: external_runner_js_namespaceObject.createMultiCompilerRunner
|
|
59
83
|
},
|
|
60
|
-
concurrent: 1
|
|
84
|
+
concurrent: 1
|
|
61
85
|
});
|
|
62
|
-
const defaultOptions = (_index, context)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
const defaultOptions = (_index, context)=>({
|
|
87
|
+
context: context.getSource(),
|
|
88
|
+
mode: 'production',
|
|
89
|
+
target: 'async-node',
|
|
90
|
+
devtool: false,
|
|
91
|
+
entry: './index.js',
|
|
92
|
+
cache: false,
|
|
93
|
+
output: {
|
|
94
|
+
path: context.getDist(),
|
|
95
|
+
filename: '[name].mjs',
|
|
96
|
+
pathinfo: true,
|
|
97
|
+
module: true,
|
|
98
|
+
library: {
|
|
99
|
+
type: 'modern-module'
|
|
100
|
+
},
|
|
101
|
+
bundlerInfo: {
|
|
102
|
+
force: false
|
|
103
|
+
}
|
|
76
104
|
},
|
|
77
|
-
|
|
78
|
-
|
|
105
|
+
module: {
|
|
106
|
+
defaultRules: [
|
|
107
|
+
'...',
|
|
108
|
+
{
|
|
109
|
+
test: /\.css$/i,
|
|
110
|
+
type: 'css/auto'
|
|
111
|
+
}
|
|
112
|
+
]
|
|
79
113
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
'
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
minimize: false,
|
|
93
|
-
moduleIds: 'named',
|
|
94
|
-
chunkIds: 'named',
|
|
95
|
-
runtimeChunk: 'single',
|
|
96
|
-
},
|
|
97
|
-
externals: {
|
|
98
|
-
fs: 'module-import fs',
|
|
99
|
-
path: 'module-import path',
|
|
100
|
-
},
|
|
101
|
-
});
|
|
114
|
+
bail: true,
|
|
115
|
+
optimization: {
|
|
116
|
+
minimize: false,
|
|
117
|
+
moduleIds: 'named',
|
|
118
|
+
chunkIds: 'named',
|
|
119
|
+
runtimeChunk: 'single'
|
|
120
|
+
},
|
|
121
|
+
externals: {
|
|
122
|
+
fs: 'fs',
|
|
123
|
+
path: 'path'
|
|
124
|
+
}
|
|
125
|
+
});
|
|
102
126
|
function createEsmOutputCase(name, src, dist) {
|
|
103
127
|
creator.create(name, src, dist);
|
|
104
128
|
}
|
|
129
|
+
exports.createEsmOutputCase = __webpack_exports__.createEsmOutputCase;
|
|
130
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
131
|
+
"createEsmOutputCase"
|
|
132
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
133
|
+
Object.defineProperty(exports, '__esModule', {
|
|
134
|
+
value: true
|
|
135
|
+
});
|
package/dist/case/example.js
CHANGED
|
@@ -1,57 +1,95 @@
|
|
|
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
|
+
createExampleCase: ()=>createExampleCase
|
|
37
|
+
});
|
|
38
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
39
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
40
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
41
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
10
42
|
function overrideOptions(index, context, options) {
|
|
11
43
|
options.context = context.getSource();
|
|
12
44
|
options.output = options.output || {};
|
|
13
45
|
options.output.pathinfo = true;
|
|
14
46
|
options.output.path = context.getDist();
|
|
15
47
|
options.output.publicPath = 'dist/';
|
|
16
|
-
if (!options.entry)
|
|
17
|
-
|
|
18
|
-
if (!options.plugins)
|
|
19
|
-
options.plugins = [];
|
|
48
|
+
if (!options.entry) options.entry = './example.js';
|
|
49
|
+
if (!options.plugins) options.plugins = [];
|
|
20
50
|
}
|
|
21
51
|
function createExampleProcessor(name) {
|
|
22
52
|
return {
|
|
23
|
-
config:
|
|
24
|
-
(0,
|
|
53
|
+
config: (context)=>{
|
|
54
|
+
(0, external_common_js_namespaceObject.configMultiCompiler)(context, name, [
|
|
55
|
+
'rspack.config.js',
|
|
56
|
+
'webpack.config.js'
|
|
57
|
+
], ()=>({}), overrideOptions);
|
|
25
58
|
},
|
|
26
|
-
compiler: async (context)
|
|
27
|
-
await (0,
|
|
59
|
+
compiler: async (context)=>{
|
|
60
|
+
await (0, external_common_js_namespaceObject.compiler)(context, name);
|
|
28
61
|
},
|
|
29
|
-
build: async (context)
|
|
30
|
-
await (0,
|
|
62
|
+
build: async (context)=>{
|
|
63
|
+
await (0, external_common_js_namespaceObject.build)(context, name);
|
|
31
64
|
},
|
|
32
|
-
run: async (env, context)
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
check: async (env, context) => {
|
|
65
|
+
run: async (env, context)=>{},
|
|
66
|
+
check: (env, context)=>{
|
|
36
67
|
const compiler = context.getCompiler();
|
|
37
68
|
const stats = compiler.getStats();
|
|
38
|
-
if (stats?.hasErrors()) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
69
|
+
if (stats?.hasErrors()) console.log(stats.toString({
|
|
70
|
+
all: false,
|
|
71
|
+
errors: true,
|
|
72
|
+
errorDetails: true,
|
|
73
|
+
errorStack: true
|
|
74
|
+
}));
|
|
46
75
|
expect(stats?.hasErrors()).toBe(false);
|
|
47
|
-
}
|
|
76
|
+
}
|
|
48
77
|
};
|
|
49
78
|
}
|
|
50
|
-
const creator = new
|
|
79
|
+
const creator = new creator_js_namespaceObject.BasicCaseCreator({
|
|
51
80
|
clean: true,
|
|
52
|
-
steps: ({ name })
|
|
53
|
-
|
|
81
|
+
steps: ({ name })=>[
|
|
82
|
+
createExampleProcessor(name)
|
|
83
|
+
],
|
|
84
|
+
concurrent: true
|
|
54
85
|
});
|
|
55
86
|
function createExampleCase(name, src) {
|
|
56
|
-
creator.create(name, src,
|
|
87
|
+
creator.create(name, src, external_node_path_default().join(src, 'dist'));
|
|
57
88
|
}
|
|
89
|
+
exports.createExampleCase = __webpack_exports__.createExampleCase;
|
|
90
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
91
|
+
"createExampleCase"
|
|
92
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
93
|
+
Object.defineProperty(exports, '__esModule', {
|
|
94
|
+
value: true
|
|
95
|
+
});
|
package/dist/case/hash.js
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
createHashCase: ()=>createHashCase
|
|
28
|
+
});
|
|
29
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
30
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
6
31
|
const REG_ERROR_CASE = /error$/;
|
|
7
|
-
class HashCaseCreator extends
|
|
32
|
+
class HashCaseCreator extends creator_js_namespaceObject.BasicCaseCreator {
|
|
8
33
|
describe(name, tester, testConfig, options) {
|
|
9
|
-
it(`should print correct hash for ${name}`, async ()
|
|
34
|
+
it(`should print correct hash for ${name}`, async ()=>{
|
|
10
35
|
await tester.prepare();
|
|
11
36
|
await tester.compile();
|
|
12
37
|
await tester.check(this.createEnv(testConfig, options));
|
|
@@ -17,25 +42,26 @@ class HashCaseCreator extends creator_1.BasicCaseCreator {
|
|
|
17
42
|
const creator = new HashCaseCreator({
|
|
18
43
|
clean: true,
|
|
19
44
|
describe: false,
|
|
20
|
-
steps: ({ name })
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
steps: ({ name })=>[
|
|
46
|
+
{
|
|
47
|
+
config: (context)=>{
|
|
48
|
+
(0, external_common_js_namespaceObject.configMultiCompiler)(context, name, [
|
|
49
|
+
'rspack.config.js',
|
|
50
|
+
'webpack.config.js'
|
|
51
|
+
], defaultOptions, overrideOptions);
|
|
52
|
+
},
|
|
53
|
+
compiler: async (context)=>{
|
|
54
|
+
await (0, external_common_js_namespaceObject.compiler)(context, name);
|
|
55
|
+
},
|
|
56
|
+
build: async (context)=>{
|
|
57
|
+
await (0, external_common_js_namespaceObject.build)(context, name);
|
|
58
|
+
},
|
|
59
|
+
run: async (env, context)=>{},
|
|
60
|
+
check: async (env, context)=>{
|
|
61
|
+
await check(env, context, name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
39
65
|
});
|
|
40
66
|
function createHashCase(name, src, dist) {
|
|
41
67
|
creator.create(name, src, dist);
|
|
@@ -48,49 +74,38 @@ function defaultOptions(index, context) {
|
|
|
48
74
|
'...',
|
|
49
75
|
{
|
|
50
76
|
test: /\.css$/i,
|
|
51
|
-
type: 'css/auto'
|
|
52
|
-
}
|
|
53
|
-
]
|
|
77
|
+
type: 'css/auto'
|
|
78
|
+
}
|
|
79
|
+
]
|
|
54
80
|
},
|
|
55
81
|
output: {
|
|
56
82
|
path: context.getDist(),
|
|
57
83
|
bundlerInfo: {
|
|
58
|
-
force: false
|
|
59
|
-
}
|
|
60
|
-
}
|
|
84
|
+
force: false
|
|
85
|
+
}
|
|
86
|
+
}
|
|
61
87
|
};
|
|
62
88
|
}
|
|
63
89
|
function overrideOptions(index, context, options) {
|
|
64
|
-
if (!options.entry)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
options.infrastructureLogging = {
|
|
69
|
-
level: 'error',
|
|
70
|
-
};
|
|
71
|
-
}
|
|
90
|
+
if (!options.entry) options.entry = './index.js';
|
|
91
|
+
if (!global.printLogger) options.infrastructureLogging = {
|
|
92
|
+
level: 'error'
|
|
93
|
+
};
|
|
72
94
|
}
|
|
73
|
-
|
|
95
|
+
function check(env, context, name) {
|
|
74
96
|
const compiler = context.getCompiler();
|
|
75
97
|
const stats = compiler.getStats();
|
|
76
98
|
const testConfig = context.getTestConfig();
|
|
77
|
-
if (!stats)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.join('\n'));
|
|
83
|
-
}
|
|
84
|
-
if (REG_ERROR_CASE.test(name)) {
|
|
85
|
-
env.expect(stats.hasErrors());
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
env.expect(!stats.hasErrors());
|
|
89
|
-
}
|
|
90
|
-
if (typeof testConfig.validate === 'function') {
|
|
91
|
-
testConfig.validate(stats);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
throw new Error('HashTestCases should have test.config.js and a validate method');
|
|
95
|
-
}
|
|
99
|
+
if (!stats) throw new Error('No stats found\n' + context.getError().map((e)=>e.stack).join('\n'));
|
|
100
|
+
if (REG_ERROR_CASE.test(name)) env.expect(stats.hasErrors());
|
|
101
|
+
else env.expect(!stats.hasErrors());
|
|
102
|
+
if ('function' == typeof testConfig.validate) testConfig.validate(stats);
|
|
103
|
+
else throw new Error('HashTestCases should have test.config.js and a validate method');
|
|
96
104
|
}
|
|
105
|
+
exports.createHashCase = __webpack_exports__.createHashCase;
|
|
106
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
107
|
+
"createHashCase"
|
|
108
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
109
|
+
Object.defineProperty(exports, '__esModule', {
|
|
110
|
+
value: true
|
|
111
|
+
});
|