Merge pull request #13775 from webpack/bugfix/azure

fix azure pipeline
This commit is contained in:
Tobias Koppers 2021-07-15 18:53:01 +02:00 committed by GitHub
commit a416c497a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 248 additions and 104 deletions

View File

@ -94,11 +94,14 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10.x, 16.x]
part: [a, b]
include:
- os: ubuntu-latest
node-version: 14.x
part: a
- os: ubuntu-latest
node-version: 12.x
part: a
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
@ -121,7 +124,7 @@ jobs:
path: .jest-cache
key: jest-integration-${{ env.GITHUB_SHA }}
restore-keys: jest-integration-
- run: yarn cover:integration --ci --cacheDirectory .jest-cache
- run: yarn cover:integration:${{ matrix.part }} --ci --cacheDirectory .jest-cache
- run: yarn cover:merge
- uses: codecov/codecov-action@v1
with:

View File

@ -39,7 +39,7 @@ jobs:
export JEST_JUNIT_OUTPUT_NAME=unit-junit.xml
yarn test:unit --ci --reporters=default --reporters=jest-junit
env:
CI: true
CI: "true"
displayName: "Run basic tests"
- task: PublishTestResults@2
inputs:
@ -93,7 +93,7 @@ jobs:
yarn pretty-lint
yarn spellcheck
env:
CI: true
CI: "true"
displayName: "Run linting"
- task: PublishTestResults@2
inputs:
@ -109,14 +109,26 @@ jobs:
pool:
vmImage: windows-latest
strategy:
maxParallel: 3
maxParallel: 6
matrix:
node-10:
node-10-a:
node_version: ^10.13.0
node-12:
part: a
node-10-b:
node_version: ^10.13.0
part: b
node-12-a:
node_version: ^12.4.0
node-16:
part: a
node-12-b:
node_version: ^12.4.0
part: b
node-16-a:
node_version: ^16.0.0
part: a
node-16-b:
node_version: ^16.0.0
part: b
steps:
- task: NodeTool@0
inputs:
@ -142,10 +154,10 @@ jobs:
- script: yarn link webpack --frozen-lockfile
displayName: "Link webpack into node_modules"
- script: |
yarn cover:integration --ci --maxWorkers=2 --reporters=default --reporters=jest-junit
yarn cover:integration:$(part) --ci --maxWorkers=2 --reporters=default --reporters=jest-junit
yarn cover:merge
env:
CI: true
CI: "true"
displayName: "Run tests with coverage"
- task: PublishTestResults@2
inputs:
@ -161,16 +173,26 @@ jobs:
pool:
vmImage: ubuntu-latest
strategy:
maxParallel: 4
maxParallel: 6
matrix:
node-10:
node-10-a:
node_version: ^10.13.0
node-12:
part: a
node-10-b:
node_version: ^10.13.0
part: b
node-12-a:
node_version: ^12.4.0
node-14:
part: a
node-14-a:
node_version: ^14.0.0
node-16:
part: a
node-16-a:
node_version: ^16.0.0
part: a
node-16-b:
node_version: ^16.0.0
part: b
steps:
- task: NodeTool@0
inputs:
@ -200,10 +222,10 @@ jobs:
- script: |
set -e
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn cover:integration --ci --maxWorkers=2 --reporters=default --reporters=jest-junit
yarn cover:integration:$(part) --ci --maxWorkers=2 --reporters=default --reporters=jest-junit
yarn cover:merge
env:
CI: true
CI: "true"
displayName: "Run tests with coverage"
- task: PublishTestResults@2
inputs:
@ -219,12 +241,20 @@ jobs:
pool:
vmImage: macOS-latest
strategy:
maxParallel: 2
maxParallel: 4
matrix:
node-12:
node-12-a:
node_version: ^12.4.0
node-16:
part: a
node-12-b:
node_version: ^12.4.0
part: b
node-16-a:
node_version: ^16.0.0
part: a
node-16-b:
node_version: ^16.0.0
part: b
steps:
- task: NodeTool@0
inputs:
@ -254,10 +284,10 @@ jobs:
- script: |
set -e
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn cover:integration --ci --reporters=default --reporters=jest-junit
yarn cover:integration:$(part) --ci --reporters=default --reporters=jest-junit
yarn cover:merge
env:
CI: true
CI: "true"
displayName: "Run tests with coverage"
- task: PublishTestResults@2
inputs:

