|
| 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 | + // Regression tests |
| 37 | + // |
| 38 | + echo(); |
| 39 | + echo('>> Regression tests'); |
| 40 | + |
| 41 | + // Using {async} to avoid unnecessary CPU usage |
| 42 | + exec('gulp botbrowsertest', {silent:false, async:true}, function(error, output) { |
| 43 | + var regSuccessMatch = output.match(/All regression tests passed/g); |
| 44 | + |
| 45 | + if (regSuccessMatch) { |
| 46 | + botio.message('+ **Regression tests:** Passed'); |
| 47 | + } else { |
| 48 | + botio.message('+ **Regression tests:** FAILED'); |
| 49 | + fail = true; // non-fatal, continue |
| 50 | + |
| 51 | + // Include a detailed summary of the ref-test failures. |
| 52 | + if (output.match(/OHNOES! Some tests failed!/g)) { |
| 53 | + const details = []; |
| 54 | + |
| 55 | + const numErrors = output.match(/ errors: \d+/g); |
| 56 | + if (numErrors) { |
| 57 | + details.push(numErrors[0]); |
| 58 | + } |
| 59 | + const numEqFailures = output.match(/ different ref\/snapshot: \d+/g); |
| 60 | + if (numEqFailures) { |
| 61 | + details.push(numEqFailures[0]); |
| 62 | + } |
| 63 | + const numFBFFailures = output.match(/ different first\/second rendering: \d+/g); |
| 64 | + if (numFBFFailures) { |
| 65 | + details.push(numFBFFailures[0]); |
| 66 | + } |
| 67 | + |
| 68 | + if (details.length > 0) { |
| 69 | + botio.message(); |
| 70 | + botio.message("```"); |
| 71 | + for (const line of details) { |
| 72 | + botio.message(line); |
| 73 | + } |
| 74 | + botio.message("```"); |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + // |
| 79 | + // Copy reftest analyzer files |
| 80 | + // |
| 81 | + echo(); |
| 82 | + echo('>> Copying reftest analyzer files'); |
| 83 | + mv('-f', './test/eq.log', botio.public_dir); |
| 84 | + mv('-f', './test/resources/reftest-analyzer.html', botio.public_dir); |
| 85 | + mv('-f', './test/resources/reftest-analyzer.css', botio.public_dir); |
| 86 | + mv('-f', './test/resources/reftest-analyzer.js', botio.public_dir); |
| 87 | + mv('-f', './test/test_snapshots', botio.public_dir + '/'); |
| 88 | + |
| 89 | + botio.message(); |
| 90 | + botio.message('Image differences available at: '+botio.public_url+'/reftest-analyzer.html#web=eq.log'); |
| 91 | + } |
| 92 | + |
| 93 | + // |
| 94 | + // Update local cache of PDF files |
| 95 | + // |
| 96 | + echo(); |
| 97 | + echo('>> Updating local PDF cache') |
| 98 | + mkdir('-p', __dirname+'/pdf-cache'); |
| 99 | + cp('./test/pdfs/*.pdf', __dirname+'/pdf-cache'); |
| 100 | + |
| 101 | + if (fail) |
| 102 | + exit(1); |
| 103 | + }); // exec test |
| 104 | +})(); // runTesting |
| 105 | + |
| 106 | +}); // npm install |
0 commit comments