add deprecation testing for config test cases

This commit is contained in:
Tobias Koppers 2019-12-17 17:18:52 +01:00
parent 085f3d7f89
commit 63afbf9bf1
12 changed files with 118 additions and 0 deletions

View File

@ -2,6 +2,7 @@
test/*.*
!test/*.js
!test/**/webpack.config.js
!test/**/deprecations.js
# Ignore example fixtures
examples/*.*

View File

@ -7,6 +7,7 @@ const mkdirp = require("mkdirp");
const rimraf = require("rimraf");
const checkArrayExpectation = require("./checkArrayExpectation");
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
const deprecationTracking = require("./helpers/deprecationTracking");
const FakeDocument = require("./helpers/FakeDocument");
const webpack = require("..");
@ -107,6 +108,7 @@ describe("ConfigTestCases", () => {
}
if (testConfig.timeout) setDefaultTimeout(testConfig.timeout);
const deprecationTracker = deprecationTracking.start();
webpack(options, (err, stats) => {
if (err) {
const fakeStats = {
@ -168,6 +170,17 @@ describe("ConfigTestCases", () => {
)
)
return;
const deprecations = deprecationTracker();
if (
checkArrayExpectation(
testDirectory,
{ deprecations },
"deprecation",
"Deprecation",
done
)
)
return;
const globalContext = {
console: console,

View File

@ -0,0 +1 @@
module.exports = [{ code: /DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_MANIFEST/ }];

View File

@ -0,0 +1,10 @@
module.exports = [
{
code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/,
message: /Using a string as loader options is deprecated \(ruleSet\[1\]\.rules\[2\]\.options\)/
},
{
code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/,
message: /Using a string as loader options is deprecated \(ruleSet\[1\]\.rules\[3\]\.use\[0\]\.options\)/
}
];

View File

@ -0,0 +1,14 @@
module.exports = [
{ code: /DEP_WEBPACK_CHUNK_GROUP_GET_MODULE_INDEX_2/ },
{ code: /DEP_WEBPACK_CHUNK_MODULES_ITERABLE/ },
{ code: /DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_MANIFEST/ },
{ code: /DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK/ },
{ code: /DEP_WEBPACK_MAIN_TEMPLATE_GET_ASSET_PATH/ },
{ code: /DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK/ },
{ code: /DEP_WEBPACK_MAIN_TEMPLATE_OUTPUT_OPTIONS/ },
{ code: /DEP_WEBPACK_MAIN_TEMPLATE_RENDER_CURRENT_HASH_CODE/ },
{ code: /DEP_WEBPACK_MAIN_TEMPLATE_RENDER_MANIFEST/ },
{ code: /DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE_FN/ },
{ code: /DEP_WEBPACK_MODULE_ID/ },
{ code: /DEP_WEBPACK_MODULE_UPDATE_HASH/ }
];

View File

@ -0,0 +1,3 @@
module.exports = [
{ code: /DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK/ }
];

View File

@ -0,0 +1,18 @@
module.exports = [
{
code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/,
message: /rules\[0\].use\[0\]/
},
{
code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/,
message: /rules\[0\].use\[1\]/
},
{
code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/,
message: /rules\[1\].use\[0\]/
},
{
code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/,
message: /rules\[1\].use\[1\]/
}
];

View File

@ -0,0 +1,5 @@
module.exports = [
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[0\]/ },
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[1\]/ },
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[2\]/ }
];

View File

@ -0,0 +1,5 @@
module.exports = [
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[0\]/ },
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[1\]/ },
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[2\]/ }
];

View File

@ -0,0 +1,5 @@
module.exports = [
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[0\]/ },
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[1\]/ },
{ code: /DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING/, message: /oneOf\[2\]/ }
];

View File

@ -0,0 +1,3 @@
module.exports = [
{ code: /DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK/ }
];

View File

@ -0,0 +1,40 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const util = require("util");
let interception = undefined;
const originalDeprecate = util.deprecate;
util.deprecate = (fn, message, code) => {
const original = originalDeprecate(fn, message, code);
return function(...args) {
if (interception) {
interception.set(`${code}: ${message}`, { code, message });
return fn.apply(this, args);
} else {
return original.apply(this, args);
}
};
};
exports.start = handler => {
interception = new Map();
return () => {
const map = interception;
interception = undefined;
return Array.from(map)
.sort(([a], [b]) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
})
.map(([key, data]) => data);
};
};