2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-13 08:36:28 +00:00
nativefier/test/multitarget.js
Kenneth G. Franqueiro a360f6c2ee Add more comprehensive tests
This implements the following cases:

* Basic runs for a specific version/platform/arch with default options
  (testing for existence of expected output files/folders)
* Runs for each target platform with `out` set
* Runs for each target platform with `asar` set
* Runs for each target platform with `prune` set
* Runs for each target platform with `ignore` set
  * This includes testing `ignore` including a path separator
  * This also includes testing that `ignore` entries are applied
    with the app folder trimmed
* Runs for each target platform with `overwrite` set / not set
* Runs with `all` set, with `arch` or `platform` each set to `all`,
  and with `platform` set to multiple platforms (comma-delimited or
  array)
* Tests specifically for the darwin target platform, to test
  `icon` and `sign`

The test logic is organized such that the version of Electron being
tested can be configured once centrally (in config.json), and the tests
will not run until after downloading any necessary electron versions
(to avoid timing out due to long downloads).

Resolves #77.
2015-06-28 16:57:59 -04:00

146 lines
3.9 KiB
JavaScript

var fs = require('fs')
var path = require('path')
var packager = require('..')
var series = require('run-series')
var test = require('tape')
var waterfall = require('run-waterfall')
var config = require('./config.json')
var util = require('./util')
function verifyPackageExistence (finalPaths, callback) {
series(finalPaths.map(function (finalPath) {
return function (cb) {
fs.stat(finalPath, cb)
}
}), function (err, statsResults) {
if (err) return callback(null, false)
callback(null, statsResults.every(function (stats) {
return stats.isDirectory()
}))
})
}
util.setup()
test('all test', function (t) {
t.timeoutAfter(config.timeout * 5) // 4-5 packages will be built during this test
var opts = {
name: 'basicTest',
dir: path.join(__dirname, 'fixtures', 'basic'),
version: config.version,
all: true
}
waterfall([
function (cb) {
packager(opts, cb)
}, function (finalPaths, cb) {
// Windows skips packaging for OS X, and OS X only has 64-bit releases
t.equal(finalPaths.length, process.platform === 'win32' ? 4 : 5,
'packager call should resolve with expected number of paths')
verifyPackageExistence(finalPaths, cb)
}, function (exists, cb) {
t.true(exists, 'Packages should be generated for all possible platforms')
cb()
}
], function (err) {
t.end(err)
})
})
util.teardown()
util.setup()
test('platform=all test (one arch)', function (t) {
t.timeoutAfter(config.timeout * 2) // 2 packages will be built during this test
var opts = {
name: 'basicTest',
dir: path.join(__dirname, 'fixtures', 'basic'),
version: config.version,
arch: 'ia32',
platform: 'all'
}
waterfall([
function (cb) {
packager(opts, cb)
}, function (finalPaths, cb) {
t.equal(finalPaths.length, 2, 'packager call should resolve with expected number of paths')
verifyPackageExistence(finalPaths, cb)
}, function (exists, cb) {
t.true(exists, 'Packages should be generated for both 32-bit platforms')
cb()
}
], function (err) {
t.end(err)
})
})
util.teardown()
util.setup()
test('arch=all test (one platform)', function (t) {
t.timeoutAfter(config.timeout * 2) // 2 packages will be built during this test
var opts = {
name: 'basicTest',
dir: path.join(__dirname, 'fixtures', 'basic'),
version: config.version,
arch: 'all',
platform: 'linux'
}
waterfall([
function (cb) {
packager(opts, cb)
}, function (finalPaths, cb) {
t.equal(finalPaths.length, 2, 'packager call should resolve with expected number of paths')
verifyPackageExistence(finalPaths, cb)
}, function (exists, cb) {
t.true(exists, 'Packages should be generated for both architectures')
cb()
}
], function (err) {
t.end(err)
})
})
util.teardown()
function createMultiTest (arch, platform) {
return function (t) {
t.timeoutAfter(config.timeout * 4) // 4 packages will be built during this test
var opts = {
name: 'basicTest',
dir: path.join(__dirname, 'fixtures', 'basic'),
version: config.version,
arch: arch,
platform: platform
}
waterfall([
function (cb) {
packager(opts, cb)
}, function (finalPaths, cb) {
t.equal(finalPaths.length, 4, 'packager call should resolve with expected number of paths')
verifyPackageExistence(finalPaths, cb)
}, function (exists, cb) {
t.true(exists, 'Packages should be generated for all combinations of specified archs and platforms')
cb()
}
], function (err) {
t.end(err)
})
}
}
util.setup()
test('multi-platform / multi-arch test, from arrays', createMultiTest(['ia32', 'x64'], ['linux', 'win32']))
util.teardown()
util.setup()
test('multi-platform / multi-arch test, from strings', createMultiTest('ia32,x64', 'linux,win32'))
util.teardown()