How to use the threads.config.set function in threads

To help you get started, we’ve selected a few threads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TypeScriptToLua / TypeScriptToLua / test / threaded_runner.ts View on Github external
function fileArrToString(fileArr: string[]): string {
    return fileArr.map(val => path.basename(val).replace(".spec.js", "")).join(", ");
}

function printTestStats(testCount: number, failedTestCount: number, header: string, footer: string): void {
    console.log("-----------------");
    console.log(header);
    console.log(`Total:  ${testCount}`);
    console.log(`Passed: ${testCount - failedTestCount}`);
    console.log(`Failed: ${failedTestCount}`);
    console.log(footer);
    console.log("-----------------");
}

config.set({
  basepath: {
    node: __dirname,
  }
});

let cpuCount = os.cpus().length + 1;
if ("TRAVIS" in process.env && "CI" in process.env) {
    // fixed thread count for CI
    cpuCount = 8;
}
const testFiles: string[] = glob.sync("./test/**/*.spec.js");
const pool = new Pool(cpuCount);
let jobCounter = 0;
const testStartTime = new Date();
const fileCount = testFiles.length;
let exitWithError = false;