|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const config = require('./config.json') |
| 4 | +const fs = require('fs') |
| 5 | +const packager = require('..') |
| 6 | +const path = require('path') |
| 7 | +const series = require('run-series') |
| 8 | +const test = require('tape') |
| 9 | +const util = require('./util') |
| 10 | +const waterfall = require('run-waterfall') |
| 11 | + |
| 12 | +function verifyPackageExistence (finalPaths, callback) { |
| 13 | + series(finalPaths.map(function (finalPath) { |
| 14 | + return function (cb) { |
| 15 | + fs.stat(finalPath, cb) |
| 16 | + } |
| 17 | + }), function (err, statsResults) { |
| 18 | + if (err) return callback(null, false) |
| 19 | + |
| 20 | + callback(null, statsResults.every(function (stats) { |
| 21 | + return stats.isDirectory() |
| 22 | + })) |
| 23 | + }) |
| 24 | +} |
| 25 | + |
| 26 | +util.setup() |
| 27 | +test('platform=all test (one arch) (afterExtract hook)', function (t) { |
| 28 | + t.timeoutAfter(config.timeout * 2) // 2 packages will be built during this test |
| 29 | + |
| 30 | + var afterExtractCalled = false |
| 31 | + var opts = { |
| 32 | + name: 'basicTest', |
| 33 | + dir: path.join(__dirname, 'fixtures', 'basic'), |
| 34 | + version: config.version, |
| 35 | + arch: 'ia32', |
| 36 | + platform: 'all', |
| 37 | + afterExtract: [function testAfterExtract (buildPath, electronVersion, platform, arch, callback) { |
| 38 | + afterExtractCalled = true |
| 39 | + t.equal(electronVersion, opts.version, 'afterExtract electronVersion should be the same as the options object') |
| 40 | + t.equal(arch, opts.arch, 'afterExtract arch should be the same as the options object') |
| 41 | + callback() |
| 42 | + }] |
| 43 | + } |
| 44 | + |
| 45 | + waterfall([ |
| 46 | + function (cb) { |
| 47 | + packager(opts, cb) |
| 48 | + }, function (finalPaths, cb) { |
| 49 | + t.equal(finalPaths.length, 2, 'packager call should resolve with expected number of paths') |
| 50 | + t.true(afterExtractCalled, 'afterExtract methods should have been called') |
| 51 | + verifyPackageExistence(finalPaths, cb) |
| 52 | + }, function (exists, cb) { |
| 53 | + t.true(exists, 'Packages should be generated for both 32-bit platforms') |
| 54 | + cb() |
| 55 | + } |
| 56 | + ], function (err) { |
| 57 | + t.end(err) |
| 58 | + }) |
| 59 | +}) |
| 60 | +util.teardown() |
0 commit comments