From bd520e10ca2123a75d55e57ec0952801acd70da0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 4 Sep 2015 18:01:43 -0700 Subject: [PATCH] Add debug option to runtests Running `runtests` with `debug` will cause mocha to run in debug mode and break on the first line, enabling one to connect a debugger to the running tests and step through a test at their leisure. --- Jakefile.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index ea13cce6685..3ac2e8fad13 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -588,9 +588,10 @@ function deleteTemporaryProjectOutput() { } var testTimeout = 20000; -desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]'."); +desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]', debug=true."); task("runtests", ["tests", builtLocalDirectory], function() { cleanTestDirs(); + var debug = process.env.debug || process.env.d; host = "mocha" tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; @@ -613,7 +614,7 @@ task("runtests", ["tests", builtLocalDirectory], function() { reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter'; // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer - var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; + var cmd = host + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; console.log(cmd); exec(cmd, deleteTemporaryProjectOutput); }, {async: true});