mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Return a promise in test runners
This commit is contained in:
parent
4a59da9194
commit
cf5d94f084
@ -22,8 +22,10 @@ module.exports = ({logFile, headless, testPaths, buildAtomEnvironment}) ->
|
|||||||
|
|
||||||
setSpecType('user')
|
setSpecType('user')
|
||||||
|
|
||||||
|
resolveWithExitCode = null
|
||||||
|
promise = new Promise (resolve, reject) -> resolveWithExitCode = resolve
|
||||||
jasmineEnv = jasmine.getEnv()
|
jasmineEnv = jasmine.getEnv()
|
||||||
jasmineEnv.addReporter(buildReporter({logFile, headless}))
|
jasmineEnv.addReporter(buildReporter({logFile, headless, resolveWithExitCode}))
|
||||||
TimeReporter = require './time-reporter'
|
TimeReporter = require './time-reporter'
|
||||||
jasmineEnv.addReporter(new TimeReporter())
|
jasmineEnv.addReporter(new TimeReporter())
|
||||||
jasmineEnv.setIncludedTags([process.platform])
|
jasmineEnv.setIncludedTags([process.platform])
|
||||||
@ -37,6 +39,7 @@ module.exports = ({logFile, headless, testPaths, buildAtomEnvironment}) ->
|
|||||||
atom.commands.attach(window)
|
atom.commands.attach(window)
|
||||||
|
|
||||||
jasmineEnv.execute()
|
jasmineEnv.execute()
|
||||||
|
promise
|
||||||
|
|
||||||
disableFocusMethods = ->
|
disableFocusMethods = ->
|
||||||
['fdescribe', 'ffdescribe', 'fffdescribe', 'fit', 'ffit', 'fffit'].forEach (methodName) ->
|
['fdescribe', 'ffdescribe', 'fffdescribe', 'fit', 'ffit', 'fffit'].forEach (methodName) ->
|
||||||
@ -68,14 +71,14 @@ setSpecType = (specType) ->
|
|||||||
setSpecDirectory = (specDirectory) ->
|
setSpecDirectory = (specDirectory) ->
|
||||||
setSpecField('specDirectory', specDirectory)
|
setSpecField('specDirectory', specDirectory)
|
||||||
|
|
||||||
buildReporter = ({logFile, headless}) ->
|
buildReporter = ({logFile, headless, resolveWithExitCode}) ->
|
||||||
if headless
|
if headless
|
||||||
buildTerminalReporter(logFile)
|
buildTerminalReporter(logFile, resolveWithExitCode)
|
||||||
else
|
else
|
||||||
AtomReporter = require './atom-reporter'
|
AtomReporter = require './atom-reporter'
|
||||||
reporter = new AtomReporter()
|
reporter = new AtomReporter()
|
||||||
|
|
||||||
buildTerminalReporter = (logFile) ->
|
buildTerminalReporter = (logFile, resolveWithExitCode) ->
|
||||||
logStream = fs.openSync(logFile, 'w') if logFile?
|
logStream = fs.openSync(logFile, 'w') if logFile?
|
||||||
log = (str) ->
|
log = (str) ->
|
||||||
if logStream?
|
if logStream?
|
||||||
@ -94,9 +97,10 @@ buildTerminalReporter = (logFile) ->
|
|||||||
|
|
||||||
if grim.getDeprecationsLength() > 0
|
if grim.getDeprecationsLength() > 0
|
||||||
grim.logDeprecations()
|
grim.logDeprecations()
|
||||||
return atom.exit(1)
|
resolveWithExitCode(1)
|
||||||
|
return
|
||||||
|
|
||||||
if runner.results().failedCount > 0
|
if runner.results().failedCount > 0
|
||||||
atom.exit(1)
|
resolveWithExitCode(1)
|
||||||
else
|
else
|
||||||
atom.exit(0)
|
resolveWithExitCode(0)
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
# Start the crash reporter before anything else.
|
# Start the crash reporter before anything else.
|
||||||
require('crash-reporter').start(productName: 'Atom', companyName: 'GitHub')
|
require('crash-reporter').start(productName: 'Atom', companyName: 'GitHub')
|
||||||
|
remote = require 'remote'
|
||||||
|
|
||||||
|
exitWithStatusCode = (status) =>
|
||||||
|
remote.require('app').emit('will-exit')
|
||||||
|
remote.process.exit(status)
|
||||||
|
|
||||||
try
|
try
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc'
|
||||||
remote = require 'remote'
|
|
||||||
{getWindowLoadSettings} = require './window-load-settings-helpers'
|
{getWindowLoadSettings} = require './window-load-settings-helpers'
|
||||||
AtomEnvironment = require '../src/atom-environment'
|
AtomEnvironment = require '../src/atom-environment'
|
||||||
|
|
||||||
@ -38,17 +42,18 @@ try
|
|||||||
|
|
||||||
legacyTestRunner = require(getWindowLoadSettings().legacyTestRunnerPath)
|
legacyTestRunner = require(getWindowLoadSettings().legacyTestRunnerPath)
|
||||||
testRunner = require(getWindowLoadSettings().testRunnerPath)
|
testRunner = require(getWindowLoadSettings().testRunnerPath)
|
||||||
testRunner({
|
promise = testRunner({
|
||||||
logFile: getWindowLoadSettings().logFile
|
logFile: getWindowLoadSettings().logFile
|
||||||
headless: getWindowLoadSettings().headless
|
headless: getWindowLoadSettings().headless
|
||||||
testPaths: getWindowLoadSettings().testPaths
|
testPaths: getWindowLoadSettings().testPaths
|
||||||
buildAtomEnvironment: (params) -> new AtomEnvironment(params)
|
buildAtomEnvironment: (params) -> new AtomEnvironment(params)
|
||||||
legacyTestRunner: legacyTestRunner
|
legacyTestRunner: legacyTestRunner
|
||||||
})
|
})
|
||||||
|
|
||||||
|
promise.then(exitWithStatusCode) if getWindowLoadSettings().headless
|
||||||
catch error
|
catch error
|
||||||
if getWindowLoadSettings().headless
|
if getWindowLoadSettings().headless
|
||||||
console.error(error.stack ? error)
|
console.error(error.stack ? error)
|
||||||
remote.require('app').emit('will-exit')
|
exitWithStatusCode(1)
|
||||||
remote.process.exit(status)
|
|
||||||
else
|
else
|
||||||
throw error
|
throw error
|
||||||
|
Loading…
Reference in New Issue
Block a user