Add window:run-package-specs command

This will only run specs found in the current projects spec directory
This commit is contained in:
probablycorey 2013-08-21 17:14:27 -07:00 committed by Corey Johnson
parent ba632751a0
commit 78b9a99f86
4 changed files with 34 additions and 20 deletions

View File

@ -45,6 +45,7 @@
'ctrl-meta-f': 'window:toggle-full-screen'
'meta-r': 'window:reload'
'alt-meta-i': 'window:toggle-dev-tools'
'meta-alt-ctrl-p': 'window:run-package-specs'
'ctrl-|': 'pane:split-right'
'ctrl-w v': 'pane:split-right'

View File

@ -15,24 +15,33 @@ measure 'spec suite require time', ->
for spec in jasmine.getEnv().currentRunner().specs() when not spec.specType?
spec.specType = specType
# Run core specs
requireSpecs(window.resourcePath)
setSpecType('core')
runAllSpecs = ->
requireSpecs(window.resourcePath)
setSpecType('core')
fixturesPackagesPath = fsUtils.resolveOnLoadPath('fixtures/packages')
packagePaths = atom.getAvailablePackageNames().map (packageName) -> atom.resolvePackagePath(packageName)
packagePaths = _.groupBy packagePaths, (packagePath) ->
if packagePath.indexOf("#{fixturesPackagesPath}#{path.sep}") is 0
'fixtures'
else if packagePath.indexOf("#{window.resourcePath}#{path.sep}") is 0
'bundled'
else
'user'
fixturesPackagesPath = fsUtils.resolveOnLoadPath('fixtures/packages')
packagePaths = atom.getAvailablePackageNames().map (packageName) -> atom.resolvePackagePath(packageName)
packagePaths = _.groupBy packagePaths, (packagePath) ->
if packagePath.indexOf("#{fixturesPackagesPath}#{path.sep}") is 0
'fixtures'
else if packagePath.indexOf("#{window.resourcePath}#{path.sep}") is 0
'bundled'
else
'user'
# Run bundled package specs
requireSpecs(packagePath) for packagePath in packagePaths.bundled ? []
setSpecType('bundled')
# Run bundled package specs
requireSpecs(packagePath) for packagePath in packagePaths.bundled ? []
setSpecType('bundled')
# Run user package specs
requireSpecs(packagePath) for packagePath in packagePaths.user ? []
setSpecType('user')
# Run user package specs
requireSpecs(packagePath) for packagePath in packagePaths.user ? []
setSpecType('user')
runSpecs = (specPath) ->
requireSpecs(specPath)
setSpecType("user")
if specPath = atom.getLoadSettings().specPath
runSpecs(specPath)
else
runAllSpecs()

View File

@ -140,6 +140,9 @@ class AtomApplication
ipc.once 'update-application-menu', (processId, routingId, keystrokesByCommand) =>
@applicationMenu.update(keystrokesByCommand)
ipc.on 'run-package-specs', (processId, routingId, packagePath) =>
@runSpecs({@resourcePath, specPath: packagePath, exitWhenDone: false})
ipc.on 'command', (processId, routingId, command) =>
@emit(command)
@ -194,14 +197,14 @@ class AtomApplication
else
console.log "Opening unknown url #{urlToOpen}"
runSpecs: ({exitWhenDone, resourcePath}) ->
runSpecs: ({exitWhenDone, resourcePath, specPath}) ->
if resourcePath isnt @resourcePath and not fs.existsSync(resourcePath)
resourcePath = @resourcePath
bootstrapScript = 'spec-bootstrap'
isSpec = true
devMode = true
new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode})
new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode, specPath})
promptForPath: ({devMode}={}) ->
pathsToOpen = dialog.showOpenDialog title: 'Open', properties: ['openFile', 'openDirectory', 'multiSelections', 'createDirectory']

View File

@ -81,6 +81,7 @@ class RootView extends View
@command 'application:zoom', -> ipc.sendChannel('command', 'application:zoom')
@command 'application:bring-all-windows-to-front', -> ipc.sendChannel('command', 'application:bring-all-windows-to-front')
@command 'window:run-package-specs', => ipc.sendChannel('run-package-specs', project.getPath())
@command 'window:increase-font-size', =>
config.set("editor.fontSize", config.get("editor.fontSize") + 1)