fcs
2025-04-10 0163870d662dc5b7d69ceff977490ede594f7d82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
 
const { readdirSync } = require('fs');
const { spawnSync } = require('child_process');
const path = require('path');
 
let benchmarks = [];
 
if (!!process.env.npm_config_benchmarks) {
  benchmarks = process.env.npm_config_benchmarks
    .split(';')
    .map((item) => (item + '.js'));
}
 
// Run each file in this directory or the list given on the command line except
// index.js as a Node.js process.
(benchmarks.length > 0 ? benchmarks : readdirSync(__dirname))
  .filter((item) => (item !== 'index.js' && item.match(/\.js$/)))
  .map((item) => path.join(__dirname, item))
  .forEach((item) => {
    const child = spawnSync(process.execPath, [
      '--expose-gc',
      item
    ], { stdio: 'inherit' });
    if (child.signal) {
      console.error(`Tests aborted with ${child.signal}`);
      process.exitCode = 1;
    } else {
      process.exitCode = child.status;
    }
    if (child.status !== 0) {
      process.exit(process.exitCode);
    }
  });