<commit_before>/**
 * Module dependencies.
 */

var mocha = require('mocha')
var Base = mocha.reporters.Base
var color = Base.color;
var stackTrace = require('stack-trace');

/**
 * Expose `List`.
 */

exports = module.exports = List;

/**
 * Initialize a new `List` test reporter.
 *
 * @param {Runner} runner
 * @api public
 */

function List(runner) {
  Base.call(this, runner);

  var self = this
    , stats = this.stats
    , total = runner.total;

  runner.on('start', function(){
    console.log(JSON.stringify( ['start', { total: total }] ));
  });
  
  runner.on('test', function(test){
    console.log(JSON.stringify( ['test', info(test)] ));
  });  

  runner.on('pass', function(test){
    console.log(JSON.stringify( ['pass', pass(test)] ));
  });

  runner.on('fail', function(test, err){
    test = fail(test, err);
    console.log(JSON.stringify( ['fail', test] ));
  });  
  
  runner.on('test end', function(test){
    console.log(JSON.stringify( ['test end', {id:test.id}] ));
  });    

  runner.on('end', function(){
    process.stdout.write(JSON.stringify( ['end', self.stats] ));
  });
}

/**
 * Return a plain-object representation of `test`
 * free of cyclic properties etc.
 *
 * @param {Object} test
 * @return {Object}
 * @api private
 */

function info(test) {
  return {
     id: test.id,
     parentTitle: test.parent.fullTitle(),
     title: test.title,
     duration: test.duration
  }
}

function pass(test) {
  return {
     id: test.id,
     duration: test.duration
  }
}

function fail(test, err) {
  //console.log(err.stack)
  //console.log(err)
  //trace = stackTrace.parse(err)
  //console.log(trace[0])
  //console.log(trace[1])
  return {
     id: test.id,     
     duration: test.duration,
     error: err
  }
}<commit_msg>Adding suite information to the stream<commit_after>/**
 * Module dependencies.
 */

var mocha = require('mocha');
var Base = mocha.reporters.Base;
var color = Base.color;
var stackTrace = require('stack-trace');
var util = require('util');

/**
 * Expose `List`.
 */

exports = module.exports = List;

/**
 * Initialize a new `List` test reporter.
 *
 * @param {Runner} runner
 * @api public
 */

function List(runner) {
  Base.call(this, runner);

  var self = this;
  var stats = this.stats;
  var total = runner.total;

  runner.on('start', function(){
    console.log(JSON.stringify( ['start', { total: total }] ));
  });

  runner.on('suite', function(suite){
    if (suite.id != undefined) {
      console.log(JSON.stringify( ['suite', suite_info(suite)] ));
    }
  });

  runner.on('test', function(test){
    console.log(JSON.stringify( ['test', info(test)] ));
  });

  runner.on('pass', function(test){
    console.log(JSON.stringify( ['pass', pass(test)] ));
  });

  runner.on('fail', function(test, err){
    test = fail(test, err);
    console.log(JSON.stringify( ['fail', test] ));
  });

  runner.on('test end', function(test){
    console.log(JSON.stringify( ['test end', {id: test.id}] ));
  });

  runner.on('suite end', function(suite){
    if (suite.id != undefined) {
      console.log(JSON.stringify( ['suite end', {id: suite.id}] ));
    }
  });

  runner.on('end', function(){
    console.log(JSON.stringify( ['end', self.stats] ));
  });
}

/**
 * Return a plain-object representation of `test`
 * free of cyclic properties etc.
 *
 * @param {Object} test
 * @return {Object}
 * @api private
 */


function suite_info(suite) {
  return {
     id: suite.id,
     title: suite.title,
  }
}

function info(test) {
  return {
     id: test.id,
     suiteId: test.parent.id,
     title: test.title
  }
}

function pass(test) {
  return {
     id: test.id,
     duration: test.duration
  }
}

function fail(test, err) {
  //console.log(err.stack)
  //console.log(err)
  //trace = stackTrace.parse(err)
  //console.log(trace[0])
  //console.log(trace[1])
  return {
     id: test.id,
     duration: test.duration,
     error: err
  }
}
{'fraction_non_alphanumeric': 0.18807339449541285, 'fraction_numerical': 0.0010193679918450561, 'mean_word_length': 3.0885416666666665, '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': '3905735', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1344, 'n_words': 297}