test: use exit event to wait for process exit (#21865)
This commit is contained in:
parent
2743d60f52
commit
0209302d84
7 changed files with 10 additions and 10 deletions
|
@ -160,7 +160,7 @@ describe('app module', () => {
|
||||||
if (appProcess && appProcess.stdout) {
|
if (appProcess && appProcess.stdout) {
|
||||||
appProcess.stdout.on('data', data => { output += data })
|
appProcess.stdout.on('data', data => { output += data })
|
||||||
}
|
}
|
||||||
const [code] = await emittedOnce(appProcess, 'close')
|
const [code] = await emittedOnce(appProcess, 'exit')
|
||||||
|
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
expect(output).to.include('Exit event with code: 123')
|
expect(output).to.include('Exit event with code: 123')
|
||||||
|
@ -173,7 +173,7 @@ describe('app module', () => {
|
||||||
const electronPath = process.execPath
|
const electronPath = process.execPath
|
||||||
|
|
||||||
appProcess = cp.spawn(electronPath, [appPath])
|
appProcess = cp.spawn(electronPath, [appPath])
|
||||||
const [code, signal] = await emittedOnce(appProcess, 'close')
|
const [code, signal] = await emittedOnce(appProcess, 'exit')
|
||||||
|
|
||||||
expect(signal).to.equal(null, 'exit signal should be null, if you see this please tag @MarshallOfSound')
|
expect(signal).to.equal(null, 'exit signal should be null, if you see this please tag @MarshallOfSound')
|
||||||
expect(code).to.equal(123, 'exit code should be 123, if you see this please tag @MarshallOfSound')
|
expect(code).to.equal(123, 'exit code should be 123, if you see this please tag @MarshallOfSound')
|
||||||
|
@ -194,7 +194,7 @@ describe('app module', () => {
|
||||||
if (appProcess && appProcess.stdout) {
|
if (appProcess && appProcess.stdout) {
|
||||||
appProcess.stdout.on('data', () => appProcess!.kill())
|
appProcess.stdout.on('data', () => appProcess!.kill())
|
||||||
}
|
}
|
||||||
const [code, signal] = await emittedOnce(appProcess, 'close')
|
const [code, signal] = await emittedOnce(appProcess, 'exit')
|
||||||
|
|
||||||
const message = `code:\n${code}\nsignal:\n${signal}`
|
const message = `code:\n${code}\nsignal:\n${signal}`
|
||||||
expect(code).to.equal(0, message)
|
expect(code).to.equal(0, message)
|
||||||
|
|
|
@ -227,7 +227,7 @@ describe('BrowserView module', () => {
|
||||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'leak-exit-browserview.js')
|
const appPath = path.join(__dirname, 'fixtures', 'api', 'leak-exit-browserview.js')
|
||||||
const electronPath = process.execPath
|
const electronPath = process.execPath
|
||||||
const appProcess = ChildProcess.spawn(electronPath, [appPath])
|
const appProcess = ChildProcess.spawn(electronPath, [appPath])
|
||||||
const [code] = await emittedOnce(appProcess, 'close')
|
const [code] = await emittedOnce(appProcess, 'exit')
|
||||||
expect(code).to.equal(0)
|
expect(code).to.equal(0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -340,7 +340,7 @@ ifdescribe(!process.mas && !process.env.DISABLE_CRASH_REPORTER_TESTS && process.
|
||||||
it('does not prevent process from crashing', (done) => {
|
it('does not prevent process from crashing', (done) => {
|
||||||
const appPath = path.join(fixtures, 'api', 'cookie-app')
|
const appPath = path.join(fixtures, 'api', 'cookie-app')
|
||||||
const appProcess = childProcess.spawn(process.execPath, [appPath])
|
const appProcess = childProcess.spawn(process.execPath, [appPath])
|
||||||
appProcess.once('close', () => {
|
appProcess.once('exit', () => {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -878,7 +878,7 @@ describe('Menu module', function () {
|
||||||
let output = ''
|
let output = ''
|
||||||
appProcess.stdout.on('data', data => { output += data })
|
appProcess.stdout.on('data', data => { output += data })
|
||||||
|
|
||||||
await emittedOnce(appProcess, 'close')
|
await emittedOnce(appProcess, 'exit')
|
||||||
expect(output).to.include('Window has no menu')
|
expect(output).to.include('Window has no menu')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -889,7 +889,7 @@ describe('Menu module', function () {
|
||||||
let output = ''
|
let output = ''
|
||||||
appProcess.stdout.on('data', data => { output += data })
|
appProcess.stdout.on('data', data => { output += data })
|
||||||
|
|
||||||
await emittedOnce(appProcess, 'close')
|
await emittedOnce(appProcess, 'exit')
|
||||||
expect(output).to.include('Window has no menu')
|
expect(output).to.include('Window has no menu')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -161,7 +161,7 @@ describe('netLog module', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await emittedOnce(appProcess, 'close')
|
await emittedOnce(appProcess, 'exit')
|
||||||
expect(fs.existsSync(dumpFileDynamic)).to.be.true('dynamic dump file exists')
|
expect(fs.existsSync(dumpFileDynamic)).to.be.true('dynamic dump file exists')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -234,7 +234,7 @@ describe('session module', () => {
|
||||||
)
|
)
|
||||||
|
|
||||||
appProcess.stdout.on('data', data => { output += data })
|
appProcess.stdout.on('data', data => { output += data })
|
||||||
appProcess.stdout.on('end', () => {
|
appProcess.on('exit', () => {
|
||||||
resolve(output.replace(/(\r\n|\n|\r)/gm, ''))
|
resolve(output.replace(/(\r\n|\n|\r)/gm, ''))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe('WebContentsView', () => {
|
||||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'leak-exit-webcontentsview.js')
|
const appPath = path.join(__dirname, 'fixtures', 'api', 'leak-exit-webcontentsview.js')
|
||||||
const electronPath = process.execPath
|
const electronPath = process.execPath
|
||||||
const appProcess = ChildProcess.spawn(electronPath, [appPath])
|
const appProcess = ChildProcess.spawn(electronPath, [appPath])
|
||||||
const [code] = await emittedOnce(appProcess, 'close')
|
const [code] = await emittedOnce(appProcess, 'exit')
|
||||||
expect(code).to.equal(0)
|
expect(code).to.equal(0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue