2013-12-18 04:31:13 +04:00
|
|
|
fs = require 'fs'
|
|
|
|
|
|
|
|
module.exports.runSpecSuite = (specSuite, logFile, logErrors=true) ->
|
2014-07-09 19:26:34 +04:00
|
|
|
{$, $$} = require '../src/space-pen-extensions'
|
|
|
|
|
2013-09-17 22:47:00 +04:00
|
|
|
window[key] = value for key, value of require '../vendor/jasmine'
|
|
|
|
|
2014-01-15 22:41:01 +04:00
|
|
|
{TerminalReporter} = require 'jasmine-tagged'
|
2012-08-27 01:29:46 +04:00
|
|
|
|
2014-09-19 02:16:59 +04:00
|
|
|
disableFocusMethods() if process.env.JANKY_SHA1
|
|
|
|
|
2013-09-18 01:54:33 +04:00
|
|
|
TimeReporter = require './time-reporter'
|
2013-08-29 09:07:57 +04:00
|
|
|
timeReporter = new TimeReporter()
|
2012-08-27 01:29:46 +04:00
|
|
|
|
2013-12-19 05:12:12 +04:00
|
|
|
logStream = fs.openSync(logFile, 'w') if logFile?
|
2013-12-19 06:35:20 +04:00
|
|
|
log = (str) ->
|
2013-12-19 05:12:12 +04:00
|
|
|
if logStream?
|
2013-12-19 06:35:20 +04:00
|
|
|
fs.writeSync(logStream, str)
|
2013-12-19 05:12:12 +04:00
|
|
|
else
|
2013-12-19 06:35:20 +04:00
|
|
|
process.stderr.write(str)
|
2013-12-18 04:31:13 +04:00
|
|
|
|
2013-08-29 02:52:49 +04:00
|
|
|
if atom.getLoadSettings().exitWhenDone
|
2014-01-15 22:41:01 +04:00
|
|
|
reporter = new TerminalReporter
|
2013-12-19 06:35:20 +04:00
|
|
|
print: (str) ->
|
|
|
|
log(str)
|
2013-08-29 02:52:49 +04:00
|
|
|
onComplete: (runner) ->
|
2013-12-19 06:35:20 +04:00
|
|
|
fs.closeSync(logStream) if logStream?
|
2014-12-13 00:23:56 +03:00
|
|
|
require('grim').logDeprecations() if process.env.JANKY_SHA1
|
2013-08-29 02:52:49 +04:00
|
|
|
atom.exit(runner.results().failedCount > 0 ? 1 : 0)
|
2012-08-27 01:29:46 +04:00
|
|
|
else
|
2013-09-18 01:54:33 +04:00
|
|
|
AtomReporter = require './atom-reporter'
|
2013-08-29 02:52:49 +04:00
|
|
|
reporter = new AtomReporter()
|
2013-02-12 06:00:42 +04:00
|
|
|
|
2012-08-27 01:29:46 +04:00
|
|
|
require specSuite
|
2013-08-29 02:52:49 +04:00
|
|
|
|
2012-08-27 01:29:46 +04:00
|
|
|
jasmineEnv = jasmine.getEnv()
|
|
|
|
jasmineEnv.addReporter(reporter)
|
2013-08-29 09:07:57 +04:00
|
|
|
jasmineEnv.addReporter(timeReporter)
|
2013-11-06 03:44:38 +04:00
|
|
|
jasmineEnv.setIncludedTags([process.platform])
|
2013-02-02 02:13:09 +04:00
|
|
|
|
2013-08-29 02:52:49 +04:00
|
|
|
$('body').append $$ -> @div id: 'jasmine-content'
|
2013-02-02 02:13:09 +04:00
|
|
|
|
2012-08-27 01:29:46 +04:00
|
|
|
jasmineEnv.execute()
|
2014-09-19 02:16:59 +04:00
|
|
|
|
|
|
|
disableFocusMethods = ->
|
|
|
|
['fdescribe', 'ffdescribe', 'fffdescribe', 'fit', 'ffit', 'fffit'].forEach (methodName) ->
|
|
|
|
focusMethod = window[methodName]
|
|
|
|
window[methodName] = (description) ->
|
|
|
|
error = new Error('Focused spec is running on CI')
|
|
|
|
focusMethod description, -> throw error
|