forked from mozilla/botio-files-pdfjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
on_cmd_test.js
84 lines (72 loc) · 2.19 KB
/
on_cmd_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var botio = require(process.env['BOTIO_MODULE']);
require('shelljs/global');
var fail = false;
silent(true);
(function runTesting() {
//
// Get PDFs from local cache
//
echo();
echo('>> Deploying cached PDF files');
cp(__dirname+'/pdf-cache/*', './test/pdfs');
//
// Get ref snapshots
//
echo();
echo('>> Getting ref snapshots');
mkdir('-p', './test/ref');
cp('-Rf', __dirname+'/refs/*', './test/ref');
//
// Deploy custom files
//
echo();
echo('>> Deploying custom files');
cp('-f', __dirname+'/test-files/browser_manifest.json', './test/resources/browser_manifests');
//
// Run tests
//
echo();
echo('>> Running tests');
// Using {async} to avoid unnecessary CPU usage
exec('node make bottest', {silent:false, async:true}, function(error, output) {
var unitSuccessMatch = output.match(/All unit tests passed/g);
var fontSuccessMatch = output.match(/All font tests passed/g);
var regSuccessMatch = output.match(/All regression tests passed/g);
if (fontSuccessMatch) {
botio.message('+ **Font tests:** Passed');
} else {
botio.message('+ **Font tests:** FAILED');
fail = true; // non-fatal, continue
}
if (unitSuccessMatch) {
botio.message('+ **Unit tests:** Passed');
} else {
botio.message('+ **Unit tests:** FAILED');
fail = true; // non-fatal, continue
}
if (regSuccessMatch) {
botio.message('+ **Regression tests:** Passed');
} else {
botio.message('+ **Regression tests:** FAILED');
fail = true; // non-fatal, continue
//
// Copy reftest analyzer files
//
echo();
echo('>> Copying reftest analyzer files');
mv('-f', './test/eq.log', botio.public_dir);
mv('-f', './test/resources/reftest-analyzer.xhtml', botio.public_dir);
botio.message();
botio.message('Image differences available at: '+botio.public_url+'/reftest-analyzer.xhtml#web=eq.log');
}
//
// Update local cache of PDF files
//
echo();
echo('>> Updating local PDF cache')
mkdir('-p', __dirname+'/pdf-cache');
cp('./test/pdfs/*.pdf', __dirname+'/pdf-cache');
if (fail)
exit(1);
}); // exec test
})(); // runTesting