diff --git a/packages/rspack-test-tools/jest.config.compat.js b/packages/rspack-test-tools/jest.config.compat.js index 6f6d771c1d7..3a9bacf318f 100644 --- a/packages/rspack-test-tools/jest.config.compat.js +++ b/packages/rspack-test-tools/jest.config.compat.js @@ -14,6 +14,7 @@ module.exports = { "/tests/HotTestCasesWeb.test.js", "/tests/HotTestCasesNode.test.js", "/tests/HotTestCasesWebWorker.test.js", - "/tests/Diagnostics.test.js" + "/tests/Diagnostics.test.js", + "/tests/StatsTestCases.basictest.js" ] }; diff --git a/packages/rspack-test-tools/jest.config.legacy.js b/packages/rspack-test-tools/jest.config.legacy.js index debee28b768..4600d4ca745 100644 --- a/packages/rspack-test-tools/jest.config.legacy.js +++ b/packages/rspack-test-tools/jest.config.legacy.js @@ -17,6 +17,7 @@ module.exports = { "HotTestCasesWebWorker.test.js", "HotTestCasesNode.test.js", "Diagnostics.test.js", + "StatsTestCases.basictest.js", ".difftest.js" ] }; diff --git a/packages/rspack-test-tools/tests/StatsTestCases.basictest.js b/packages/rspack-test-tools/tests/StatsTestCases.basictest.js index a0c4951a841..92b92a32d73 100644 --- a/packages/rspack-test-tools/tests/StatsTestCases.basictest.js +++ b/packages/rspack-test-tools/tests/StatsTestCases.basictest.js @@ -3,8 +3,8 @@ const fs = require("fs"); const { createStatsCase } = require(".."); const NAME = "StatsTestCases"; -const caseDir = path.resolve(__dirname, "../../rspack/tests/statsCases"); -const distDir = path.resolve(__dirname, `../../rspack/tests/js/stats`); +const caseDir = path.resolve(__dirname, "./statsCases"); +const distDir = path.resolve(__dirname, `./js/stats`); const tests = fs .readdirSync(caseDir) diff --git a/packages/rspack/tests/__snapshots__/StatsTestCases.basictest.js.snap b/packages/rspack-test-tools/tests/__snapshots__/StatsTestCases.basictest.js.snap similarity index 100% rename from packages/rspack/tests/__snapshots__/StatsTestCases.basictest.js.snap rename to packages/rspack-test-tools/tests/__snapshots__/StatsTestCases.basictest.js.snap diff --git a/packages/rspack/tests/statsCases/auxiliary-files-test/index.js b/packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/index.js similarity index 100% rename from packages/rspack/tests/statsCases/auxiliary-files-test/index.js rename to packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/index.js diff --git a/packages/rspack/tests/statsCases/auxiliary-files-test/raw.png b/packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/raw.png similarity index 100% rename from packages/rspack/tests/statsCases/auxiliary-files-test/raw.png rename to packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/raw.png diff --git a/packages/rspack/tests/statsCases/auxiliary-files-test/stringModule.js b/packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/stringModule.js similarity index 100% rename from packages/rspack/tests/statsCases/auxiliary-files-test/stringModule.js rename to packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/stringModule.js diff --git a/packages/rspack/tests/statsCases/auxiliary-files-test/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/auxiliary-files-test/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/auxiliary-files-test/webpack.config.js diff --git a/packages/rspack/tests/statsCases/builtin-swc-loader-parse-error/index.ts b/packages/rspack-test-tools/tests/statsCases/builtin-swc-loader-parse-error/index.ts similarity index 100% rename from packages/rspack/tests/statsCases/builtin-swc-loader-parse-error/index.ts rename to packages/rspack-test-tools/tests/statsCases/builtin-swc-loader-parse-error/index.ts diff --git a/packages/rspack/tests/statsCases/builtin-swc-loader-parse-error/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/builtin-swc-loader-parse-error/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/builtin-swc-loader-parse-error/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/builtin-swc-loader-parse-error/webpack.config.js diff --git a/packages/rspack/tests/statsCases/css-concat-error/foo.css b/packages/rspack-test-tools/tests/statsCases/css-concat-error/foo.css similarity index 100% rename from packages/rspack/tests/statsCases/css-concat-error/foo.css rename to packages/rspack-test-tools/tests/statsCases/css-concat-error/foo.css diff --git a/packages/rspack/tests/statsCases/css-concat-error/index.js b/packages/rspack-test-tools/tests/statsCases/css-concat-error/index.js similarity index 100% rename from packages/rspack/tests/statsCases/css-concat-error/index.js rename to packages/rspack-test-tools/tests/statsCases/css-concat-error/index.js diff --git a/packages/rspack/tests/statsCases/css-concat-error/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/css-concat-error/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/css-concat-error/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/css-concat-error/webpack.config.js diff --git a/packages/rspack/tests/statsCases/filename/dynamic.js b/packages/rspack-test-tools/tests/statsCases/filename/dynamic.js similarity index 100% rename from packages/rspack/tests/statsCases/filename/dynamic.js rename to packages/rspack-test-tools/tests/statsCases/filename/dynamic.js diff --git a/packages/rspack/tests/statsCases/filename/index.js b/packages/rspack-test-tools/tests/statsCases/filename/index.js similarity index 100% rename from packages/rspack/tests/statsCases/filename/index.js rename to packages/rspack-test-tools/tests/statsCases/filename/index.js diff --git a/packages/rspack/tests/statsCases/filename/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/filename/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/filename/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/filename/webpack.config.js diff --git a/packages/rspack/tests/statsCases/hot+production/index.js b/packages/rspack-test-tools/tests/statsCases/hot+production/index.js similarity index 100% rename from packages/rspack/tests/statsCases/hot+production/index.js rename to packages/rspack-test-tools/tests/statsCases/hot+production/index.js diff --git a/packages/rspack/tests/statsCases/hot+production/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/hot+production/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/hot+production/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/hot+production/webpack.config.js diff --git a/packages/rspack/tests/statsCases/ignore-plugin/globalIndex.js b/packages/rspack-test-tools/tests/statsCases/ignore-plugin/globalIndex.js similarity index 100% rename from packages/rspack/tests/statsCases/ignore-plugin/globalIndex.js rename to packages/rspack-test-tools/tests/statsCases/ignore-plugin/globalIndex.js diff --git a/packages/rspack/tests/statsCases/ignore-plugin/index.js b/packages/rspack-test-tools/tests/statsCases/ignore-plugin/index.js similarity index 100% rename from packages/rspack/tests/statsCases/ignore-plugin/index.js rename to packages/rspack-test-tools/tests/statsCases/ignore-plugin/index.js diff --git a/packages/rspack/tests/statsCases/ignore-plugin/locals/en.js b/packages/rspack-test-tools/tests/statsCases/ignore-plugin/locals/en.js similarity index 100% rename from packages/rspack/tests/statsCases/ignore-plugin/locals/en.js rename to packages/rspack-test-tools/tests/statsCases/ignore-plugin/locals/en.js diff --git a/packages/rspack/tests/statsCases/ignore-plugin/locals/zh.js b/packages/rspack-test-tools/tests/statsCases/ignore-plugin/locals/zh.js similarity index 100% rename from packages/rspack/tests/statsCases/ignore-plugin/locals/zh.js rename to packages/rspack-test-tools/tests/statsCases/ignore-plugin/locals/zh.js diff --git a/packages/rspack/tests/statsCases/ignore-plugin/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/ignore-plugin/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/ignore-plugin/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/ignore-plugin/webpack.config.js diff --git a/packages/rspack/tests/statsCases/ignore-warning/index.js b/packages/rspack-test-tools/tests/statsCases/ignore-warning/index.js similarity index 100% rename from packages/rspack/tests/statsCases/ignore-warning/index.js rename to packages/rspack-test-tools/tests/statsCases/ignore-warning/index.js diff --git a/packages/rspack/tests/statsCases/ignore-warning/index.scss b/packages/rspack-test-tools/tests/statsCases/ignore-warning/index.scss similarity index 100% rename from packages/rspack/tests/statsCases/ignore-warning/index.scss rename to packages/rspack-test-tools/tests/statsCases/ignore-warning/index.scss diff --git a/packages/rspack/tests/statsCases/ignore-warning/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/ignore-warning/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/ignore-warning/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/ignore-warning/webpack.config.js diff --git a/packages/rspack/tests/statsCases/issue-3558/index.js b/packages/rspack-test-tools/tests/statsCases/issue-3558/index.js similarity index 100% rename from packages/rspack/tests/statsCases/issue-3558/index.js rename to packages/rspack-test-tools/tests/statsCases/issue-3558/index.js diff --git a/packages/rspack/tests/statsCases/issue-3558/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/issue-3558/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/issue-3558/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/issue-3558/webpack.config.js diff --git a/packages/rspack/tests/statsCases/legacy-ie-css-warning/index.css b/packages/rspack-test-tools/tests/statsCases/legacy-ie-css-warning/index.css similarity index 100% rename from packages/rspack/tests/statsCases/legacy-ie-css-warning/index.css rename to packages/rspack-test-tools/tests/statsCases/legacy-ie-css-warning/index.css diff --git a/packages/rspack/tests/statsCases/legacy-ie-css-warning/index.js b/packages/rspack-test-tools/tests/statsCases/legacy-ie-css-warning/index.js similarity index 100% rename from packages/rspack/tests/statsCases/legacy-ie-css-warning/index.js rename to packages/rspack-test-tools/tests/statsCases/legacy-ie-css-warning/index.js diff --git a/packages/rspack/tests/statsCases/legacy-ie-css-warning/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/legacy-ie-css-warning/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/legacy-ie-css-warning/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/legacy-ie-css-warning/webpack.config.js diff --git a/packages/rspack/tests/statsCases/let-keyword-as-variable-name-error/index.js b/packages/rspack-test-tools/tests/statsCases/let-keyword-as-variable-name-error/index.js similarity index 100% rename from packages/rspack/tests/statsCases/let-keyword-as-variable-name-error/index.js rename to packages/rspack-test-tools/tests/statsCases/let-keyword-as-variable-name-error/index.js diff --git a/packages/rspack/tests/statsCases/let-keyword-as-variable-name-error/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/let-keyword-as-variable-name-error/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/let-keyword-as-variable-name-error/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/let-keyword-as-variable-name-error/webpack.config.js diff --git a/packages/rspack/tests/statsCases/limit-chunk-count-plugin/a.js b/packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/a.js similarity index 100% rename from packages/rspack/tests/statsCases/limit-chunk-count-plugin/a.js rename to packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/a.js diff --git a/packages/rspack/tests/statsCases/limit-chunk-count-plugin/b.js b/packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/b.js similarity index 100% rename from packages/rspack/tests/statsCases/limit-chunk-count-plugin/b.js rename to packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/b.js diff --git a/packages/rspack/tests/statsCases/limit-chunk-count-plugin/c.js b/packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/c.js similarity index 100% rename from packages/rspack/tests/statsCases/limit-chunk-count-plugin/c.js rename to packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/c.js diff --git a/packages/rspack/tests/statsCases/limit-chunk-count-plugin/d.js b/packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/d.js similarity index 100% rename from packages/rspack/tests/statsCases/limit-chunk-count-plugin/d.js rename to packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/d.js diff --git a/packages/rspack/tests/statsCases/limit-chunk-count-plugin/e.js b/packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/e.js similarity index 100% rename from packages/rspack/tests/statsCases/limit-chunk-count-plugin/e.js rename to packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/e.js diff --git a/packages/rspack/tests/statsCases/limit-chunk-count-plugin/index.js b/packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/index.js similarity index 100% rename from packages/rspack/tests/statsCases/limit-chunk-count-plugin/index.js rename to packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/index.js diff --git a/packages/rspack/tests/statsCases/limit-chunk-count-plugin/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/limit-chunk-count-plugin/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/limit-chunk-count-plugin/webpack.config.js diff --git a/packages/rspack/tests/statsCases/logging-loader/index.js b/packages/rspack-test-tools/tests/statsCases/logging-loader/index.js similarity index 100% rename from packages/rspack/tests/statsCases/logging-loader/index.js rename to packages/rspack-test-tools/tests/statsCases/logging-loader/index.js diff --git a/packages/rspack/tests/statsCases/logging-loader/test-loader.js b/packages/rspack-test-tools/tests/statsCases/logging-loader/test-loader.js similarity index 100% rename from packages/rspack/tests/statsCases/logging-loader/test-loader.js rename to packages/rspack-test-tools/tests/statsCases/logging-loader/test-loader.js diff --git a/packages/rspack/tests/statsCases/logging-loader/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/logging-loader/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/logging-loader/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/logging-loader/webpack.config.js diff --git a/packages/rspack/tests/statsCases/minify-error/index.js b/packages/rspack-test-tools/tests/statsCases/minify-error/index.js similarity index 100% rename from packages/rspack/tests/statsCases/minify-error/index.js rename to packages/rspack-test-tools/tests/statsCases/minify-error/index.js diff --git a/packages/rspack/tests/statsCases/minify-error/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/minify-error/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/minify-error/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/minify-error/webpack.config.js diff --git a/packages/rspack/tests/statsCases/named-chunk-group/dynamic.js b/packages/rspack-test-tools/tests/statsCases/named-chunk-group/dynamic.js similarity index 100% rename from packages/rspack/tests/statsCases/named-chunk-group/dynamic.js rename to packages/rspack-test-tools/tests/statsCases/named-chunk-group/dynamic.js diff --git a/packages/rspack/tests/statsCases/named-chunk-group/index.js b/packages/rspack-test-tools/tests/statsCases/named-chunk-group/index.js similarity index 100% rename from packages/rspack/tests/statsCases/named-chunk-group/index.js rename to packages/rspack-test-tools/tests/statsCases/named-chunk-group/index.js diff --git a/packages/rspack/tests/statsCases/named-chunk-group/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/named-chunk-group/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/named-chunk-group/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/named-chunk-group/webpack.config.js diff --git a/packages/rspack/tests/statsCases/nonexistent-import-source-error/index.js b/packages/rspack-test-tools/tests/statsCases/nonexistent-import-source-error/index.js similarity index 100% rename from packages/rspack/tests/statsCases/nonexistent-import-source-error/index.js rename to packages/rspack-test-tools/tests/statsCases/nonexistent-import-source-error/index.js diff --git a/packages/rspack/tests/statsCases/nonexistent-import-source-error/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/nonexistent-import-source-error/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/nonexistent-import-source-error/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/nonexistent-import-source-error/webpack.config.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-multiple/e1.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-multiple/e1.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-multiple/e1.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-multiple/e1.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-multiple/e2.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-multiple/e2.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-multiple/e2.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-multiple/e2.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-multiple/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-multiple/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-multiple/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-multiple/webpack.config.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-single/e1.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-single/e1.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-single/e1.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-single/e1.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-single/e2.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-single/e2.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-single/e2.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-single/e2.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-single/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-single/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-single/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-single/webpack.config.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-true/e1.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-true/e1.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-true/e1.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-true/e1.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-true/e2.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-true/e2.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-true/e2.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-true/e2.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk-true/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-true/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk-true/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk-true/webpack.config.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk/e1.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk/e1.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk/e1.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk/e1.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk/e2.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk/e2.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk/e2.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk/e2.js diff --git a/packages/rspack/tests/statsCases/optimization-runtime-chunk/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/optimization-runtime-chunk/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/optimization-runtime-chunk/webpack.config.js diff --git a/packages/rspack/tests/statsCases/parse-error/a.js b/packages/rspack-test-tools/tests/statsCases/parse-error/a.js similarity index 100% rename from packages/rspack/tests/statsCases/parse-error/a.js rename to packages/rspack-test-tools/tests/statsCases/parse-error/a.js diff --git a/packages/rspack/tests/statsCases/parse-error/b.js b/packages/rspack-test-tools/tests/statsCases/parse-error/b.js similarity index 100% rename from packages/rspack/tests/statsCases/parse-error/b.js rename to packages/rspack-test-tools/tests/statsCases/parse-error/b.js diff --git a/packages/rspack/tests/statsCases/parse-error/index.js b/packages/rspack-test-tools/tests/statsCases/parse-error/index.js similarity index 100% rename from packages/rspack/tests/statsCases/parse-error/index.js rename to packages/rspack-test-tools/tests/statsCases/parse-error/index.js diff --git a/packages/rspack/tests/statsCases/parse-error/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/parse-error/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/parse-error/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/parse-error/webpack.config.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/a.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/a.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/a.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/a.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/a1.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/a1.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/a1.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/a1.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/a2.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/a2.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/a2.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/a2.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/b.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/b.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/b1.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b1.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/b1.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b1.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/b2.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b2.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/b2.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b2.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/b3.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b3.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/b3.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/b3.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/c.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/c.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/c.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/c.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/c1.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/c1.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/c1.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/c1.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/c2.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/c2.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/c2.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/c2.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/index.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/index.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/index.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/index.js diff --git a/packages/rspack/tests/statsCases/prefetch-preload-mixed/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/prefetch-preload-mixed/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/prefetch-preload-mixed/webpack.config.js diff --git a/packages/rspack/tests/statsCases/reasons/a.js b/packages/rspack-test-tools/tests/statsCases/reasons/a.js similarity index 100% rename from packages/rspack/tests/statsCases/reasons/a.js rename to packages/rspack-test-tools/tests/statsCases/reasons/a.js diff --git a/packages/rspack/tests/statsCases/reasons/index.js b/packages/rspack-test-tools/tests/statsCases/reasons/index.js similarity index 100% rename from packages/rspack/tests/statsCases/reasons/index.js rename to packages/rspack-test-tools/tests/statsCases/reasons/index.js diff --git a/packages/rspack/tests/statsCases/reasons/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/reasons/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/reasons/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/reasons/webpack.config.js diff --git a/packages/rspack/tests/statsCases/resolve-overflow-error/errors.js b/packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/errors.js similarity index 100% rename from packages/rspack/tests/statsCases/resolve-overflow-error/errors.js rename to packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/errors.js diff --git a/packages/rspack/tests/statsCases/resolve-overflow-error/index.js b/packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/index.js similarity index 100% rename from packages/rspack/tests/statsCases/resolve-overflow-error/index.js rename to packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/index.js diff --git a/packages/rspack/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/a.js b/packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/a.js similarity index 100% rename from packages/rspack/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/a.js rename to packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/a.js diff --git a/packages/rspack/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/b.js b/packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/b.js similarity index 100% rename from packages/rspack/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/b.js rename to packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/b.js diff --git a/packages/rspack/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/package.json b/packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/package.json similarity index 100% rename from packages/rspack/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/package.json rename to packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/node_modules/cycle-alias/package.json diff --git a/packages/rspack/tests/statsCases/resolve-overflow-error/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/resolve-overflow-error/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/resolve-overflow-error/webpack.config.js diff --git a/packages/rspack/tests/statsCases/resolve-unexpected-exports-in-pkg-error/errors.js b/packages/rspack-test-tools/tests/statsCases/resolve-unexpected-exports-in-pkg-error/errors.js similarity index 100% rename from packages/rspack/tests/statsCases/resolve-unexpected-exports-in-pkg-error/errors.js rename to packages/rspack-test-tools/tests/statsCases/resolve-unexpected-exports-in-pkg-error/errors.js diff --git a/packages/rspack/tests/statsCases/resolve-unexpected-exports-in-pkg-error/index.js b/packages/rspack-test-tools/tests/statsCases/resolve-unexpected-exports-in-pkg-error/index.js similarity index 100% rename from packages/rspack/tests/statsCases/resolve-unexpected-exports-in-pkg-error/index.js rename to packages/rspack-test-tools/tests/statsCases/resolve-unexpected-exports-in-pkg-error/index.js diff --git a/packages/rspack/tests/statsCases/resolve-unexpected-exports-in-pkg-error/node_modules/pkg-a/package.json b/packages/rspack-test-tools/tests/statsCases/resolve-unexpected-exports-in-pkg-error/node_modules/pkg-a/package.json similarity index 100% rename from packages/rspack/tests/statsCases/resolve-unexpected-exports-in-pkg-error/node_modules/pkg-a/package.json rename to packages/rspack-test-tools/tests/statsCases/resolve-unexpected-exports-in-pkg-error/node_modules/pkg-a/package.json diff --git a/packages/rspack/tests/statsCases/runtime-modules/index.js b/packages/rspack-test-tools/tests/statsCases/runtime-modules/index.js similarity index 100% rename from packages/rspack/tests/statsCases/runtime-modules/index.js rename to packages/rspack-test-tools/tests/statsCases/runtime-modules/index.js diff --git a/packages/rspack/tests/statsCases/runtime-modules/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/runtime-modules/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/runtime-modules/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/runtime-modules/webpack.config.js diff --git a/packages/rspack/tests/statsCases/runtime-specific-exports/example.js b/packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/example.js similarity index 100% rename from packages/rspack/tests/statsCases/runtime-specific-exports/example.js rename to packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/example.js diff --git a/packages/rspack/tests/statsCases/runtime-specific-exports/increment.js b/packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/increment.js similarity index 100% rename from packages/rspack/tests/statsCases/runtime-specific-exports/increment.js rename to packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/increment.js diff --git a/packages/rspack/tests/statsCases/runtime-specific-exports/math.js b/packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/math.js similarity index 100% rename from packages/rspack/tests/statsCases/runtime-specific-exports/math.js rename to packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/math.js diff --git a/packages/rspack/tests/statsCases/runtime-specific-exports/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/runtime-specific-exports/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/runtime-specific-exports/webpack.config.js diff --git a/packages/rspack/tests/statsCases/side-effects-bailouts/index.js b/packages/rspack-test-tools/tests/statsCases/side-effects-bailouts/index.js similarity index 100% rename from packages/rspack/tests/statsCases/side-effects-bailouts/index.js rename to packages/rspack-test-tools/tests/statsCases/side-effects-bailouts/index.js diff --git a/packages/rspack/tests/statsCases/side-effects-bailouts/lib.js b/packages/rspack-test-tools/tests/statsCases/side-effects-bailouts/lib.js similarity index 100% rename from packages/rspack/tests/statsCases/side-effects-bailouts/lib.js rename to packages/rspack-test-tools/tests/statsCases/side-effects-bailouts/lib.js diff --git a/packages/rspack/tests/statsCases/side-effects-bailouts/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/side-effects-bailouts/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/side-effects-bailouts/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/side-effects-bailouts/webpack.config.js diff --git a/packages/rspack/tests/statsCases/simple-export/index.js b/packages/rspack-test-tools/tests/statsCases/simple-export/index.js similarity index 100% rename from packages/rspack/tests/statsCases/simple-export/index.js rename to packages/rspack-test-tools/tests/statsCases/simple-export/index.js diff --git a/packages/rspack/tests/statsCases/simple-module-source/index.js b/packages/rspack-test-tools/tests/statsCases/simple-module-source/index.js similarity index 100% rename from packages/rspack/tests/statsCases/simple-module-source/index.js rename to packages/rspack-test-tools/tests/statsCases/simple-module-source/index.js diff --git a/packages/rspack/tests/statsCases/simple-module-source/raw.png b/packages/rspack-test-tools/tests/statsCases/simple-module-source/raw.png similarity index 100% rename from packages/rspack/tests/statsCases/simple-module-source/raw.png rename to packages/rspack-test-tools/tests/statsCases/simple-module-source/raw.png diff --git a/packages/rspack/tests/statsCases/simple-module-source/stringModule.js b/packages/rspack-test-tools/tests/statsCases/simple-module-source/stringModule.js similarity index 100% rename from packages/rspack/tests/statsCases/simple-module-source/stringModule.js rename to packages/rspack-test-tools/tests/statsCases/simple-module-source/stringModule.js diff --git a/packages/rspack/tests/statsCases/simple-module-source/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/simple-module-source/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/simple-module-source/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/simple-module-source/webpack.config.js diff --git a/packages/rspack/tests/statsCases/stats-hooks/index.js b/packages/rspack-test-tools/tests/statsCases/stats-hooks/index.js similarity index 100% rename from packages/rspack/tests/statsCases/stats-hooks/index.js rename to packages/rspack-test-tools/tests/statsCases/stats-hooks/index.js diff --git a/packages/rspack/tests/statsCases/stats-hooks/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/stats-hooks/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/stats-hooks/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/stats-hooks/webpack.config.js diff --git a/packages/rspack/tests/statsCases/try-require-module/index.js b/packages/rspack-test-tools/tests/statsCases/try-require-module/index.js similarity index 100% rename from packages/rspack/tests/statsCases/try-require-module/index.js rename to packages/rspack-test-tools/tests/statsCases/try-require-module/index.js diff --git a/packages/rspack/tests/statsCases/try-require-module/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/try-require-module/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/try-require-module/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/try-require-module/webpack.config.js diff --git a/packages/rspack/tests/statsCases/try-require-resolve-module/index.js b/packages/rspack-test-tools/tests/statsCases/try-require-resolve-module/index.js similarity index 100% rename from packages/rspack/tests/statsCases/try-require-resolve-module/index.js rename to packages/rspack-test-tools/tests/statsCases/try-require-resolve-module/index.js diff --git a/packages/rspack/tests/statsCases/try-require-resolve-module/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/try-require-resolve-module/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/try-require-resolve-module/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/try-require-resolve-module/webpack.config.js diff --git a/packages/rspack/tests/statsCases/try-require-resolve-weak-module/index.js b/packages/rspack-test-tools/tests/statsCases/try-require-resolve-weak-module/index.js similarity index 100% rename from packages/rspack/tests/statsCases/try-require-resolve-weak-module/index.js rename to packages/rspack-test-tools/tests/statsCases/try-require-resolve-weak-module/index.js diff --git a/packages/rspack/tests/statsCases/try-require-resolve-weak-module/webpack.config.js b/packages/rspack-test-tools/tests/statsCases/try-require-resolve-weak-module/webpack.config.js similarity index 100% rename from packages/rspack/tests/statsCases/try-require-resolve-weak-module/webpack.config.js rename to packages/rspack-test-tools/tests/statsCases/try-require-resolve-weak-module/webpack.config.js diff --git a/packages/rspack/tests/StatsTestCases.basictest.js b/packages/rspack/tests/StatsTestCases.basictest.js deleted file mode 100644 index d6451289222..00000000000 --- a/packages/rspack/tests/StatsTestCases.basictest.js +++ /dev/null @@ -1,209 +0,0 @@ -"use strict"; - -require("./helpers/warmup-webpack"); -const path = require("path"); -const fs = require("graceful-fs"); -const rimraf = require("rimraf"); -const captureStdio = require("./helpers/captureStdio"); -const webpack = require(".."); - -/** - * Escapes regular expression metacharacters - * @param {string} str String to quote - * @returns {string} Escaped string - */ -const quoteMeta = str => { - return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&"); -}; - -const base = path.join(__dirname, "statsCases"); -const outputBase = path.join(__dirname, "js", "stats"); -const tests = fs - .readdirSync(base) - .filter( - testName => - fs.existsSync(path.join(base, testName, "index.js")) || - fs.existsSync(path.join(base, testName, "webpack.config.js")) - ) - .filter(testName => { - const testDirectory = path.join(base, testName); - const filterPath = path.join(testDirectory, "test.filter.js"); - if (fs.existsSync(filterPath) && !require(filterPath)()) { - describe.skip(testName, () => it("filtered", () => {})); - return false; - } - return true; - }); - -describe("StatsTestCases", () => { - jest.setTimeout(30000); - let stderr; - beforeEach(() => { - stderr = captureStdio(process.stderr, true); - }); - afterEach(() => { - stderr.restore(); - }); - tests.forEach(testName => { - it("should print correct stats for " + testName, done => { - const outputDirectory = path.join(outputBase, testName); - rimraf.sync(outputDirectory); - fs.mkdirSync(outputDirectory, { recursive: true }); - let options = { - mode: "development", - entry: "./index", - output: { - filename: "bundle.js" - } - }; - if (fs.existsSync(path.join(base, testName, "webpack.config.js"))) { - options = require(path.join(base, testName, "webpack.config.js")); - } - let testConfig = {}; - try { - // try to load a test file - testConfig = Object.assign( - testConfig, - require(path.join(base, testName, "test.config.js")) - ); - } catch (e) { - // ignored - } - - (Array.isArray(options) ? options : [options]).forEach(options => { - if (!options.context) options.context = path.join(base, testName); - if (!options.output) options.output = options.output || {}; - if (!options.output.path) options.output.path = outputDirectory; - if (!options.plugins) options.plugins = []; - if (!options.optimization) options.optimization = {}; - if (options.optimization.minimize === undefined) - options.optimization.minimize = false; - }); - const c = webpack(options); - const compilers = c.compilers ? c.compilers : [c]; - compilers.forEach(c => { - const ifs = c.inputFileSystem; - c.inputFileSystem = Object.create(ifs); - c.inputFileSystem.readFile = function () { - const args = Array.prototype.slice.call(arguments); - const callback = args.pop(); - ifs.readFile.apply( - ifs, - args.concat([ - (err, result) => { - if (err) return callback(err); - if (!/\.(js|json|txt)$/.test(args[0])) - return callback(null, result); - callback(null, result.toString("utf-8").replace(/\r/g, "")); - } - ]) - ); - }; - - // CHANGE: The checkConstraints() function is currently not implemented in rspack - // c.hooks.compilation.tap("StatsTestCasesTest", compilation => { - // [ - // "optimize", - // "optimizeModules", - // "optimizeChunks", - // "afterOptimizeTree", - // "afterOptimizeAssets", - // "beforeHash" - // ].forEach(hook => { - // compilation.hooks[hook].tap("TestCasesTest", () => - // compilation.checkConstraints() - // ); - // }); - // }); - }); - c.run((err, stats) => { - if (err) return done(err); - for (const compilation of [] - .concat(stats.stats || stats) - .map(s => s.compilation)) { - compilation.logging.delete("webpack.Compilation.ModuleProfile"); - } - if (/error$/.test(testName)) { - expect(stats.hasErrors()).toBe(true); - } else if (stats.hasErrors()) { - return done( - new Error( - stats.toString({ - all: false, - errors: true, - errorStack: true, - errorDetails: true - }) - ) - ); - } else { - fs.writeFileSync( - path.join(outputBase, testName, "stats.txt"), - stats.toString({ - preset: "verbose", - context: path.join(base, testName), - colors: false - }), - "utf-8" - ); - } - let toStringOptions = { - context: path.join(base, testName), - colors: false - }; - let hasColorSetting = false; - if (typeof c.options.stats !== "undefined") { - toStringOptions = c.options.stats; - if (toStringOptions === null || typeof toStringOptions !== "object") - toStringOptions = { preset: toStringOptions }; - if (!toStringOptions.context) - toStringOptions.context = path.join(base, testName); - hasColorSetting = typeof toStringOptions.colors !== "undefined"; - } - if (Array.isArray(c.options) && !toStringOptions.children) { - toStringOptions.children = c.options.map(o => o.stats); - } - // mock timestamps - for (const { compilation: s } of [].concat(stats.stats || stats)) { - expect(s.startTime).toBeGreaterThan(0); - expect(s.endTime).toBeGreaterThan(0); - s.endTime = new Date("04/20/1970, 12:42:42 PM").getTime(); - s.startTime = s.endTime - 1234; - } - let actual = stats.toString(toStringOptions); - expect(typeof actual).toBe("string"); - if (!hasColorSetting) { - actual = stderr.toString() + actual; - actual = actual - .replace(/\u001b\[[0-9;]*m/g, "") - // CHANGE: The time unit display in Rspack is second - .replace(/[0-9]*\.[0-9]+(\s?s)/g, "X$1"); - } else { - actual = stderr.toStringRaw() + actual; - actual = actual - .replace(/\u001b\[1m\u001b\[([0-9;]*)m/g, "") - .replace(/\u001b\[1m/g, "") - .replace(/\u001b\[39m\u001b\[22m/g, "") - .replace(/\u001b\[([0-9;]*)m/g, "") - // CHANGE: The time unit display in Rspack is second - .replace(/[0-9]*\.[0-9]+(<\/CLR>)?(\s?s)/g, "X$1$2"); - } - // cspell:ignore Xdir - const testPath = path.join(base, testName); - actual = actual - .replace(/\r\n?/g, "\n") - // CHANGE: Remove potential line break and "|" caused by long text - .replace(/((ERROR|WARNING)([\s\S](?!╭|├))*?)(\n │ )/g, "$1") - // CHANGE: Update the regular expression to replace the 'Rspack' version string - .replace(/Rspack [^ )]+(\)?) compiled/g, "Rspack x.x.x$1 compiled") - .replace(new RegExp(quoteMeta(testPath), "g"), "Xdir/" + testName) - .replace(/(\w)\\(\w)/g, "$1/$2") - .replace(/, additional resolving: X ms/g, "") - .replace(/Unexpected identifier '.+?'/g, "Unexpected identifier"); - expect(actual).toMatchSnapshot(); - if (testConfig.validate) testConfig.validate(stats, stderr.toString()); - done(); - }); - }); - }); -});