pdf.js/external/builder/test-fixtures.js
Jonas Jenwald 198ef044f8 Account for changes in eslint-plugin-import version 2.23.0
The simplest solution, as far as I can tell, to "fix" the new errors reported by the `no-unresolved` rules was to extend the existing whitelisting to cover the new cases. Given that the affected `imports` are only relevant in `gulp server`-mode, this should thus be completely fine.

Please find additional information at:
 - https://github.com/benmosher/eslint-plugin-import/releases/tag/v2.23.0
 - https://github.com/benmosher/eslint-plugin-import/blob/v2.23.0/CHANGELOG.md#2230---2021-05-13
2021-05-16 11:50:55 +02:00

63 lines
1.6 KiB
JavaScript

"use strict";
const builder = require("./builder.js");
const fs = require("fs");
const path = require("path");
let errors = 0;
const baseDir = path.join(__dirname, "fixtures");
const files = fs
.readdirSync(baseDir)
.filter(function (name) {
return /-expected\./.test(name);
})
.map(function (name) {
return path.join(baseDir, name);
});
files.forEach(function (expectationFilename) {
const inFilename = expectationFilename.replace("-expected", "");
const expectation = fs
.readFileSync(expectationFilename)
.toString()
.trim()
.replace(/__filename/g, fs.realpathSync(inFilename));
const outLines = [];
const outFilename = function (line) {
outLines.push(line);
};
const defines = {
TRUE: true,
FALSE: false,
};
let out;
try {
builder.preprocess(inFilename, outFilename, defines);
out = outLines.join("\n").trim();
} catch (e) {
out = ("Error: " + e.message).replace(/^/gm, "//");
}
if (out !== expectation) {
errors++;
console.log("Assertion failed for " + inFilename);
console.log("--------------------------------------------------");
console.log("EXPECTED:");
console.log(expectation);
console.log("--------------------------------------------------");
console.log("ACTUAL");
console.log(out);
console.log("--------------------------------------------------");
console.log();
}
});
if (errors) {
console.error("Found " + errors + " expectation failures.");
process.exit(1);
} else {
console.log("All tests completed without errors.");
process.exit(0);
}