<commit_before>'use strict'
const fs = require('fs')
const { promisify } = require('util')
const { join } = require('path')
const { error } = require('./support/mute')

// we want to explicity run the test in order of complexity
// not their alphabetical order 
const defaultTests = ['login', 'user', 'rat', 'rescue', 'stats']

const START_OF_ARGS = 2
const args = (process.ARGV || process.argv).slice(START_OF_ARGS)

const options = {
  error_prefix: '\u001B[31m',
  error_suffix: '\u001B[39m',
  ok_prefix: '\u001B[32m',
  ok_suffix: '\u001B[39m',
  bold_prefix: '\u001B[1m',
  bold_suffix: '\u001B[22m',
  assertion_prefix: '\u001B[35m',
  assertion_suffix: '\u001B[39m',
  mute: true
}

/**
 * run against all the files/dirs defined in tests
 * @returns {Promise.<void>}
 */
async function start () {

  try {

    let tests

    if (args.length) {
      // must have specified what we want to run
      tests = [ args.shift() ]
      options.testspec = args.shift()
      // unmumte if we have specified a single test to run
      options.mute = !options.testspec
    } else {
      // just run the default tests
      tests = defaultTests
    }

    const reporter = require('./support/reporter')
    const run = promisify(reporter.run)
    await run(tests.map((test) => {
      // check if the files exist
      const file = join(__dirname, test + '.js')
      if (fs.existsSync(file)) {
        return file<commit_msg>abort tests with unhandled promise rejection<commit_after>'use strict'
const fs = require('fs')
const { promisify } = require('util')
const { join } = require('path')
const { error } = require('./support/mute')

// we want to explicity run the test in order of complexity
// not their alphabetical order 
const defaultTests = ['login', 'user', 'rat', 'rescue', 'stats']

const START_OF_ARGS = 2
const args = (process.ARGV || process.argv).slice(START_OF_ARGS)

const options = {
  error_prefix: '\u001B[31m',
  error_suffix: '\u001B[39m',
  ok_prefix: '\u001B[32m',
  ok_suffix: '\u001B[39m',
  bold_prefix: '\u001B[1m',
  bold_suffix: '\u001B[22m',
  assertion_prefix: '\u001B[35m',
  assertion_suffix: '\u001B[39m',
  mute: true
}

process.on('unhandledRejection', err => {
  error('unhandledRejection' + err.message + '\n' + err.stack)
  process.exit(1)
})

/**
 * run against all the files/dirs defined in tests
 * @returns {Promise.<void>}
 */
async function start () {

  try {

    let tests

    if (args.length) {
      // must have specified what we want to run
      tests = [ args.shift() ]
      options.testspec = args.shift()
      // unmumte if we have specified a single test to run
      options.mute = !options.testspec
    } else {
      // just run the default tests
      tests = defaultTests
    }

    const reporter = require('./support/reporter')
    const run = promisify(reporter.run)
    await run(tests.map((test) => {
      // check if the files exist
      const file = join(__dirname, test + '.js')
      if (fs.existsSync(file)) {
        return file
{'fraction_non_alphanumeric': 0.14186046511627906, 'fraction_numerical': 0.026910299003322258, 'mean_word_length': 3.107776261937244, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '4687900', 'n_tokens_mistral': 1059, 'n_tokens_neox': 992, 'n_words': 281}