Skip to content

Commit

Permalink
Customize Vex.Flow.Test.FONTS_TO_TEST to test fewer fonts.
Browse files Browse the repository at this point in the history
By default we test Bravura, Petaluma, and Gonville.
  • Loading branch information
ronyeh committed Apr 24, 2021
1 parent 6f5c4fd commit 134338f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/vexflow_test_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ if (!global.QUnit) {

global['VF'] = Vex.Flow;
VF.Test = (function () {
var DEFAULT_FONTS_TO_TEST = [VF.Fonts.Bravura, VF.Fonts.Gonville, VF.Fonts.Petaluma];

var Test = {
// Test Options.
RUN_CANVAS_TESTS: true,
Expand All @@ -65,6 +67,9 @@ VF.Test = (function () {
// Default font properties for tests.
Font: { size: 10 },

// Test all three fonts by default. Customize the FONTS_TO_TEST array to test fewer fonts.
FONTS_TO_TEST: DEFAULT_FONTS_TO_TEST,

FONT_STACKS: {
Bravura: [VF.Fonts.Bravura, VF.Fonts.Gonville, VF.Fonts.Custom],
Gonville: [VF.Fonts.Gonville, VF.Fonts.Bravura, VF.Fonts.Custom],
Expand Down Expand Up @@ -203,9 +208,7 @@ VF.Test = (function () {
VF.DEFAULT_FONT_STACK = defaultFontStack;
};

QUnit.test(name, testFunc('Bravura'));
QUnit.test(name, testFunc('Gonville'));
QUnit.test(name, testFunc('Petaluma'));
VF.Test.runTestWithFonts(name, testFunc);
},

runNodeTest: function (name, func, params) {
Expand Down Expand Up @@ -248,9 +251,18 @@ VF.Test = (function () {
}
};

QUnit.test(name, testFunc('Bravura'));
QUnit.test(name, testFunc('Gonville'));
QUnit.test(name, testFunc('Petaluma'));
VF.Test.runTestWithFonts(name, testFunc);
},

// Run QUnit.test() for each font that is included in VF.Test.FONTS_TO_TEST.
runTestWithFonts: function (name, func) {
if (!Array.isArray(VF.Test.FONTS_TO_TEST)) {
VF.Test.FONTS_TO_TEST = DEFAULT_FONTS_TO_TEST;
}

VF.Test.FONTS_TO_TEST.forEach((font) => {
QUnit.test(name, func(font.getName()));
});
},

plotNoteWidth: VF.Note.plotMetrics,
Expand Down
7 changes: 7 additions & 0 deletions tools/generate_png_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ VF.Test.RUN_RAPHAEL_TESTS = false;
VF.Test.RUN_NODE_TESTS = true;
VF.Test.NODE_IMAGEDIR = imageDir;

// By default we test all fonts.
// Modify VF.Test.FONTS_TO_TEST to test fewer fonts at a time.
// In the future, we can allow customization via process.argv.
// VF.Test.FONTS_TO_TEST = [VF.Fonts.Petaluma];
// VF.Test.FONTS_TO_TEST = [VF.Fonts.Gonville];
// VF.Test.FONTS_TO_TEST = [VF.Fonts.Bravura];

// Create the image directory if it doesn't exist.
fs.mkdirSync(VF.Test.NODE_IMAGEDIR, { recursive: true });

Expand Down

0 comments on commit 134338f

Please sign in to comment.