grunt qunit: Don't break in JSON.parse when debug output is generated while running...
authorAndreas Lind <andreas@one.com>
Mon, 22 May 2017 07:17:18 +0000 (09:17 +0200)
committerAndreas Lind <andreas@one.com>
Mon, 22 May 2017 07:17:18 +0000 (09:17 +0200)
Gruntfile.js

index caf4790..6bdbfb4 100644 (file)
@@ -141,7 +141,15 @@ module.exports = function(grunt) {
           errors.push(-1);
         }
         else {
-          errors.push(report(testType, JSON.parse(result.stdout)));
+          var output = result.stdout;
+          var index = output.lastIndexOf('\n');
+          if (index !== -1) {
+            // There's something before the report JSON
+            // Log it to the console -- it's probably some debug output:
+            console.log(output.slice(0, index));
+            output = output.slice(index);
+          }
+          errors.push(report(testType, JSON.parse(output)));
         }
         if (errors.length === 2) {
           done(!errors[0] && !errors[1]);