<commit_before>var runner = require('run-qunit')

var createResultsHandler = function(ctx){
  return function(res){
    console.log("strider-qunit > Results:", res);
    ctx.events.emit('testDone', res);
  }
}


module.exports = function(ctx, cb) {

    ctx.addDetectionRule({
            filename: "test/index.html"
          , grep: /qunit/gi
          , exists: true
          , language: "javascript"
          , framework: "qunit"
          , prepare: function(ctx, cb){

              if (!ctx.events){
                throw "strider-qunit requires a worker with events bus - is your strider-simple-worker out of date?"
              }

              var cgi = require('gateway')(ctx.workingDir, {'.php': 'php-cgi'})

              var cgiwrap = function(){
                console.log("!!! -> CGI: ", req.url)
                return cgi.apply(this, arguments);
              }

              var opts = {
                // TODO use path() for :
                testfile : ctx.workingDir + '/test/index.html' // TODO override from db
              , testdir: ctx.workingDir  // TODO overide from DB
              , port: 4000
              , path: ctx.workingDir
              , useID : true
              , middleware : [cgi]
              }


             ctx.striderMessage("Setting up qunit server");
             ctx.browsertestPort =  opts.port;
             ctx.browsertestPath = "/test/index.html" //TODO overwrite from DB

             // TEMP TODO
             require('child_process').exec("grunt || (npm install && grunt)", {cwd: ctx.workingDir}, function(err, stdout, stderr){ 
               console.log("Grunt finished")

               runner.start(opts, createResultsHandler(ctx), function(){
                 ctx.striderMessage("Strider-QUnit Runner Started");
                 cb(0)
               });
             });


           }

          , test: function(){
            // Do NOTHING
            // Either a cloud browser, or a manual one
            // will connect and run the tests.
            // Because they might want to run more than one 
            // browser, we leave the server running for them.
          }

          , cleanup: function(){
            if (runner.open()){
              runner.close()
            }
          }
        })

  console.log("strider-qunit extension loaded")
  cb(null, null);
}
<commit_msg>need to call the callbacks or we'll hang<commit_after>var runner = require('run-qunit')

var createResultsHandler = function(ctx){
  return function(res){
    console.log("strider-qunit > Results:", res);
    ctx.events.emit('testDone', res);
  }
}


module.exports = function(ctx, cb) {

    ctx.addDetectionRule({
            filename: "test/index.html"
          , grep: /qunit/gi
          , exists: true
          , language: "javascript"
          , framework: "qunit"
          , prepare: function(ctx, cb){

              if (!ctx.events){
                throw "strider-qunit requires a worker with events bus - is your strider-simple-worker out of date?"
              }

              var cgi = require('gateway')(ctx.workingDir, {'.php': 'php-cgi'})

              var cgiwrap = function(){
                console.log("!!! -> CGI: ", req.url)
                return cgi.apply(this, arguments);
              }

              var opts = {
                // TODO use path() for :
                testfile : ctx.workingDir + '/test/index.html' // TODO override from db
              , testdir: ctx.workingDir  // TODO overide from DB
              , port: 4000
              , path: ctx.workingDir
              , useID : true
              , middleware : [cgi]
              }


             ctx.striderMessage("Setting up qunit server");
             ctx.browsertestPort =  opts.port;
             ctx.browsertestPath = "/test/index.html" //TODO overwrite from DB

             // TEMP TODO
             require('child_process').exec("grunt || (npm install && grunt)", {cwd: ctx.workingDir}, function(err, stdout, stderr){ 
               console.log("Grunt finished")

               runner.start(opts, createResultsHandler(ctx), function(){
                 ctx.striderMessage("Strider-QUnit Runner Started");
                 cb(0)
               });
             });


           }

           , cleanup: function(ctx, cb){
            if (runner.open()){
              runner.close()
            }
            cb(0)
          }
        })

  console.log("strider-qunit extension loaded")
  cb(null, null);
}

{'fraction_non_alphanumeric': 0.12241264188738037, 'fraction_numerical': 0.0024482528377476075, 'mean_word_length': 1.5092127303182579, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1481678', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1189, 'n_words': 302}