2023-07-08 23:07:54 +09:00
|
|
|
import { fileURLToPath } from "url";
|
|
|
|
import fs from "fs";
|
|
|
|
import path from "path";
|
2024-01-23 02:33:31 +09:00
|
|
|
import { preprocessPDFJSCode } from "./babel-plugin-pdfjs-preprocessor.mjs";
|
2016-05-11 08:05:29 +09:00
|
|
|
|
2023-07-08 23:07:54 +09:00
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
2016-05-11 08:05:29 +09:00
|
|
|
|
2021-03-14 01:37:27 +09:00
|
|
|
let errors = 0;
|
2016-05-11 08:05:29 +09:00
|
|
|
|
2021-03-14 01:37:27 +09:00
|
|
|
const baseDir = path.join(__dirname, "fixtures_esprima");
|
|
|
|
const files = fs
|
2017-05-04 02:16:37 +09:00
|
|
|
.readdirSync(baseDir)
|
2020-04-14 19:28:14 +09:00
|
|
|
.filter(function (name) {
|
2017-05-04 02:16:37 +09:00
|
|
|
return /-expected\./.test(name);
|
|
|
|
})
|
2020-04-14 19:28:14 +09:00
|
|
|
.map(function (name) {
|
2017-05-04 02:16:37 +09:00
|
|
|
return path.join(baseDir, name);
|
|
|
|
});
|
2020-04-14 19:28:14 +09:00
|
|
|
files.forEach(function (expectationFilename) {
|
2021-03-14 01:37:27 +09:00
|
|
|
const inFilename = expectationFilename.replace("-expected", "");
|
|
|
|
const expectation = fs
|
2017-05-04 02:16:37 +09:00
|
|
|
.readFileSync(expectationFilename)
|
|
|
|
.toString()
|
|
|
|
.trim()
|
2023-03-22 23:31:10 +09:00
|
|
|
.replaceAll("__filename", fs.realpathSync(inFilename));
|
2021-03-14 01:37:27 +09:00
|
|
|
const input = fs.readFileSync(inFilename).toString();
|
2016-05-11 08:05:29 +09:00
|
|
|
|
2021-03-14 01:37:27 +09:00
|
|
|
const defines = {
|
2016-05-11 08:05:29 +09:00
|
|
|
TRUE: true,
|
|
|
|
FALSE: false,
|
Fix the remaining cases of inconsistent spacing and trailing commas in objects, and enable the `comma-dangle` and `object-curly-spacing` ESLint rules
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/gulpfile.js b/gulpfile.js
index d18b9c58..7d47fd8d 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1247,7 +1247,8 @@ gulp.task('gh-pages-git', ['gh-pages-prepare', 'wintersmith'], function () {
var reason = process.env['PDFJS_UPDATE_REASON'];
safeSpawnSync('git', ['init'], { cwd: GH_PAGES_DIR, });
- safeSpawnSync('git', ['remote', 'add', 'origin', REPO], { cwd: GH_PAGES_DIR, });
+ safeSpawnSync('git', ['remote', 'add', 'origin', REPO],
+ { cwd: GH_PAGES_DIR, });
safeSpawnSync('git', ['add', '-A'], { cwd: GH_PAGES_DIR, });
safeSpawnSync('git', [
'commit', '-am', 'gh-pages site created via gulpfile.js script',
```
2017-06-03 00:13:35 +09:00
|
|
|
OBJ: { obj: { i: 1 }, j: 2 },
|
|
|
|
TEXT: "text",
|
2016-05-11 08:05:29 +09:00
|
|
|
};
|
2021-03-14 01:37:27 +09:00
|
|
|
const map = {
|
2017-05-31 10:38:22 +09:00
|
|
|
"import-alias": "import-name",
|
|
|
|
};
|
2021-03-14 01:37:27 +09:00
|
|
|
const ctx = {
|
2021-01-23 01:38:26 +09:00
|
|
|
defines,
|
|
|
|
map,
|
2016-05-11 08:05:29 +09:00
|
|
|
rootPath: __dirname + "/../..",
|
|
|
|
};
|
2021-03-14 01:37:27 +09:00
|
|
|
let out;
|
2016-05-11 08:05:29 +09:00
|
|
|
try {
|
2023-07-08 23:07:54 +09:00
|
|
|
out = preprocessPDFJSCode(ctx, input);
|
2016-05-11 08:05:29 +09:00
|
|
|
} catch (e) {
|
2023-03-23 20:34:08 +09:00
|
|
|
out = ("Error: " + e.message).replaceAll(/^/gm, "//");
|
2016-05-11 08:05:29 +09:00
|
|
|
}
|
|
|
|
if (out !== expectation) {
|
2017-01-10 22:32:40 +09:00
|
|
|
errors++;
|
|
|
|
|
2024-01-23 02:33:31 +09:00
|
|
|
// Allow regenerating the expected output using
|
|
|
|
// OVERWRITE=true node ./external/builder/test-fixtures_esprima.mjs
|
|
|
|
if (process.env.OVERWRITE) {
|
|
|
|
fs.writeFileSync(expectationFilename, out + "\n");
|
|
|
|
}
|
|
|
|
|
2017-05-04 02:16:37 +09:00
|
|
|
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();
|
2016-05-11 08:05:29 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (errors) {
|
2017-05-04 02:16:37 +09:00
|
|
|
console.error("Found " + errors + " expectation failures.");
|
|
|
|
process.exit(1);
|
2016-05-11 08:05:29 +09:00
|
|
|
} else {
|
2017-05-04 02:16:37 +09:00
|
|
|
console.log("All tests completed without errors.");
|
|
|
|
process.exit(0);
|
2016-05-11 08:05:29 +09:00
|
|
|
}
|