<commit_before>/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/

"use strict";
import * as fs from "fs";
import * as glob from "glob";
import * as istanbul from "istanbul";
import * as Mocha from "mocha";
import * as paths from "path";

// tslint:disable-next-line:no-var-requires
const remapIstanbul = require("remap-istanbul");

declare var global: {
  [key: string]: any; // missing index defintion
};

// Linux: prevent a weird NPE when mocha on Linux requires the window size from the TTY
// Since we are not running in a tty environment, we just implementt he method statically
// tslint:disable-next-line:no-var-requires
const tty = require("tty");
if (!tty.getWindowSize) {
  tty.getWindowSize = function(): number[] {
    return [80, 75];
  };
}

let mocha = new Mocha({
  ui: "tdd",
  useColors: true
});

let testOptions: any;

export function configure(mochaOpts: Mocha.MochaOptions, testOpts: any): void {
  mocha = new Mocha(mochaOpts);
  testOptions = testOpts;
}

function _mkDirIfExists(dir: string): void {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir);
  }
}<commit_msg>test: Fixed Mocha deprecated warning (#520)<commit_after>/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/

"use strict";
import * as fs from "fs";
import * as glob from "glob";
import * as istanbul from "istanbul";
import * as Mocha from "mocha";
import * as paths from "path";

// tslint:disable-next-line:no-var-requires
const remapIstanbul = require("remap-istanbul");

declare var global: {
  [key: string]: any; // missing index defintion
};

// Linux: prevent a weird NPE when mocha on Linux requires the window size from the TTY
// Since we are not running in a tty environment, we just implementt he method statically
// tslint:disable-next-line:no-var-requires
const tty = require("tty");
if (!tty.getWindowSize) {
  tty.getWindowSize = function(): number[] {
    return [80, 75];
  };
}

let mocha = new Mocha({
  ui: "tdd"
});

let testOptions: any;

export function configure(mochaOpts: Mocha.MochaOptions, testOpts: any): void {
  // For Mocha >= 6.0.0, `useColors` is deprecated
  const color = mochaOpts.useColors || (<any>mochaOpts).color || false;
  delete mochaOpts.useColors;

  mocha = new Mocha(mochaOpts);
  mocha.useColors(color);
  testOptions = testOpts;
}

function _mkDirIfExists(dir: string): void {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir);
  }
}
{'fraction_non_alphanumeric': 0.20831758034026465, 'fraction_numerical': 0.005293005671077505, 'mean_word_length': 2.8126801152737753, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '6621836', 'n_tokens_mistral': 848, 'n_tokens_neox': 815, 'n_words': 259}