Skip to content

Commit

Permalink
test: use config.version Electron whenever possible (#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Jun 25, 2024
1 parent 2f92bbd commit 0353a8a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"app"
],
"ava": {
"timeout": "60s"
"timeout": "120s"
},
"funding": {
"url": "https://github.com/electron/packager?sponsor=1"
Expand Down
12 changes: 6 additions & 6 deletions test/darwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async function appBundleTest (t, opts, appBundleId) {
assertCFBundleIdentifierValue(t, obj, appBundleIdentifier, 'CFBundleName should reflect opts.appBundleId or fallback to default')
}

async function appHelpersBundleTest (t, opts, helperBundleId, appBundleId) {
async function appHelpersBundleLegacyTest (t, opts, helperBundleId, appBundleId) {
opts.electronVersion = '1.4.13'

if (helperBundleId) {
Expand Down Expand Up @@ -428,11 +428,11 @@ if (!(process.env.CI && process.platform === 'win32')) {
])
}))

test.serial('app helpers bundle', darwinTest(appHelpersBundleTest, 'com.electron.basetest.helper'))
test.serial('app helpers bundle (w/ special characters)', darwinTest(appHelpersBundleTest, 'com.electron."bãśè tëßt!@#$%^&*()?\'.hęłpėr'))
test.serial('app helpers bundle helper-bundle-id fallback to app-bundle-id', darwinTest(appHelpersBundleTest, null, 'com.electron.basetest'))
test.serial('app helpers bundle helper-bundle-id fallback to app-bundle-id (w/ special characters)', darwinTest(appHelpersBundleTest, null, 'com.electron."bãśè tëßt!!@#$%^&*()?\''))
test.serial('app helpers bundle helper-bundle-id & app-bundle-id fallback', darwinTest(appHelpersBundleTest))
test.serial('app helpers bundle', darwinTest(appHelpersBundleLegacyTest, 'com.electron.basetest.helper'))
test.serial('app helpers bundle (w/ special characters)', darwinTest(appHelpersBundleLegacyTest, 'com.electron."bãśè tëßt!@#$%^&*()?\'.hęłpėr'))
test.serial('app helpers bundle helper-bundle-id fallback to app-bundle-id', darwinTest(appHelpersBundleLegacyTest, null, 'com.electron.basetest'))
test.serial('app helpers bundle helper-bundle-id fallback to app-bundle-id (w/ special characters)', darwinTest(appHelpersBundleLegacyTest, null, 'com.electron."bãśè tëßt!!@#$%^&*()?\''))
test.serial('app helpers bundle helper-bundle-id & app-bundle-id fallback', darwinTest(appHelpersBundleLegacyTest))

test.serial('app helpers bundle with renderer/plugin helpers', darwinTest(appHelpersBundleElectron6Test))

Expand Down
22 changes: 13 additions & 9 deletions test/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const util = require('./_util')
async function hookTest (wantHookCalled, hookName, t, opts, validator) {
let hookCalled = false
opts.dir = util.fixtureSubdir('basic')
opts.electronVersion = '1.4.13'
opts.arch = 'ia32'
opts.electronVersion = config.version
opts.arch = 'x64'
opts.platform = 'all'

opts[hookName] = [validator
Expand All @@ -27,10 +27,10 @@ async function hookTest (wantHookCalled, hookName, t, opts, validator) {

// 2 packages will be built during this test
const finalPaths = await packager(opts)
t.is(finalPaths.length, 2, 'packager call should resolve with expected number of paths')
t.is(finalPaths.length, 4, 'packager call should resolve with expected number of paths')
t.is(wantHookCalled, hookCalled, `${hookName} methods ${wantHookCalled ? 'should' : 'should not'} have been called`)
const exists = await util.verifyPackageExistence(finalPaths)
t.deepEqual(exists, [true, true], 'Packages should be generated for both 32-bit platforms')
t.deepEqual(exists, [true, true, true, true], 'Packages should be generated for all x64 platforms')
}

function createHookTest (hookName, validator) {
Expand All @@ -40,11 +40,15 @@ function createHookTest (hookName, validator) {
test.serial('platform=all (one arch) for beforeCopy hook', createHookTest('beforeCopy'))
test.serial('platform=all (one arch) for afterCopy hook', createHookTest('afterCopy'))
test.serial('platform=all (one arch) for afterFinalizePackageTargets hook', createHookTest('afterFinalizePackageTargets', (t, targets, callback) => {
t.is(targets.length, 2, 'target list should have two items')
t.is(targets[0].arch, 'ia32')
t.is(targets[0].platform, 'linux')
t.is(targets[1].arch, 'ia32')
t.is(targets[1].platform, 'win32')
t.is(targets.length, 4, 'target list should have four items')
t.is(targets[0].arch, 'x64')
t.is(targets[0].platform, 'darwin')
t.is(targets[1].arch, 'x64')
t.is(targets[1].platform, 'linux')
t.is(targets[2].arch, 'x64')
t.is(targets[2].platform, 'mas')
t.is(targets[3].arch, 'x64')
t.is(targets[3].platform, 'win32')
callback()
}))
test.serial('platform=all (one arch) for afterPrune hook', createHookTest('afterPrune'))
Expand Down
3 changes: 2 additions & 1 deletion test/mas.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const { packager } = require('../dist')
const path = require('path')
const test = require('ava')
const util = require('./_util')
const config = require('./config.json')

if (!(process.env.CI && process.platform === 'win32')) {
const masOpts = {
name: 'masTest',
dir: util.fixtureSubdir('basic'),
electronVersion: '2.0.0-beta.1',
electronVersion: config.version,
arch: 'x64',
platform: 'mas'
}
Expand Down
4 changes: 2 additions & 2 deletions test/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ test('validateListFromOptions works for armv7l host and target arch', t => {
})

test('build for all available official targets',
testMultiTarget({ all: true, electronVersion: '1.8.2' }, util.allPlatformArchCombosCount - 5,
'Packages should be generated for all possible platforms (except win32/arm64)'))
testMultiTarget({ all: true, electronVersion: config.version }, util.allPlatformArchCombosCount - 2,
'Packages should be generated for all possible platforms (except linux/ia32 and linux/mips64el)'))
test('build for all available official targets for a version without arm64 or mips64el support',
testMultiTarget({ all: true, electronVersion: '1.4.13' }, util.allPlatformArchCombosCount - 7,
'Packages should be generated for all possible platforms (except linux/arm64, linux/mips64el, or win32/arm64)'))
Expand Down

0 comments on commit 0353a8a

Please sign in to comment.