Skip to content

Commit 1bb0db3

Browse files
authored
Merge pull request #13750 from webpack/ci/memory-problems
improve CI stablilty
2 parents 78e9a00 + 4e9bcd1 commit 1bb0db3

File tree

15 files changed

+73
-52
lines changed

15 files changed

+73
-52
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@
131131
],
132132
"scripts": {
133133
"setup": "node ./setup/setup.js",
134-
"test": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest",
134+
"test": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
135135
"test:update-snapshots": "yarn jest -u",
136-
"test:integration": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\"",
137-
"test:basic": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/te{st/TestCasesNormal,st/StatsTestCases,st/ConfigTestCases}.test.js\"",
136+
"test:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.test.js\"",
137+
"test:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/te{st/TestCasesNormal,st/StatsTestCases,st/ConfigTestCases}.test.js\"",
138138
"test:unit": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
139139
"travis:integration": "yarn cover:integration --ci $JEST",
140140
"travis:basic": "yarn cover:basic --ci $JEST",
@@ -165,9 +165,9 @@
165165
"benchmark": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
166166
"cover": "yarn cover:all && yarn cover:report",
167167
"cover:clean": "rimraf .nyc_output coverage",
168-
"cover:all": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --coverage",
169-
"cover:basic": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/te{st/TestCasesNormal,st/StatsTestCases,st/ConfigTestCases}.test.js\" --coverage",
170-
"cover:integration": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\" --coverage",
168+
"cover:all": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --coverage",
169+
"cover:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/te{st/TestCasesNormal,st/StatsTestCases,st/ConfigTestCases}.test.js\" --coverage",
170+
"cover:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.test.js\" --coverage",
171171
"cover:unit": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
172172
"cover:types": "node node_modules/tooling/type-coverage",
173173
"cover:merge": "nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",

test/ConfigTestCases.template.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ const describeCases = config => {
128128
}
129129
if (testConfig.timeout) setDefaultTimeout(testConfig.timeout);
130130
});
131+
afterAll(() => {
132+
// cleanup
133+
options = undefined;
134+
optionsArr = undefined;
135+
testConfig = undefined;
136+
});
131137
beforeAll(() => {
132138
rimraf.sync(cacheDirectory);
133139
});
@@ -306,6 +312,11 @@ const describeCases = config => {
306312
esmMode,
307313
parentModule
308314
) => {
315+
if (testConfig === undefined) {
316+
throw new Error(
317+
`_require(${module}) called after all tests have completed`
318+
);
319+
}
309320
if (Array.isArray(module) || /^\.\.?\//.test(module)) {
310321
let content;
311322
let p;

test/TestCases.template.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const deprecationTracking = require("./helpers/deprecationTracking");
1111
const captureStdio = require("./helpers/captureStdio");
1212
const asModule = require("./helpers/asModule");
1313

14-
const webpack = require("..");
15-
1614
const casesPath = path.join(__dirname, "cases");
1715
let categories = fs.readdirSync(casesPath);
1816
categories = categories.map(cat => {
@@ -79,7 +77,7 @@ const describeCases = config => {
7977
const terserForTesting = new TerserPlugin({
8078
parallel: false
8179
});
82-
const options = {
80+
let options = {
8381
context: casesPath,
8482
entry: "./" + category.name + "/" + testName + "/",
8583
target: config.target || "async-node",
@@ -191,6 +189,8 @@ const describeCases = config => {
191189
};
192190
const cleanups = [];
193191
afterAll(() => {
192+
options = undefined;
193+
testConfig = undefined;
194194
for (const fn of cleanups) fn();
195195
});
196196
beforeAll(done => {
@@ -206,6 +206,7 @@ const describeCases = config => {
206206
"cache1"
207207
);
208208
const deprecationTracker = deprecationTracking.start();
209+
const webpack = require("..");
209210
webpack(options, err => {
210211
deprecationTracker();
211212
options.output.path = oldPath;
@@ -224,6 +225,7 @@ const describeCases = config => {
224225
"cache2"
225226
);
226227
const deprecationTracker = deprecationTracking.start();
228+
const webpack = require("..");
227229
webpack(options, err => {
228230
deprecationTracker();
229231
options.output.path = oldPath;
@@ -237,6 +239,7 @@ const describeCases = config => {
237239
it(
238240
testName + " should compile",
239241
done => {
242+
const webpack = require("..");
240243
const compiler = webpack(options);
241244
const run = () => {
242245
const deprecationTracker = deprecationTracking.start();
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import("./module");
2-
3-
it("should run", () => {});
1+
it("should run", () => import("./module"));

test/configCases/async-commons-chunk/existing-name/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
const chunkLoadingSpy = jest.spyOn(__webpack_require__, "e");
22

3-
it("should not have duplicate chunks in blocks", function(done) {
3+
it("should not have duplicate chunks in blocks", function (done) {
4+
let i = 0;
5+
const d = () => {
6+
if (i++ >= 3) done();
7+
};
8+
49
// This split point should contain: a
510
require.ensure(
611
[],
7-
function(require) {
12+
function (require) {
813
expect(require("./a")).toBe("a");
14+
d();
915
},
1016
"a"
1117
);
@@ -14,9 +20,10 @@ it("should not have duplicate chunks in blocks", function(done) {
1420
// have it only contain b and make chunk a be an async dependency.
1521
require.ensure(
1622
[],
17-
function(require) {
23+
function (require) {
1824
expect(require("./a")).toBe("a");
1925
expect(require("./b")).toBe("b");
26+
d();
2027
},
2128
"a+b"
2229
);
@@ -25,10 +32,11 @@ it("should not have duplicate chunks in blocks", function(done) {
2532
// have it only contain c and make chunks a and a+b be async dependencies.
2633
require.ensure(
2734
[],
28-
function(require) {
35+
function (require) {
2936
expect(require("./a")).toBe("a");
3037
expect(require("./b")).toBe("b");
3138
expect(require("./c")).toBe("c");
39+
d();
3240
},
3341
"a+b+c"
3442
);
@@ -46,5 +54,5 @@ it("should not have duplicate chunks in blocks", function(done) {
4654
["a+b" /* == b */],
4755
["a+b+c" /* == c */]
4856
]);
49-
done();
57+
d();
5058
});
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import "./a";
2-
import(/* webpackChunkName: "async" */ "./async");
2+
it("should compile", () => import(/* webpackChunkName: "async" */ "./async"));
33
import "./b";
44
import "./c";
5-
6-
it("should compile", () => {});
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import "./c";
2-
import(/* webpackChunkName: "async" */ "./async");
2+
it("should compile", () => import(/* webpackChunkName: "async" */ "./async"));
33
import "./b";
44
import "./a";
5-
6-
it("should compile", () => {});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import("./test.js");
1+
it("should load", () => import("./test.js"));

test/configCases/parsing/requirejs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ it("should ignore require.config", function() {
99
it("should have a require.version", function() {
1010
expect(require.version).toBeTypeOf("string");
1111
});
12-
it("should have a requirejs.onError function", function() {
12+
it("should have a requirejs.onError function", function(done) {
1313
function f(){}
1414
expect(requirejs.onError).toBeTypeOf("undefined"); // has no default handler
1515
var org = requirejs.onError;
1616
requirejs.onError = f;
1717
expect(requirejs.onError).toBe(f);
1818
requirejs.onError = org;
19-
require(["./file.js"], function() {});
19+
require(["./file.js"], function() { done() });
2020
});

test/configCases/source-map/module-names/index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,27 @@ function getSourceMap(filename) {
55
return map;
66
}
77

8-
it("should include test.js in SourceMap", function() {
8+
it("should include test.js in SourceMap", function () {
99
var allSources = new Set();
1010
var map = getSourceMap("bundle0.js");
11-
for(var source of map.sources) allSources.add(source);
11+
for (var source of map.sources) allSources.add(source);
1212
map = getSourceMap("chunk-a.js");
13-
for(var source of map.sources) allSources.add(source);
13+
for (var source of map.sources) allSources.add(source);
1414
map = getSourceMap("chunk-b.js");
15-
for(var source of map.sources) allSources.add(source);
15+
for (var source of map.sources) allSources.add(source);
1616
expect(allSources).toContain("module");
1717
allSources.delete("module");
1818
expect(allSources).toContain("fallback");
19-
for(const source of allSources) {
19+
for (const source of allSources) {
2020
expect(source).toMatch(/^fallback\**$/);
2121
}
2222
});
2323

24-
require.ensure(["./test.js"], function(require) {}, "chunk-a");
25-
require.ensure(["./test.js", "./test.js?1"], function(require) {}, "chunk-b");
24+
if (Math.random() < 0) {
25+
require.ensure(["./test.js"], function (require) {}, "chunk-a");
26+
require.ensure(
27+
["./test.js", "./test.js?1"],
28+
function (require) {},
29+
"chunk-b"
30+
);
31+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
it("should run", function () {
2-
Promise.all([
3-
import(/* webpackChunkName: "a" */ "./a"),
4-
import(/* webpackChunkName: "b" */ "./b")
5-
]);
6-
72
const files = require("fs").readdirSync(__dirname);
83
expect(files).toContain("a.bundle.js");
94
expect(files).toContain("b-b_js-c441f481.bundle.js");
5+
6+
return Promise.all([
7+
import(/* webpackChunkName: "a" */ "./a"),
8+
import(/* webpackChunkName: "b" */ "./b")
9+
]);
1010
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
it("should run", function () {
2-
Promise.all([
3-
import(/* webpackChunkName: "a" */ "./a"),
4-
import(/* webpackChunkName: "b" */ "./b")
5-
]);
6-
72
const files = require("fs").readdirSync(__dirname);
83
expect(files).toContain("a.bundle.js");
94
expect(files).toContain("b---b_js---c441f481.bundle.js");
5+
6+
return Promise.all([
7+
import(/* webpackChunkName: "a" */ "./a"),
8+
import(/* webpackChunkName: "b" */ "./b")
9+
]);
1010
});
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
it("should compile and evaluate fine", () => {});
2-
3-
import("./a");
4-
import("./b");
1+
it("should compile and evaluate fine", () =>
2+
Promise.all([import("./a"), import("./b")]));
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
it("should handle mixed size types chunk in splitChunks", async () => {
2-
import("./chunk1");
3-
import("./chunk2");
4-
});
1+
it("should handle mixed size types chunk in splitChunks", () =>
2+
Promise.all([import("./chunk1"), import("./chunk2")]));

test/configCases/split-chunks/runtime-chunk-async-node/webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ module.exports = {
99
},
1010
target: "async-node",
1111
output: {
12-
filename: "[name].js"
12+
filename: "[name].js",
13+
library: {
14+
type: "commonjs-module"
15+
}
1316
},
1417
optimization: {
1518
chunkIds: "named",

0 commit comments

Comments
 (0)