Allow multiple test paths to be specified as command line arguments

This commit is contained in:
Nathan Sobo
2015-09-27 20:53:41 -06:00
parent e886d8b253
commit e4d64309b7
2 changed files with 12 additions and 6 deletions

View File

@@ -87,7 +87,7 @@ class AtomApplication
openWithOptions: ({pathsToOpen, executedFrom, urlsToOpen, test, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, logFile, profileStartup}) ->
if test
@runSpecs({headless: true, @resourcePath, specDirectory, logFile})
@runTests({headless: true, @resourcePath, executedFrom, specDirectory, pathsToOpen, logFile})
else if pathsToOpen.length > 0
@openPaths({pathsToOpen, executedFrom, pidToKillWhenClosed, newWindow, devMode, safeMode, profileStartup})
else if urlsToOpen.length > 0
@@ -160,7 +160,7 @@ class AtomApplication
devMode: @focusedWindow()?.devMode
safeMode: @focusedWindow()?.safeMode
@on 'application:run-all-specs', -> @runSpecs(headless: false, resourcePath: @devResourcePath, safeMode: @focusedWindow()?.safeMode)
@on 'application:run-all-specs', -> @runTests(headless: false, resourcePath: @devResourcePath, safeMode: @focusedWindow()?.safeMode)
@on 'application:quit', -> app.quit()
@on 'application:new-window', -> @openPath(_.extend(windowDimensions: @focusedWindow()?.getDimensions(), getLoadSettings()))
@on 'application:new-file', -> (@focusedWindow() ? this).openPath()
@@ -251,7 +251,7 @@ class AtomApplication
@applicationMenu.update(win, template, keystrokesByCommand)
ipc.on 'run-package-specs', (event, specDirectory) =>
@runSpecs({resourcePath: @devResourcePath, specDirectory: specDirectory, headless: false})
@runTests({resourcePath: @devResourcePath, specDirectory: specDirectory, headless: false})
ipc.on 'command', (event, command) =>
@emit(command)
@@ -489,7 +489,7 @@ class AtomApplication
# :specPath - The directory to load specs from.
# :safeMode - A Boolean that, if true, won't run specs from ~/.atom/packages
# and ~/.atom/dev/packages, defaults to false.
runSpecs: ({headless, resourcePath, specDirectory, logFile, safeMode}) ->
runTests: ({headless, resourcePath, executedFrom, specDirectory, pathsToOpen, logFile, safeMode}) ->
if resourcePath isnt @resourcePath and not fs.existsSync(resourcePath)
resourcePath = @resourcePath
@@ -498,10 +498,16 @@ class AtomApplication
catch error
windowInitializationScript = require.resolve(path.resolve(__dirname, '..', '..', 'src', 'initialize-test-window'))
testPaths = []
testPaths.push(specDirectory) if specDirectory?
if pathsToOpen?
for pathToOpen in pathsToOpen
testPaths.push(path.resolve(executedFrom, fs.normalize(pathToOpen)))
isSpec = true
devMode = true
safeMode ?= false
new AtomWindow({windowInitializationScript, resourcePath, headless, isSpec, devMode, specDirectory, logFile, safeMode})
new AtomWindow({windowInitializationScript, resourcePath, headless, isSpec, devMode, testPaths, logFile, safeMode})
locationForPathToOpen: (pathToOpen, executedFrom='') ->
return {pathToOpen} unless pathToOpen

View File

@@ -23,7 +23,7 @@ try
testRunner({
logFile: atom.getLoadSettings().logFile
headless: atom.getLoadSettings().headless
testPaths: [atom.getLoadSettings().specDirectory]
testPaths: atom.getLoadSettings().testPaths
})
catch error