8000 add image test for mathjax v3 · lzhice/plotly.js@3a12c15 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a12c15

Browse files
committed
add image test for mathjax v3
1 parent f3f9424 commit 3a12c15

12 files changed

+130
-25
lines changed

.circleci/config.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,24 @@ jobs:
216216
name: Test MathJax on firefox-latest
217217
command: .circleci/test.sh mathjax-firefox82+
218218

219+
make-baselines-mathjax3:
220+
docker:
221+
- image: circleci/python:3.8.9
222+
working_directory: ~/plotly.js
223+
steps:
224+
- attach_workspace:
225+
at: ~/
226+
- run:
227+
name: Install kaleido, plotly.io and required fonts
228+
command: .circleci/env_image.sh
229+
- run:
230+
name: Create mathjax v3 png files
231+
command: .circleci/test.sh make-baselines-mathjax3
232+
- persist_to_workspace:
233+
root: ~/
234+
paths:
235+
- plotly.js
236+
219237
make-baselines:
220238
parallelism: 4
221239
docker:
@@ -249,6 +267,20 @@ jobs:
249267
path: build
250268
destination: /
251269

270+
test-baselines-mathjax3:
271+
docker:
272+
- image: circleci/node:16.8.0
273+
working_directory: ~/plotly.js
274+
steps:
275+
- attach_workspace:
276+
at: ~/
277+
- run:
278+
name: Compare pixels of mathjax v3 baselines
279+
command: .circleci/test.sh test-image-mathjax3
280+
- store_artifacts:
281+
path: build
282+
destination: /
283+
252284
make-exports:
253285
docker:
254286
- image: circleci/python:3.8.9
@@ -413,6 +445,12 @@ workflows:
413445
- flaky-no-gl-jasmine:
414446
requires:
415447
- install-and-cibuild
448+
- make-baselines-mathjax3:
449+
requires:
450+
- install-and-cibuild
451+
- test-baselines-mathjax3:
452+
requires:
453+
- make-baselines-mathjax3
416454
- make-baselines:
417455
requires:
418456
- install-and-cibuild

.circleci/test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ case $1 in
8080
exit $EXIT_STATE
8181
;;
8282

83+
make-baselines-mathjax3)
84+
python3 test/image/make_baseline.py mathjax3 legend_mathjax_title_and_items mathjax parcats_grid_subplots table_latex_multitrace_scatter table_plain_birds table_wrapped_birds ternary-mathjax || EXIT_STATE=$?
85+
exit $EXIT_STATE
86+
;;
87+
8388
make-baselines)
8489
SUITE=$(find $ROOT/test/image/mocks/ -type f -printf "%f\n" | sed 's/\.json$//1' | circleci tests split)
8590
python3 test/image/make_baseline.py $SUITE || EXIT_STATE=$?
@@ -91,6 +96,11 @@ case $1 in
9196
exit $EXIT_STATE
9297
;;
9398

99+
test-image-mathjax3)
100+
node test/image/compare_pixels_test.js mathjax3 || { tar -cvf build/baselines.tar build/test_images/*.png ; exit 1 ; } || EXIT_STATE=$?
101+
exit $EXIT_STATE
102+
;;
103+
94104
source-syntax)
95105
npm run lint || EXIT_STATE=$?
96106
npm run test-syntax || EXIT_STATE=$?
Loading
49 KB
Loading
Loading
Loading
Loading
Loading
Loading

test/image/compare_pixels_test.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,33 @@ if(argv._.length === 0) {
4141

4242
// Build list of mocks to compare
4343
var allMockList = [];
44+
var mathjax3;
4445
argv._.forEach(function(pattern) {
45-
var mockList = getMockList(pattern);
46+
if(pattern === 'mathjax3') {
47+
mathjax3 = true;
48+
} else {
49+
var mockList = getMockList(pattern);
4650

47-
if(mockList.length === 0) {
48-
throw 'No mocks found with pattern ' + pattern;
49-
}
51+
if(mockList.length === 0) {
52+
throw 'No mocks found with pattern ' + pattern;
53+
}
5054

51-
allMockList = allMockList.concat(mockList);
55+
allMockList = allMockList.concat(mockList);
56+
}
5257
});
5358

59+
if(mathjax3) {
60+
allMockList = [
61+
'legend_mathjax_title_and_items',
62+
'mathjax',
63+
'parcats_grid_subplots',
64+
'table_latex_multitrace_scatter',
65+
'table_plain_birds',
66+
'table_wrapped_birds',
67+
'ternary-mathjax'
68+
];
69+
}
70+
5471
// To get rid of duplicates
5572
function unique(value, index, self) {
5673
return self.indexOf(value) === index;
@@ -75,11 +92,19 @@ for(var i = 0; i < allMockList.length; i++) {
7592
continue;
7693
}
7794

95+
var isMapbox = mockName.substr(0, 7) === 'mapbox_';
96+
var isOtherFlaky = [
97+
// list flaky mocks other than mapbox:
98+
'gl3d_bunny-hull'
99+
].indexOf(mockName) !== -1;
100+
101+
if(mathjax3) mockName = 'mathjax3___' + mockName;
102+
78103
var imagePaths = getImagePaths(mockName);
79104
var base = imagePaths.baseline;
80105
var test = imagePaths.test;
81106

82-
if(!common.doesFileExist(test)) {
107+
if(!common.doesFileExist(test) && !mathjax3) {
83108
console.log('- skip:', mockName);
84109
skipped.push(mockName);
85110
continue;
@@ -114,12 +139,6 @@ for(var i = 0; i < allMockList.length; i++) {
114139
height: height
115140
});
116141

117-
var isMapbox = mockName.substr(0, 7) === 'mapbox_';
118-
var isOtherFlaky = [
119-
// list flaky mocks other than mapbox:
120-
'gl3d_bunny-hull'
121-
].indexOf(mockName) !== -1;
122-
123142
var shouldBePixelPerfect = !(isMapbox || isOtherFlaky);
124143

125144
var numDiffPixels = pixelmatch(img0.data, img1.data, diff.data, width, height, {

0 commit comments

Comments
 (0)
0