From 85e21223cede24a1b68156fedd8ef59fe9f562e8 Mon Sep 17 00:00:00 2001
From: kirrg001 <katharina.irrgang@googlemail.com>
Date: Wed, 25 May 2016 08:02:23 +0200
Subject: [PATCH] improvement: run single test with mochacli

---
 Gruntfile.js | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/Gruntfile.js b/Gruntfile.js
index bdc56213eb..3b4fa3c564 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -18,7 +18,6 @@ var _              = require('lodash'),
     cwd            = process.cwd().replace(/( |\(|\))/g, escapeChar + '$1'),
     buildDirectory = path.resolve(cwd, '.build'),
     distDirectory  = path.resolve(cwd, '.dist'),
-    mochaPath      = path.resolve(cwd + '/node_modules/.bin/mocha'),
     emberPath      = path.resolve(cwd + '/core/client/node_modules/.bin/ember'),
 
     // ## Grunt configuration
@@ -208,7 +207,10 @@ var _              = require('lodash'),
                     src: [
                         'core/test/functional/module/**/*_spec.js'
                     ]
-                }
+                },
+
+                // #### Run single test (src is set dynamically, see grunt task 'test')
+                single: {}
             },
 
             // ### grunt-mocha-istanbul
@@ -289,12 +291,6 @@ var _              = require('lodash'),
                     }
                 },
 
-                test: {
-                    command: function (test) {
-                        return 'node ' + mochaPath  + ' --timeout=15000 --ui=bdd --reporter=spec --colors core/test/' + test;
-                    }
-                },
-
                 shrinkwrap: {
                     command: 'npm shrinkwrap'
                 },
@@ -501,7 +497,18 @@ var _              = require('lodash'),
                 grunt.fail.fatal('No test provided. `grunt test` expects a filename. e.g.: `grunt test:unit/apps_spec.js`. Did you mean `npm test` or `grunt validate`?');
             }
 
-            grunt.task.run('test-setup', 'shell:test:' + test);
+            test = 'core/test/' + test;
+
+            // CASE: execute folder
+            if (!test.match(/.js/)) {
+                test += '/**';
+            } else if (!fs.existsSync(test)) {
+                grunt.fail.fatal('This file does not exist!');
+            }
+
+            cfg.mochacli.single.src = [test];
+            grunt.initConfig(cfg);
+            grunt.task.run('test-setup', 'mochacli:single');
         });
 
         // ### Validate