View File

@ -313,12 +313,12 @@ module.exports = class MultiCompiler {
/**
* @template SetupResult
* @param {function(Compiler, number, Callback<Stats>, function(): boolean, function(): void, function(): void): SetupResult} setup setup a single compiler
* @param {function(Compiler, Callback<Stats>): void} run run/continue a single compiler
* @param {function(Compiler, SetupResult, Callback<Stats>): void} run run/continue a single compiler
* @param {Callback<MultiStats>} callback callback when all compilers are done, result includes Stats of all changed compilers
* @returns {SetupResult[]} result of setup
*/
_runGraph(setup, run, callback) {
/** @typedef {{ compiler: Compiler, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
/** @typedef {{ compiler: Compiler, setupResult: SetupResult, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
// State transitions for nodes:
// -> blocked (initial)
@ -335,6 +335,7 @@ module.exports = class MultiCompiler {
/** @type {Node[]} */
const nodes = this.compilers.map(compiler => ({
compiler,
setupResult: undefined,
result: undefined,
state: "blocked",
children: [],
@ -444,14 +445,14 @@ module.exports = class MultiCompiler {
const setupResults = [];
nodes.forEach((node, i) => {
setupResults.push(
setup(
(node.setupResult = setup(
node.compiler,
i,
nodeDone.bind(null, node),
() => node.state !== "starting" && node.state !== "running",
() => nodeChange(node),
() => nodeInvalid(node)
)
))
);
});
let processing = true;
@ -470,7 +471,7 @@ module.exports = class MultiCompiler {
) {
running++;
node.state = "starting";
run(node.compiler, nodeDone.bind(null, node));
run(node.compiler, node.setupResult, nodeDone.bind(null, node));
node.state = "running";
}
}
@ -522,8 +523,9 @@ module.exports = class MultiCompiler {
}
return watching;
},
(compiler, initial, callback) => {
if (!compiler.watching.running) compiler.watching.invalidate();
(compiler, watching, callback) => {
if (compiler.watching !== watching) return;
if (!watching.running) watching.invalidate();
},
handler
);
@ -546,7 +548,7 @@ module.exports = class MultiCompiler {
if (this.validateDependencies(callback)) {
this._runGraph(
() => {},
(compiler, callback) => compiler.run(callback),
(compiler, setupResult, callback) => compiler.run(callback),
(err, stats) => {
this.running = false;

View File

@ -135,8 +135,8 @@
"jest": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
"test": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
"test:update-snapshots": "yarn jest -u",
"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\"",
"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\"",
"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/*.{basictest,longtest,test}.js\"",
"test:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.basictest.js\"",
"test:unit": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
"travis:integration": "yarn cover:integration --ci $JEST",
"travis:basic": "yarn cover:basic --ci $JEST",
@ -168,11 +168,13 @@
"cover": "yarn cover:all && yarn cover:report",
"cover:clean": "rimraf .nyc_output coverage",
"cover:all": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --coverage",
"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",
"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",
"cover:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.basictest.js\" --coverage",
"cover:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" --coverage",
"cover:integration:a": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,test}.js\" --coverage",
"cover:integration:b": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.longtest.js\" --coverage",
"cover:unit": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
"cover:types": "node node_modules/tooling/type-coverage",
"cover:merge": "nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
"cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
"cover:report": "nyc report -t coverage"
},
"lint-staged": {
@ -193,6 +195,8 @@
],
"testMatch": [
"<rootDir>/test/*.test.js",
"<rootDir>/test/*.basictest.js",
"<rootDir>/test/*.longtest.js",
"<rootDir>/test/*.unittest.js"
],
"watchPathIgnorePatterns": [

View File

@ -9,11 +9,11 @@ const cacheDirectory = path.resolve(__dirname, "js/buildDepsCache");
const outputDirectory = path.resolve(__dirname, "js/buildDeps");
const inputDirectory = path.resolve(__dirname, "js/buildDepsInput");
const webpack = require("../");
const coverageEnabled = webpack.toString().includes("++");
const exec = (n, options = {}) => {
return new Promise((resolve, reject) => {
const webpack = require("../");
const coverageEnabled = webpack.toString().includes("++");
const p = child_process.execFile(
process.execPath,
[

View File

@ -1,12 +1,14 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const { createFsFromVolume, Volume } = require("memfs");
const webpack = require("..");
const fs = require("graceful-fs");
const rimraf = require("rimraf");
const createCompiler = config => {
const webpack = require("..");
const compiler = webpack(config);
compiler.outputFileSystem = createFsFromVolume(new Volume());
return compiler;

View File

@ -1,16 +1,18 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const rimraf = require("rimraf");
const webpack = require("..");
let fixtureCount = 0;
describe("Compiler (caching)", () => {
jest.setTimeout(15000);
function compile(entry, options, callback) {
const webpack = require("..");
options = webpack.config.getNormalizedWebpackOptions(options);
options.mode = "none";
options.cache = true;

View File

@ -1,8 +1,8 @@
"use strict";
const path = require("path");
require("./helpers/warmup-webpack");
const webpack = require("..");
const path = require("path");
const Stats = require("../lib/Stats");
const { createFsFromVolume, Volume } = require("memfs");
const captureStdio = require("./helpers/captureStdio");
@ -12,6 +12,7 @@ describe("Compiler", () => {
jest.setTimeout(20000);
function compile(entry, options, callback) {
const noOutputPath = !options.output || !options.output.path;
const webpack = require("..");
options = webpack.config.getNormalizedWebpackOptions(options);
if (!options.mode) options.mode = "production";
options.entry = entry;
@ -206,6 +207,7 @@ describe("Compiler", () => {
describe("methods", () => {
let compiler;
beforeEach(() => {
const webpack = require("..");
compiler = webpack({
entry: "./c",
context: path.join(__dirname, "fixtures"),
@ -285,6 +287,7 @@ describe("Compiler", () => {
});
});
it("should not emit on errors", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -306,6 +309,7 @@ describe("Compiler", () => {
try {
const createCompiler = options => {
return new Promise((resolve, reject) => {
const webpack = require("..");
const c = webpack(options);
c.run((err, stats) => {
if (err) {
@ -339,6 +343,7 @@ describe("Compiler", () => {
it("should not emit compilation errors in async (watch)", async () => {
const createStats = options => {
return new Promise((resolve, reject) => {
const webpack = require("..");
const c = webpack(options);
c.outputFileSystem = createFsFromVolume(new Volume());
const watching = c.watch({}, (err, stats) => {
@ -362,6 +367,7 @@ describe("Compiler", () => {
});
it("should not emit on errors (watch)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -381,6 +387,7 @@ describe("Compiler", () => {
});
});
it("should not be running twice at a time (run)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -399,6 +406,7 @@ describe("Compiler", () => {
});
});
it("should not be running twice at a time (watch)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -417,6 +425,7 @@ describe("Compiler", () => {
});
});
it("should not be running twice at a time (run - watch)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -435,6 +444,7 @@ describe("Compiler", () => {
});
});
it("should not be running twice at a time (watch - run)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -453,6 +463,7 @@ describe("Compiler", () => {
});
});
it("should not be running twice at a time (instance cb)", done => {
const webpack = require("..");
compiler = webpack(
{
context: __dirname,
@ -471,6 +482,7 @@ describe("Compiler", () => {
});
});
it("should run again correctly after first compilation", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -492,6 +504,7 @@ describe("Compiler", () => {
});
});
it("should watch again correctly after first compilation", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -512,6 +525,7 @@ describe("Compiler", () => {
});
});
it("should run again correctly after first closed watch", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -533,6 +547,7 @@ describe("Compiler", () => {
});
});
it("should set compiler.watching correctly", function (done) {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -550,6 +565,7 @@ describe("Compiler", () => {
expect(compiler.watching).toBe(watching);
});
it("should watch again correctly after first closed watch", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -571,6 +587,7 @@ describe("Compiler", () => {
});
});
it("should run again correctly inside afterDone hook", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -595,6 +612,7 @@ describe("Compiler", () => {
});
});
it("should call afterDone hook after other callbacks (run)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -620,6 +638,7 @@ describe("Compiler", () => {
});
it("should call afterDone hook after other callbacks (instance cb)", done => {
const instanceCb = jest.fn();
const webpack = require("..");
compiler = webpack(
{
context: __dirname,
@ -645,6 +664,7 @@ describe("Compiler", () => {
});
});
it("should call afterDone hook after other callbacks (watch)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -677,6 +697,7 @@ describe("Compiler", () => {
});
});
it("should call afterDone hook after other callbacks (watch close)", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -709,6 +730,7 @@ describe("Compiler", () => {
});
});
it("should flag watchMode as true in watch", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "production",
@ -731,6 +753,7 @@ describe("Compiler", () => {
});
});
it("should use cache on second run call", done => {
const webpack = require("..");
compiler = webpack({
context: __dirname,
mode: "development",
@ -754,6 +777,7 @@ describe("Compiler", () => {
});
it("should call the failed-hook on error", done => {
const failedSpy = jest.fn();
const webpack = require("..");
compiler = webpack({
bail: true,
context: __dirname,
@ -775,7 +799,8 @@ describe("Compiler", () => {
});
it("should deprecate when watch option is used without callback", () => {
const tracker = deprecationTracking.start();
webpack({
const webpack = require("..");
compiler = webpack({
watch: true
});
const deprecations = tracker();
@ -817,6 +842,7 @@ describe("Compiler", () => {
}
}
it("should log to the console (verbose)", done => {
const webpack = require("..");
compiler = webpack({
context: path.join(__dirname, "fixtures"),
entry: "./a",
@ -847,6 +873,7 @@ describe("Compiler", () => {
});
});
it("should log to the console (debug mode)", done => {
const webpack = require("..");
compiler = webpack({
context: path.join(__dirname, "fixtures"),
entry: "./a",
@ -879,6 +906,7 @@ describe("Compiler", () => {
});
});
it("should log to the console (none)", done => {
const webpack = require("..");
compiler = webpack({
context: path.join(__dirname, "fixtures"),
entry: "./a",
@ -898,6 +926,7 @@ describe("Compiler", () => {
});
});
it("should log to the console with colors (verbose)", done => {
const webpack = require("..");
compiler = webpack({
context: path.join(__dirname, "fixtures"),
entry: "./a",
@ -929,6 +958,7 @@ describe("Compiler", () => {
});
});
it("should log to the console with colors (debug mode)", done => {
const webpack = require("..");
compiler = webpack({
context: path.join(__dirname, "fixtures"),
entry: "./a",

View File

@ -1,5 +1,7 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const vm = require("vm");

View File

@ -1,8 +1,8 @@
require("./helpers/warmup-webpack");
const path = require("path");
const jestDiff = require("jest-diff").diff;
const stripAnsi = require("strip-ansi");
const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } =
require("..").config;
/**
* Escapes regular expression metacharacters
@ -63,6 +63,8 @@ describe("Defaults", () => {
});
const getDefaultConfig = config => {
const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } =
require("..").config;
config = getNormalizedWebpackOptions(config);
applyWebpackOptionsDefaults(config);
process.chdir(cwd);

View File

@ -1,5 +1,7 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const webpack = require("..");
@ -129,12 +131,6 @@ async function compile(options) {
return { errors, warnings };
}
it("should compile fine (warmup)", async () => {
await compile({
entry: "./entry-point"
});
}, 120000);
it("should emit warning for missingFile", async () => {
await expect(
compile({

View File

@ -1,9 +1,9 @@
"use strict";
/* describe it */
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const webpack = require("..");
describe("Examples", () => {
const basePath = path.join(__dirname, "..", "examples");
@ -39,6 +39,7 @@ describe("Examples", () => {
if (!options.entry) options.entry = "./example.js";
if (!options.plugins) options.plugins = [];
}
const webpack = require("..");
webpack(options, (err, stats) => {
if (err) return done(err);
if (stats.hasErrors()) {

View File

@ -1,5 +1,7 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const vm = require("vm");
@ -7,8 +9,6 @@ const rimraf = require("rimraf");
const checkArrayExpectation = require("./checkArrayExpectation");
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
const webpack = require("..");
const casesPath = path.join(__dirname, "hotCases");
let categories = fs
.readdirSync(casesPath)
@ -45,6 +45,7 @@ const describeCases = config => {
it(
testName + " should compile",
done => {
const webpack = require("..");
const outputDirectory = path.join(
__dirname,
"js",

View File

@ -1,5 +1,6 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const { createFsFromVolume, Volume } = require("memfs");
const webpack = require("..");
@ -29,6 +30,13 @@ const createMultiCompiler = options => {
return compiler;
};
const close = (watching, compiler, done) => {
watching.close(err => {
if (err) return done(err);
compiler.close(done);
});
};
describe("MultiCompiler", function () {
jest.setTimeout(20000);
@ -42,7 +50,7 @@ describe("MultiCompiler", function () {
throw err;
}
expect(called).toBe(2);
done();
compiler.close(done);
});
});
@ -51,13 +59,12 @@ describe("MultiCompiler", function () {
let called = 0;
compiler.hooks.watchRun.tap("MultiCompiler test", () => called++);
const watcher = compiler.watch(1000, err => {
const watching = compiler.watch(1000, err => {
if (err) {
throw err;
}
watcher.close();
expect(called).toBe(2);
done();
close(watching, compiler, done);
});
});
@ -67,16 +74,20 @@ describe("MultiCompiler", function () {
if (err) return done(err);
});
compiler.run((err, stats) => {
if (err) return done();
if (err) {
compiler.close(done);
}
});
});
it("should not be running twice at a time (watch)", done => {
const compiler = createMultiCompiler();
const watcher = compiler.watch({}, (err, stats) => {
const watching = compiler.watch({}, (err, stats) => {
if (err) return done(err);
});
compiler.watch({}, (err, stats) => {
if (err) return watcher.close(done);
if (err) {
close(watching, compiler, done);
}
});
});
it("should not be running twice at a time (run - watch)", done => {
@ -85,17 +96,21 @@ describe("MultiCompiler", function () {
if (err) return done(err);
});
compiler.watch({}, (err, stats) => {
if (err) return done();
if (err) {
compiler.close(done);
}
});
});
it("should not be running twice at a time (watch - run)", done => {
const compiler = createMultiCompiler();
let watcher;
watcher = compiler.watch({}, (err, stats) => {
let watching;
watching = compiler.watch({}, (err, stats) => {
if (err) return done(err);
});
compiler.run((err, stats) => {
if (err) return watcher.close(done);
if (err) {
close(watching, compiler, done);
}
});
});
it("should not be running twice at a time (instance cb)", done => {
@ -113,7 +128,9 @@ describe("MultiCompiler", function () {
);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
if (err) return done();
if (err) {
compiler.close(done);
}
});
});
it("should run again correctly after first compilation", done => {
@ -123,7 +140,7 @@ describe("MultiCompiler", function () {
compiler.run((err, stats) => {
if (err) return done(err);
done();
compiler.close(done);
});
});
});
@ -132,10 +149,10 @@ describe("MultiCompiler", function () {
compiler.run((err, stats) => {
if (err) return done(err);
let watcher;
watcher = compiler.watch({}, (err, stats) => {
let watching;
watching = compiler.watch({}, (err, stats) => {
if (err) return done(err);
watcher.close(done);
close(watching, compiler, done);
});
});
});
@ -147,7 +164,7 @@ describe("MultiCompiler", function () {
watching.close(() => {
compiler.run((err, stats) => {
if (err) return done(err);
done();
compiler.close(done);
});
});
});
@ -157,10 +174,9 @@ describe("MultiCompiler", function () {
if (err) return done(err);
});
watching.close(() => {
let watcher;
watcher = compiler.watch({}, (err, stats) => {
const watching2 = compiler.watch({}, (err, stats) => {
if (err) return done(err);
watcher.close(done);
close(watching2, compiler, done);
});
});
});
@ -197,7 +213,7 @@ describe("MultiCompiler", function () {
expect(events.join(" ")).toBe(
"a run a done b run b done d run d done e run e done c run c done"
);
done();
compiler.close(done);
});
});
it("should respect parallelism and dependencies for watching", done => {
@ -364,10 +380,7 @@ describe("MultiCompiler", function () {
]
`);
events.length = 0;
watching.close(err => {
if (err) return done(err);
compiler.close(done);
});
close(watching, compiler, done);
break;
default:
done(new Error("unexpected"));
@ -444,7 +457,9 @@ describe("MultiCompiler", function () {
`);
events.length = 0;
expect(state).toBe(1);
setTimeout(done, 1000);
setTimeout(() => {
close(watching, compiler, done);
}, 1000);
} catch (e) {
console.error(e);
done(e);
@ -521,7 +536,9 @@ describe("MultiCompiler", function () {
`);
events.length = 0;
expect(state).toBe(1);
setTimeout(done, 1000);
setTimeout(() => {
close(watching, compiler, done);
}, 1000);
} catch (e) {
console.error(e);
done(e);
@ -560,7 +577,10 @@ describe("MultiCompiler", function () {
entriesA.b = "./b.js";
entriesB.a = "./a.js";
watching.invalidate(done);
watching.invalidate(err => {
if (err) return done(err);
close(watching, compiler, done);
});
});
}, 2000);
@ -606,8 +626,9 @@ describe("MultiCompiler", function () {
}
}
};
compiler.watch({}, (err, stats) => {
done(err);
const watching = compiler.watch({}, (err, stats) => {
if (err) return done(err);
close(watching, compiler, done);
});
});
});

View File

@ -1,10 +1,12 @@
"use strict";
const webpack = require("..");
require("./helpers/warmup-webpack");
const { createFsFromVolume, Volume } = require("memfs");
describe("MultiStats", () => {
it("should create JSON of children stats", done => {
const webpack = require("..");
const compiler = webpack([
{
context: __dirname,

View File

@ -1,11 +1,13 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const webpack = require("..");
describe("NodeTemplatePlugin", () => {
jest.setTimeout(20000);
it("should compile and run a simple module", done => {
const webpack = require("..");
webpack(
{
mode: "production",
@ -42,6 +44,7 @@ describe("NodeTemplatePlugin", () => {
});
it("should compile and run a simple module in single mode", done => {
const webpack = require("..");
webpack(
{
mode: "production",

View File

@ -1,9 +1,10 @@
require("./helpers/warmup-webpack");
const path = require("path");
const util = require("util");
const fs = require("fs");
const rimraf = require("rimraf");
const vm = require("vm");
const webpack = require("../");
const readdir = util.promisify(fs.readdir);
const writeFile = util.promisify(fs.writeFile);
@ -52,6 +53,7 @@ describe("Persistent Caching", () => {
const compile = async (configAdditions = {}) => {
return new Promise((resolve, reject) => {
const webpack = require("../");
webpack(
{
...config,
@ -164,6 +166,7 @@ export default ${files.map((_, i) => `f${i}`).join(" + ")};
"lib2.js": "export default 21"
};
await updateSrc(data);
const webpack = require("../");
const configAdditions = {
plugins: [
new webpack.container.ModuleFederationPlugin({

View File

@ -1,14 +1,16 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const webpack = require("../");
const rimraf = require("rimraf");
describe("Profiling Plugin", function () {
jest.setTimeout(120000);
it("should handle output path with folder creation", done => {
const webpack = require("../");
const outputPath = path.join(__dirname, "js/profilingPath");
const finalPath = path.join(outputPath, "events.json");
rimraf(outputPath, () => {

View File

@ -38,12 +38,12 @@ To add a new case, create a new directory inside of the top level test groups, a
By default this file will be the entry point for the test suite and you can add your `it()`'s there. This will also become bundled so that node env support happens as well.
#### configCases (`ConfigTestCases.test.js`) <sup>1</sup>
#### configCases (`ConfigTestCases.basictest.js`) <sup>1</sup>
If you are trying to solve a bug which is reproducible when x and y properties are used together in a config, then configCases is the place to be!!!!
In addition to an `index.js`, these configCases require a `webpack.config.js` is located inside of your test suite. This will run this specific config through `webpack` just as you were building individually. They will use the same loading/bundling technique of your `it()` tests, however you now have a more specific config use cases that you can write even before you start coding.
#### statsCases (`StatsTestCases.test.js`)
#### statsCases (`StatsTestCases.basictest.js`)
Stats cases are similar to configCases except specifically focusing on the `expected` output of your stats. Instead of writing to the console, however the output of stats will be written to disk.
By default, the "expected" outcome is a pain to write by hand so instead when statsCases are run, runner is checking output using jest's awesome snapshot functionality.

View File

@ -1,10 +1,12 @@
"use strict";
const webpack = require("..");
require("./helpers/warmup-webpack");
const { createFsFromVolume, Volume } = require("memfs");
const compile = options => {
return new Promise((resolve, reject) => {
const webpack = require("..");
const compiler = webpack(options);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {

View File

@ -1,5 +1,6 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const rimraf = require("rimraf");
@ -35,6 +36,7 @@ const tests = fs
});
describe("StatsTestCases", () => {
jest.setTimeout(30000);
let stderr;
beforeEach(() => {
stderr = captureStdio(process.stderr, true);
@ -44,7 +46,6 @@ describe("StatsTestCases", () => {
});
tests.forEach(testName => {
it("should print correct stats for " + testName, done => {
jest.setTimeout(30000);
const outputDirectory = path.join(outputBase, testName);
rimraf.sync(outputDirectory);
fs.mkdirSync(outputDirectory, { recursive: true });

View File

@ -1,5 +1,6 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const vm = require("vm");

View File

@ -1,5 +1,4 @@
const { describeCases } = require("./TestCases.template");
const webpack = require("..");
describe("TestCases", () => {
describeCases({
@ -11,6 +10,11 @@ describe("TestCases", () => {
moduleIds: "named",
chunkIds: "named"
},
plugins: [new webpack.HotModuleReplacementPlugin()]
plugins: [
c => {
const webpack = require("..");
new webpack.HotModuleReplacementPlugin().apply(c);
}
]
});
});

View File

@ -1,11 +1,12 @@
"use strict";
const webpack = require("..");
require("./helpers/warmup-webpack");
describe("Validation", () => {
const createTestCase = (name, config, fn) => {
it("should fail validation for " + name, () => {
try {
const webpack = require("..");
webpack(config);
} catch (err) {
if (err.name !== "ValidationError") throw err;

View File

@ -1,8 +1,8 @@
"use strict";
const path = require("path");
require("./helpers/warmup-webpack");
const webpack = require("../");
const path = require("path");
describe("WatchClose", () => {
jest.setTimeout(5000);
@ -16,6 +16,7 @@ describe("WatchClose", () => {
let watcher;
beforeEach(() => {
const webpack = require("../");
compiler = webpack({
mode: "development",
entry: filePath,

View File

@ -1,10 +1,10 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("fs");
const webpack = require("../");
describe("WatchSuspend", () => {
if (process.env.NO_WATCH_TESTS) {
it.skip("long running tests excluded", () => {});
@ -41,6 +41,7 @@ describe("WatchSuspend", () => {
} catch (e) {
// skip
}
const webpack = require("../");
compiler = webpack({
mode: "development",
entry: filePath,

View File

@ -1,5 +1,7 @@
"use strict";
require("./helpers/warmup-webpack");
const path = require("path");
const fs = require("graceful-fs");
const vm = require("vm");
@ -11,8 +13,6 @@ const prepareOptions = require("./helpers/prepareOptions");
const deprecationTracking = require("./helpers/deprecationTracking");
const FakeDocument = require("./helpers/FakeDocument");
const webpack = require("..");
function copyDiff(src, dest, initial) {
if (!fs.existsSync(dest)) fs.mkdirSync(dest);
const files = fs.readdirSync(src);
@ -156,6 +156,7 @@ describe("WatchTestCases", () => {
setTimeout(() => {
const deprecationTracker = deprecationTracking.start();
const webpack = require("..");
const compiler = webpack(options);
compiler.hooks.invalid.tap(
"WatchTestCasesTest",

View File

@ -18,7 +18,7 @@ module.exports = (stdio, tty) => {
toString: () => {
return stripAnsi(logs.join("")).replace(
/\([^)]+\) (\[[^\]]+\]\s*)?DeprecationWarning.+(\n\(Use .node.+\))?(\n(\s|BREAKING CHANGE).*)*(\n\s+at .*)*\n?/g,
/\([^)]+\) (\[[^\]]+\]\s*)?(Deprecation|Experimental)Warning.+(\n\(Use .node.+\))?(\n(\s|BREAKING CHANGE).*)*(\n\s+at .*)*\n?/g,
""
);
},

View File

@ -0,0 +1,26 @@
describe("warmup", () => {
it("should warmup webpack", done => {
let webpack = require("../../");
let END = new Error("end warmup");
webpack(
{
entry: "data:text/javascript,import 'data:text/javascript,'",
plugins: [
c =>
c.hooks.emit.tap("Warmup", () => {
throw END;
})
]
},
err => {
webpack = undefined;
try {
expect(err).toBe(END);
done();
} catch (e) {
done(e);
}
}
);
}, 300000);
});

View File

@ -122,8 +122,8 @@ if (process.env.DEBUG_INFO) {
}
};
};
const env = jasmine.getEnv();
env.it = addDebugInfo(env.it);
// eslint-disable-next-line no-global-assign
it = addDebugInfo(it);
}
// Workaround for a memory leak in wabt