Skip to content

Commit 30d3a6d

Browse files
committed
Enable running the `gulp xfatest* command on the bots
Depends on mozilla/pdf.js#13846
1 parent a80522e commit 30d3a6d

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

on_cmd_xfatest.js

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
var botio = require(process.env['BOTIO_MODULE']);
2+
require('shelljs/global');
3+
4+
var fail = false;
5+
6+
exec('npm install', {async:true}, function() {
7+
exec('git submodule init', {async:false});
8+
exec('git submodule update', {async:false});
9+
10+
silent(true);
11+
12+
(function runTesting() {
13+
//
14+
// Get PDFs from local cache
15+
//
16+
echo();
17+
echo('>> Deploying cached PDF files');
18+
cp(__dirname+'/pdf-cache/*', './test/pdfs');
19+
20+
//
21+
// Get ref snapshots
22+
//
23+
echo();
24+
echo('>> Getting ref snapshots');
25+
mkdir('-p', './test/ref');
26+
cp('-Rf', __dirname+'/refs/*', './test/ref');
27+
28+
//
29+
// Deploy custom files
30+
//
31+
echo();
32+
echo('>> Deploying custom files');
33+
cp('-f', __dirname+'/test-files/browser_manifest.json', './test/resources/browser_manifests');
34+
35+
//
36+
// Run tests
37+
//
38+
echo();
39+
echo('>> Running tests');
40+
41+
// Using {async} to avoid unnecessary CPU usage
42+
exec('gulp botxfatest', {silent:false, async:true}, function(error, output) {
43+
var integrationSuccessMatch = output.match(/All integration tests passed/g);
44+
var unitSuccessMatch = output.match(/All unit tests passed/g);
45+
var fontSuccessMatch = output.match(/All font tests passed/g);
46+
var regSuccessMatch = output.match(/All regression tests passed/g);
47+
48+
if (fontSuccessMatch) {
49+
botio.message('+ **Font tests:** Passed');
50+
} else {
51+
botio.message('+ **Font tests:** FAILED');
52+
fail = true; // non-fatal, continue
53+
}
54+
if (unitSuccessMatch) {
55+
botio.message('+ **Unit tests:** Passed');
56+
} else {
57+
botio.message('+ **Unit tests:** FAILED');
58+
fail = true; // non-fatal, continue
59+
}
60+
if (integrationSuccessMatch) {
61+
botio.message('+ **Integration Tests:** Passed');
62+
} else {
63+
botio.message('+ **Integration Tests:** FAILED');
64+
fail = true; // non-fatal, continue
65+
}
66+
if (regSuccessMatch) {
67+
botio.message('+ **Regression tests:** Passed');
68+
} else {
69+
botio.message('+ **Regression tests:** FAILED');
70+
fail = true; // non-fatal, continue
71+
72+
// Include a detailed summary of the ref-test failures.
73+
if (output.match(/OHNOES! Some tests failed!/g)) {
74+
const details = [];
75+
76+
const numErrors = output.match(/ errors: \d+/g);
77+
if (numErrors) {
78+
details.push(numErrors[0]);
79+
}
80+
const numEqFailures = output.match(/ different ref\/snapshot: \d+/g);
81+
if (numEqFailures) {
82+
details.push(numEqFailures[0]);
83+
}
84+
const numFBFFailures = output.match(/ different first\/second rendering: \d+/g);
85+
if (numFBFFailures) {
86+
details.push(numFBFFailures[0]);
87+
}
88+
89+
if (details.length > 0) {
90+
botio.message();
91+
botio.message("```");
92+
for (const line of details) {
93+
botio.message(line);
94+
}
95+
botio.message("```");
96+
}
97+
}
98+
99+
//
100+
// Copy reftest analyzer files
101+
//
102+
echo();
103+
echo('>> Copying reftest analyzer files');
104+
mv('-f', './test/eq.log', botio.public_dir);
105+
mv('-f', './test/resources/reftest-analyzer.html', botio.public_dir);
106+
mv('-f', './test/resources/reftest-analyzer.css', botio.public_dir);
107+
mv('-f', './test/resources/reftest-analyzer.js', botio.public_dir);
108+
mv('-f', './test/test_snapshots', botio.public_dir + '/');
109+
110+
botio.message();
111+
botio.message('Image differences available at: '+botio.public_url+'/reftest-analyzer.html#web=eq.log');
112+
}
113+
114+
//
115+
// Update local cache of PDF files
116+
//
117+
echo();
118+
echo('>> Updating local PDF cache')
119+
mkdir('-p', __dirname+'/pdf-cache');
120+
cp('./test/pdfs/*.pdf', __dirname+'/pdf-cache');
121+
122+
if (fail)
123+
exit(1);
124+
}); // exec test
125+
})(); // runTesting
126+
127+
}); // npm install

0 commit comments

Comments
 (0)