Skip to content

Commit

Permalink
refactor: always test against post-1.0 versions of Electron (#1012)
Browse files Browse the repository at this point in the history
* chore: replace Electron 1.3.1 with 1.4.13 in tests
  • Loading branch information
malept committed Jun 20, 2019
1 parent 51cce5b commit cc470ef
Show file tree
Hide file tree
Showing 24 changed files with 18 additions and 90 deletions.
20 changes: 4 additions & 16 deletions test/_setup.js
Expand Up @@ -25,7 +25,7 @@ function skipDownloadingMacZips (platform, arch) {
}

async function downloadAll (version) {
console.log(`Calling electron-download for ${version} before running tests...`)
console.log(`Downloading Electron v${version} before running tests...`)
const combinations = download.createDownloadCombos({ electronVersion: config.version, all: true }, targets.officialPlatforms, targets.officialArchs, skipDownloadingMacZips)

return Promise.all(combinations.map(combination => downloadElectronZip(version, combination)))
Expand All @@ -40,27 +40,15 @@ async function downloadElectronZip (version, options) {
})
}

async 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.
* Download all Electron distributions before running tests to avoid timing out due to
* network speed.
*/
async function preDownloadElectron () {
const versions = [
config.version,
'0.37.4',
'1.3.1'
config.version
]
await Promise.all(versions.map(downloadAll))
await downloadMASLoginHelperElectronZip()
}

const WORK_CWD = path.join(__dirname, 'work')
Expand Down
3 changes: 1 addition & 2 deletions test/asar.js
Expand Up @@ -20,8 +20,7 @@ test('asar argument test: asar is not an Object or a bool', t => {

test.serial('default_app.asar removal test', util.testSinglePlatform(async (t, opts) => {
opts.name = 'default_appASARTest'
opts.dir = util.fixtureSubdir('el-0374')
opts.electronVersion = '0.37.4'
opts.dir = util.fixtureSubdir('basic')

const resourcesPath = await util.packageAndEnsureResourcesPath(t, opts)
await util.assertPathNotExists(t, path.join(resourcesPath, 'default_app.asar'), 'The output directory should not contain the Electron default_app.asar file')
Expand Down
6 changes: 2 additions & 4 deletions test/basic.js
Expand Up @@ -61,7 +61,7 @@ test('sanitize app name for use in the out directory name', t => {
test('cannot build apps where the name ends in " Helper"', async t => {
const opts = {
arch: 'x64',
dir: path.join(__dirname, 'fixtures', 'el-0374'),
dir: util.fixtureSubdir('basic'),
name: 'Bad Helper',
platform: 'linux'
}
Expand Down Expand Up @@ -264,7 +264,6 @@ test.serial('executableName honored when building for Linux target', util.testSi

test('fails with invalid version', util.invalidOptionTest({
name: 'invalidElectronTest',
dir: util.fixtureSubdir('el-0374'),
electronVersion: '0.0.1',
arch: 'x64',
platform: 'linux',
Expand All @@ -275,8 +274,7 @@ test('fails with invalid version', util.invalidOptionTest({

test.serial('dir: relative path', util.testSinglePlatform(async (t, opts) => {
opts.name = 'ElectronTest'
opts.dir = path.join('..', 'fixtures', 'el-0374')
opts.electronVersion = '0.37.4'
opts.dir = path.join('..', 'fixtures', 'basic')

const finalPath = (await packager(opts))[0]
t.is(path.join(t.context.workDir, 'ElectronTest-linux-x64'), finalPath, 'paths returned')
Expand Down
2 changes: 1 addition & 1 deletion test/config.json
@@ -1,3 +1,3 @@
{
"version": "0.35.6"
"version": "1.4.13"
}
9 changes: 0 additions & 9 deletions test/darwin.js
Expand Up @@ -21,13 +21,6 @@ const darwinOpts = {
platform: 'darwin'
}

const el0374Opts = {
...darwinOpts,
name: 'el0374Test',
dir: util.fixtureSubdir('el-0374'),
electronVersion: '0.37.4'
}

function testWrapper (extraOpts, testFunction, ...extraArgs) {
return util.packagerTest((t, baseOpts) => testFunction(t, { ...baseOpts, ...extraOpts }, ...extraArgs))
}
Expand Down Expand Up @@ -184,8 +177,6 @@ if (!(process.env.CI && process.platform === 'win32')) {
const icnsPath = `${iconBase}.icns`

test.serial('macOS icon: .icns specified', darwinTest(iconTest, icnsPath, icnsPath))
// This test exists because the .icns file basename changed as of 0.37.4
test.serial('macOS icon: Electron 0.37.4, .icns specified', testWrapper(el0374Opts, iconTest, icnsPath, icnsPath))
test.serial('macOS icon: .ico specified (should replace with .icns)', darwinTest(iconTest, `${iconBase}.ico`, icnsPath))
test.serial('macOS icon: basename only (should add .icns)', darwinTest(iconTest, iconBase, icnsPath))

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/asar-prebuilt/package.json
Expand Up @@ -4,6 +4,6 @@
"description": "A prebuilt asar app",
"main": "main.js",
"devDependencies": {
"electron": "1.3.1"
"electron": "1.4.13"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/basic-renamed-to-electron/package.json
Expand Up @@ -6,7 +6,7 @@
"electron-prebuilt": "1.2.0"
},
"devDependencies": {
"electron": "1.3.1",
"electron": "1.4.13",
"electron-prebuilt": "1.3.0"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/basic/package.json
Expand Up @@ -11,6 +11,6 @@
"devDependencies": {
"ncp": "^2.0.0",
"run-waterfall": "^1.1.1",
"electron-prebuilt": "0.35.6"
"electron-prebuilt": "1.4.13"
}
}
4 changes: 0 additions & 4 deletions test/fixtures/el-0374/index.html

This file was deleted.

24 changes: 0 additions & 24 deletions test/fixtures/el-0374/main.js

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/el-0374/node_modules/ncp/package.json

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/el-0374/node_modules/run-series/package.json

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions test/fixtures/el-0374/package.json

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/electron-in-dependencies/package.json
Expand Up @@ -3,6 +3,6 @@
"productName": "MainJS",
"description": "Removing electron from dependencies",
"dependencies": {
"electron": "1.3.1"
"electron": "1.4.13"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/infer-missing-version-only/package.json
Expand Up @@ -2,6 +2,6 @@
"main": "main.js",
"productName": "MainJS",
"devDependencies": {
"electron": "1.3.1"
"electron": "1.4.13"
}
}

0 comments on commit cc470ef

Please sign in to comment.