2013-03-15 19:09:56 +04:00
|
|
|
measure 'spec suite require time', ->
|
2013-09-20 00:51:53 +04:00
|
|
|
{_, fs, Git} = require 'atom'
|
2013-06-13 03:20:40 +04:00
|
|
|
path = require 'path'
|
2013-09-18 01:54:33 +04:00
|
|
|
require './spec-helper'
|
2012-10-25 22:45:58 +04:00
|
|
|
|
2013-09-04 04:00:50 +04:00
|
|
|
requireSpecs = (specDirectory, specType) ->
|
2013-09-18 05:58:41 +04:00
|
|
|
for specFilePath in fs.listTreeSync(specDirectory) when /-spec\.coffee$/.test specFilePath
|
2013-09-04 04:00:50 +04:00
|
|
|
require specFilePath
|
2013-08-14 21:58:56 +04:00
|
|
|
|
|
|
|
setSpecType = (specType) ->
|
2013-08-09 23:21:56 +04:00
|
|
|
for spec in jasmine.getEnv().currentRunner().specs() when not spec.specType?
|
|
|
|
spec.specType = specType
|
|
|
|
|
2013-08-22 04:14:27 +04:00
|
|
|
runAllSpecs = ->
|
2013-09-03 04:43:12 +04:00
|
|
|
# Only run core specs when resource path is the Atom repository
|
|
|
|
if Git.exists(window.resourcePath)
|
2013-09-04 04:00:50 +04:00
|
|
|
requireSpecs(path.join(window.resourcePath, 'spec'))
|
2013-09-03 04:43:12 +04:00
|
|
|
setSpecType('core')
|
2013-08-22 04:14:27 +04:00
|
|
|
|
2013-09-19 21:44:18 +04:00
|
|
|
fixturesPackagesPath = path.join(__dirname, 'fixtures', 'packages')
|
2013-08-22 04:14:27 +04:00
|
|
|
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
|
2013-09-04 04:00:50 +04:00
|
|
|
requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.bundled ? []
|
2013-08-22 04:14:27 +04:00
|
|
|
setSpecType('bundled')
|
|
|
|
|
|
|
|
# Run user package specs
|
2013-09-04 04:00:50 +04:00
|
|
|
requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.user ? []
|
2013-08-22 04:14:27 +04:00
|
|
|
setSpecType('user')
|
|
|
|
|
2013-09-04 03:59:49 +04:00
|
|
|
if specDirectory = atom.getLoadSettings().specDirectory
|
2013-09-04 04:00:50 +04:00
|
|
|
requireSpecs(specDirectory)
|
|
|
|
setSpecType('user')
|
2013-08-22 04:14:27 +04:00
|
|
|
else
|
|
|
|
runAllSpecs()
|