@@ -19,6 +19,7 @@ var QUnit,
1919 map : require ( "lodash.map" ) ,
2020 each : require ( "lodash.foreach" ) ,
2121 bind : require ( "lodash.bind" ) ,
22+ without : require ( "lodash.without" ) ,
2223 extend : require ( "lodash.assignin" )
2324 } ,
2425 childProcess = require ( "child_process" ) ,
@@ -34,18 +35,6 @@ var QUnit,
3435 return QUnit ;
3536 } ;
3637
37- function havePromises ( ) {
38- var nodeVersion = _ . map (
39- process . versions . node . split ( "." ) ,
40- function ( item ) {
41- return + item ;
42- } ) ;
43-
44- return ( nodeVersion . length > 1 &&
45- ( nodeVersion [ 0 ] > 0 ||
46- nodeVersion [ 0 ] === 0 && nodeVersion [ 1 ] > 11 ) ) ;
47- }
48-
4938// Spawn a single child and process its stdout.
5039function spawnOne ( assert , options ) {
5140 var theChild ;
@@ -270,12 +259,27 @@ function runTestSuites( files ) {
270259}
271260
272261// Run tests. If no tests were specified on the command line, we scan the tests directory and run
273- // all the tests we find therein.
274- runTestSuites ( ( ( process . argv . length > 3 ) ?
275- ( _ . map ( process . argv [ 3 ] . split ( "," ) , function ( item ) {
262+ // all the tests we find therein. If the command line starts with a "!", we subtract from the
263+ // contents of the tests/ the list specified on the command line.
264+ runTestSuites ( ( function assembleTestList ( inSubdirectory ) {
265+ return ( process . argv . length > 3 ) ?
266+ ( process . argv [ 3 ] . substr ( 0 , 1 ) === "!" ) ?
267+
268+ // Test list was given and starts with a "!" - subtract tests from list.
269+ _ . without . apply ( _ ,
270+ [ inSubdirectory ] . concat ( process . argv [ 3 ] . substr ( 1 ) . split ( "," ) ) ) :
271+
272+ // Test list was given and does not start with a "!" - use.
273+ process . argv [ 3 ] . split ( "," ) :
274+
275+ // Test list was not given - use subdirectory contents.
276+ inSubdirectory ;
277+ } ) ( fs . readdirSync ( path . join ( __dirname , "tests" ) ) )
278+
279+ // Convert test list to list of absolute paths to the test directories.
280+ . map ( function ( item ) {
276281 return path . join ( __dirname , "tests" , item ) ;
277- } ) ) :
278- ( glob . sync ( path . join ( __dirname , "tests" , ( havePromises ( ) ? "" : "!(API)" ) + "*" ) ) ) ) ) ;
282+ } ) ) ;
279283
280284process . on ( "exit" , function ( ) {
281285 var childIndex ;
0 commit comments