From 04a909369d3275c83183c18e9b34a26c91798782 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 21 Oct 2015 11:21:52 -0400 Subject: [PATCH] Allow nodeunit:just:[array,of,test,files] --- Gruntfile.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0151e00b3..ea469474e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -127,12 +127,29 @@ module.exports = function(grunt) { // Support running a single test suite: // grunt nodeunit:just:motor for example - grunt.registerTask("nodeunit:just", "Run a single test specified by a target; usage: \"grunt nodeunit:just:[.js]\"", function(file) { + grunt.registerTask("nodeunit:just", "Run a single or limited set of tests specified by a target; usage: 'grunt nodeunit:just:test-file' or 'grunt nodeunit:just:[test-file-a,test-file-b]'", function(file) { + + var config = [ + "test/bootstrap/*.js", + ]; + if (file) { - grunt.config("nodeunit.tests", [ - "test/bootstrap/*.js", - "test/" + file + ".js", - ]); + var files = [file]; + + // + // grunt nodeunit:just:[test-file-a,test-file-b] + // + if (file[0] === "[" && file[file.length - 1] === "]") { + files = file.match(/(\w+)/g); + } + + if (files) { + files.forEach(function(file) { + config.push("test/" + file + ".js"); + }); + + grunt.config("nodeunit.tests", config); + } } grunt.task.run("nodeunit");