spec: It is not certain which process starts first
This commit is contained in:
parent
5940231b76
commit
d87ea5713d
2 changed files with 8 additions and 15 deletions
|
@ -162,23 +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 exited = 0
|
|
||||||
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.equal(code, 0)
|
assert.equal(code, 0)
|
||||||
exited++
|
|
||||||
if (exited === 2) {
|
|
||||||
done()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
// Second launch should exit with 1.
|
// Start second app when received output.
|
||||||
const second = ChildProcess.spawn(remote.process.execPath, [appPath])
|
first.stdout.once('data', () => {
|
||||||
second.once('exit', (code) => {
|
// Second launch should exit with 1.
|
||||||
assert.equal(code, 1)
|
const second = ChildProcess.spawn(remote.process.execPath, [appPath])
|
||||||
exited++
|
second.once('exit', (code) => {
|
||||||
if (exited === 2) {
|
assert.equal(code, 1)
|
||||||
done()
|
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…
Add table
Add a link
Reference in a new issue