<commit_before>var blackbox = require('./utils/blackbox');
var path = require('path');

// The test function will run your unit tests in a sandboxed
// environment. It takes 3 parameters.
//
// * __fileName__ is the file name of the runner
// * __sandbox__ is an optional sandbox to use to run the tests in
// * __cb__ is what's called after tests are completed
function test(fileName, sandbox, cb) {
  var file = path.join(process.cwd(), fileName);
  var exported = blackbox(file, sandbox);
  if (typeof exported !== 'function') {
    throw new TypeError('Expected a function and instead received ' + typeof exported);
  } else {
    return exported(cb);
  }
}

// export to koala
module.exports = test;
<commit_msg>Favor vows<commit_after>var blackbox = require('./utils/blackbox');
var path = require('path');

// The test function will run your unit tests in a sandboxed
// environment. It takes 3 parameters.
//
// * __fileName__ is the file name of the runner
// * __sandbox__ is an optional sandbox to use to run the tests in
// * __cb__ is what's called after tests are completed
function test(fileName, sandbox, cb) {
  var file = path.join(process.cwd(), fileName);
  var exported = blackbox(file, sandbox);

  // Favor vows
  if (typeof exported === 'object') {
    Object.keys(exported).forEach(function (k) {
      var t = exported[k];
      if (t.run) {
        // TODO add tasks
        t.run(null, function (results) {
          cb(results.broken || results.errored);
        });
      }
    });

    return;
  }
  
  // not vows, can be a Function.
  if (typeof exported !== 'function') {
    throw new TypeError('Expected a function and instead received ' + typeof exported);
  } else {
    return exported(cb);
  }
}

// export to koala
module.exports = test;

{'fraction_non_alphanumeric': 0.12141652613827993, 'fraction_numerical': 0.0011242270938729624, 'mean_word_length': 3.1013824884792625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '166905', 'n_tokens_mistral': 542, 'n_tokens_neox': 527, 'n_words': 197}