Merge pull request #10602 from electron/fix-singleton-test
Fix the flaky test of app.makeSingleInstance
This commit is contained in:
commit
42a2126273
2 changed files with 9 additions and 12 deletions
|
@ -162,19 +162,18 @@ describe('app module', function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton')
|
const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton')
|
||||||
// First launch should exit with 0.
|
// First launch should exit with 0.
|
||||||
let secondLaunched = false
|
|
||||||
const first = ChildProcess.spawn(remote.process.execPath, [appPath])
|
const first = ChildProcess.spawn(remote.process.execPath, [appPath])
|
||||||
first.once('exit', (code) => {
|
first.once('exit', (code) => {
|
||||||
assert.ok(secondLaunched)
|
|
||||||
assert.equal(code, 0)
|
assert.equal(code, 0)
|
||||||
done()
|
|
||||||
})
|
})
|
||||||
|
// Start second app when received output.
|
||||||
|
first.stdout.once('data', () => {
|
||||||
// Second launch should exit with 1.
|
// Second launch should exit with 1.
|
||||||
const second = ChildProcess.spawn(remote.process.execPath, [appPath])
|
const second = ChildProcess.spawn(remote.process.execPath, [appPath])
|
||||||
second.once('exit', (code) => {
|
second.once('exit', (code) => {
|
||||||
assert.ok(!secondLaunched)
|
|
||||||
assert.equal(code, 1)
|
assert.equal(code, 1)
|
||||||
secondLaunched = true
|
done()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
4
spec/fixtures/api/singleton/main.js
vendored
4
spec/fixtures/api/singleton/main.js
vendored
|
@ -1,8 +1,6 @@
|
||||||
const {app} = require('electron')
|
const {app} = require('electron')
|
||||||
|
|
||||||
process.on('uncaughtException', () => {
|
console.log('started') // ping parent
|
||||||
app.exit(2)
|
|
||||||
})
|
|
||||||
|
|
||||||
const shouldExit = app.makeSingleInstance(() => {
|
const shouldExit = app.makeSingleInstance(() => {
|
||||||
process.nextTick(() => app.exit(0))
|
process.nextTick(() => app.exit(0))
|
||||||
|
|
Loading…
Reference in a new issue