Skip to content

Commit

Permalink
[WIP]: remove --backcompat option.
Browse files Browse the repository at this point in the history
- jsdom: run Bravura and other font to ensure backcompat filename.
  • Loading branch information
h-sug1no committed Dec 17, 2021
1 parent 43626c3 commit 422c97c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
32 changes: 2 additions & 30 deletions tools/generate_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const log = (msg = 'undefined', type) => {
process.stdout.write('\n');
};

const parseArgs = (compatMode) => {
const parseArgs = () => {
const argv = [...process.argv];

const argv0 = argv.shift();
Expand Down Expand Up @@ -48,9 +48,6 @@ const parseArgs = (compatMode) => {
}
});
break;
case '--backcompat':
compatMode.mode = compatMode.MODES.BackCompat;
break;
case '--parallel':
parallel = str;
break;
Expand All @@ -73,30 +70,7 @@ const parseArgs = (compatMode) => {
};

const appMain = async () => {
// Produce filenames that match version 3.0.9.
// Remove `.Bravura` from the filename.
const compatMode = {
mode: null,
MODES: {
BackCompat: 'BackCompat',
},
fixFileNames: (imageDir) => {
if (compatMode.mode !== compatMode.MODES.BackCompat) {
return;
}
// If we are only testing the Bravura font, do not include the font name in the file name.
// See tests/vexflow_test_helpers.ts / runNodeTestHelper() / onlyBravura mode.
fs.readdirSync(imageDir).forEach((filename) => {
const matches = filename.match(/(.+)([\._]Bravura\.)(png|svg|svg\.png)$/);
if (matches && matches[2]) {
const backCompatFileName = `${matches[1]}.${matches[3]}`;
fs.renameSync(path.join(imageDir, filename), path.join(imageDir, backCompatFileName));
process.stdout.write(`${imageDir}: ${filename} -> ${backCompatFileName}\n`);
}
});
},
};
const options = parseArgs(compatMode);
const options = parseArgs();
const { childArgs, backends } = options;
const { ver, imageDir, args } = childArgs;

Expand Down Expand Up @@ -154,8 +128,6 @@ const appMain = async () => {
if (error) {
process.exit(1);
}

compatMode.fixFileNames(imageDir);
};

appMain();
16 changes: 14 additions & 2 deletions tools/generate_png_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const appMain = () => {
};

const run = (font, id) => {
console.log(`run: ${font}`);
let child;
const { argv0, argv } = childArgs;
const childArgv = [...argv, `--fonts=${font}`];
Expand All @@ -114,9 +115,20 @@ const appMain = () => {

// TODO: limit the number of processes to specified number(jobs).
// console.log(jobs);
fontStacksToTest.forEach((font, idx) => {
children.push(run(font, idx));

// filename quirk : see tests/vexflow_test_helpers.ts:runNodeTestHelper().
const quirkFontName = 'Bravura';
const fontsToTest = fontStacksToTest.filter((font) => font !== quirkFontName);

let quirkFont = fontsToTest.length !== fontStacksToTest.length ? quirkFontName : undefined;
fontsToTest.forEach((font, idx) => {
// ensure that the quirk font is tested with the other font.
children.push(run(quirkFont ? [quirkFont, font].join(',') : font, idx));
quirkFont = undefined;
});
if (quirkFont) {
children.push(run(quirkFont, idx));
}

// FIXME: need timeout detection?
// setInterval(wait, 1000);
Expand Down

0 comments on commit 422c97c

Please sign in to comment.