mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Set timeout in the main process
This commit is contained in:
@@ -497,6 +497,13 @@ class AtomApplication
|
||||
if resourcePath isnt @resourcePath and not fs.existsSync(resourcePath)
|
||||
resourcePath = @resourcePath
|
||||
|
||||
timeout = Number.parseFloat(timeout)
|
||||
unless Number.isNaN(timeout)
|
||||
timeoutHandler = ->
|
||||
console.log "The test suite has timed out because it has been running for more than #{timeout} minutes."
|
||||
process.exit(124) # Use the same exit code as the UNIX timeout util.
|
||||
setTimeout(timeoutHandler, timeout * 60 * 1000)
|
||||
|
||||
try
|
||||
windowInitializationScript = require.resolve(path.resolve(@devResourcePath, 'src', 'initialize-test-window'))
|
||||
catch error
|
||||
@@ -516,7 +523,7 @@ class AtomApplication
|
||||
isSpec = true
|
||||
devMode = true
|
||||
safeMode ?= false
|
||||
new AtomWindow({windowInitializationScript, resourcePath, headless, isSpec, devMode, testRunnerPath, legacyTestRunnerPath, testPaths, logFile, safeMode, timeout})
|
||||
new AtomWindow({windowInitializationScript, resourcePath, headless, isSpec, devMode, testRunnerPath, legacyTestRunnerPath, testPaths, logFile, safeMode})
|
||||
|
||||
resolveTestRunnerPath: (testPath) ->
|
||||
FindParentDir ?= require 'find-parent-dir'
|
||||
|
||||
@@ -19,7 +19,7 @@ class AtomWindow
|
||||
isSpec: null
|
||||
|
||||
constructor: (settings={}) ->
|
||||
{@resourcePath, pathToOpen, locationsToOpen, @isSpec, @headless, @safeMode, @devMode, timeout} = settings
|
||||
{@resourcePath, pathToOpen, locationsToOpen, @isSpec, @headless, @safeMode, @devMode} = settings
|
||||
locationsToOpen ?= [{pathToOpen}] if pathToOpen
|
||||
locationsToOpen ?= []
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ try
|
||||
path = require 'path'
|
||||
ipc = require 'ipc'
|
||||
remote = require 'remote'
|
||||
app = remote.require('app')
|
||||
{getWindowLoadSettings} = require './window-load-settings-helpers'
|
||||
AtomEnvironment = require '../src/atom-environment'
|
||||
|
||||
@@ -33,11 +32,6 @@ try
|
||||
|
||||
document.title = "Spec Suite"
|
||||
|
||||
if timeout = getWindowLoadSettings().timeout
|
||||
ChildProcess = remote.require("child_process")
|
||||
timeoutCop = ChildProcess.fork(require.resolve('./timeout-cop'), [remote.process.pid, timeout])
|
||||
app.on "will-exit", -> timeoutCop.kill()
|
||||
|
||||
legacyTestRunner = require(getWindowLoadSettings().legacyTestRunnerPath)
|
||||
testRunner = require(getWindowLoadSettings().testRunnerPath)
|
||||
testRunner({
|
||||
@@ -50,7 +44,7 @@ try
|
||||
catch error
|
||||
if getWindowLoadSettings().headless
|
||||
console.error(error.stack ? error)
|
||||
app.emit('will-exit')
|
||||
remote.require('app').emit('will-exit')
|
||||
remote.process.exit(status)
|
||||
else
|
||||
throw error
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
let parentProcessId = process.argv[2]
|
||||
let timeoutInMinutes = process.argv[3]
|
||||
let timeoutInMilliseconds = timeoutInMinutes * 1000 * 60
|
||||
|
||||
function exitTestRunner () {
|
||||
process.kill(parentProcessId, 'SIGINT')
|
||||
let errorMessage = 'The test suite has timed out because it has been running'
|
||||
errorMessage += ' for more than ' + timeoutInMinutes + ' minutes.'
|
||||
console.log(errorMessage)
|
||||
}
|
||||
|
||||
setTimeout(exitTestRunner, timeoutInMilliseconds)
|
||||
Reference in New Issue
Block a user