Skip to content

Commit

Permalink
Pre-download the MAS version being tested
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Feb 25, 2018
1 parent 5852ebb commit c82cc36
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions test/_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,50 @@ function fixtureSubdir (subdir) {
return path.join(__dirname, 'fixtures', subdir)
}

/**
* Skip testing darwin/mas target on Windows since Electron Packager itself skips it
* (see https://github.com/electron-userland/electron-packager/issues/71)
*/
function skipDownloadingMacZips (platform, arch) {
return common.isPlatformMac(platform) && process.platform === 'win32'
}

function downloadAll (version) {
console.log(`Calling electron-download for ${version} before running tests...`)
const combinations = download.createDownloadCombos({electronVersion: config.version, all: true}, targets.officialPlatforms, targets.officialArchs, (platform, arch) => {
// Skip testing darwin/mas target on Windows since electron-packager itself skips it
// (see https://github.com/electron-userland/electron-packager/issues/71)
return common.isPlatformMac(platform) && process.platform === 'win32'
})
const combinations = download.createDownloadCombos({electronVersion: config.version, all: true}, targets.officialPlatforms, targets.officialArchs, skipDownloadingMacZips)

return Promise.all(combinations.map(combination => downloadElectronZip(version, combination)))
}

return Promise.all(combinations.map(combination => {
return download.downloadElectronZip(Object.assign({}, combination, {
cache: path.join(os.homedir(), '.electron'),
quiet: !!process.env.CI,
version: version
}))
function downloadElectronZip (version, options) {
return download.downloadElectronZip(Object.assign({}, options, {
cache: path.join(os.homedir(), '.electron'),
quiet: !!process.env.CI,
version: version
}))
}

// Download all Electron distributions before running tests to avoid timing out due to network
// speed. Most tests run with the config.json version, but we have some tests using 0.37.4, and an
// electron module specific test using 1.3.1.
function downloadMASLoginHelperElectronZip () {
if (process.platform !== 'win32') {
const version = '2.0.0-beta.1'
console.log(`Calling electron-download for ${version} (MAS only) before running tests...`)
return downloadElectronZip(version, { platform: 'mas', arch: 'x64' })
}
}

/**
* Download all Electron distributions before running tests to avoid timing out due to network
* speed. Most tests run with the config.json version, but we have some tests using 0.37.4, an
* `electron` module specific test using 1.3.1., and an MAS-specific test using 2.0.0-beta.1.
*/
function preDownloadElectron () {
const versions = [
config.version,
'0.37.4',
'1.3.1'
]
return Promise.all(versions.map(downloadAll))
.then(downloadMASLoginHelperElectronZip)
}

function npmInstallForFixture (fixture) {
Expand Down

0 comments on commit c82cc36

Please sign in to comment.