Add test task that runs packages specs from queue

This commit is contained in:
Kevin Sawicki 2013-10-10 17:22:14 -07:00
parent 1ed01c5155
commit 483f63ab05
2 changed files with 34 additions and 1 deletions

View File

@ -181,7 +181,7 @@ module.exports = (grunt) ->
grunt.registerTask('compile', ['coffee', 'prebuild-less', 'cson'])
grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint'])
grunt.registerTask('test', ['shell:kill-atom', 'shell:test'])
grunt.registerTask('test', ['shell:kill-atom', 'run-specs'])
grunt.registerTask('ci', ['lint', 'update-atom-shell', 'build', 'set-development-version', 'test'])
grunt.registerTask('deploy', ['partial-clean', 'update-atom-shell', 'build', 'codesign'])
grunt.registerTask('docs', ['markdown:guides', 'build-docs'])

33
tasks/test-task.coffee Normal file
View File

@ -0,0 +1,33 @@
fs = require 'fs'
path = require 'path'
async = require 'async'
module.exports = (grunt) ->
{spawn} = require('./task-helpers')(grunt)
grunt.registerTask 'run-specs', 'Run the specs', ->
passed = true
done = @async()
queue = async.queue (packagePath, callback) ->
options =
cmd: path.resolve('node_modules/.bin/apm')
args: ['test', '-p', path.resolve('atom.sh')]
opts:
cwd: packagePath
spawn options, (error, results, code) ->
passed = passed and code is 0
callback()
modulesDirectory = path.resolve('node_modules')
for packageDirectory in fs.readdirSync(modulesDirectory)
packagePath = path.join(modulesDirectory, packageDirectory)
continue unless grunt.file.isDir(path.join(packagePath, 'spec'))
try
{engines} = grunt.file.readJSON(path.join(packagePath, 'package.json')) ? {}
queue.push(packagePath) if engines.atom?
break
queue.concurrency = 1
queue.drain = -> done(passed)