• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3require('../common');
4
5// This tests the CLI parser for our benchmark suite.
6
7const assert = require('assert');
8
9const CLI = require('../../benchmark/_cli.js');
10
11const originalArgv = process.argv;
12
13function testFilterPattern(filters, excludes, filename, expectedResult) {
14  process.argv = process.argv.concat(...filters.map((p) => ['--filter', p]));
15  process.argv = process.argv.concat(...excludes.map((p) => ['--exclude', p]));
16  process.argv = process.argv.concat(['bench']);
17
18  const cli = new CLI('', { 'arrayArgs': ['filter', 'exclude'] });
19  assert.deepStrictEqual(cli.shouldSkip(filename), expectedResult);
20
21  process.argv = originalArgv;
22}
23
24
25testFilterPattern([], [], 'foo', false);
26
27testFilterPattern(['foo'], [], 'foo', false);
28testFilterPattern(['foo'], [], 'bar', true);
29testFilterPattern(['foo', 'bar'], [], 'foo', false);
30testFilterPattern(['foo', 'bar'], [], 'bar', false);
31
32testFilterPattern([], ['foo'], 'foo', true);
33testFilterPattern([], ['foo'], 'bar', false);
34testFilterPattern([], ['foo', 'bar'], 'foo', true);
35testFilterPattern([], ['foo', 'bar'], 'bar', true);
36
37testFilterPattern(['foo'], ['bar'], 'foo', false);
38testFilterPattern(['foo'], ['bar'], 'foo-bar', true);
39