-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
/
Copy pathtest-benchmark-cli.js
38 lines (25 loc) · 1.18 KB
/
test-benchmark-cli.js
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
35
36
37
38
'use strict';
require('../common');
// This tests the CLI parser for our benchmark suite.
const assert = require('assert');
const CLI = require('../../benchmark/_cli.js');
const originalArgv = process.argv;
function testFilterPattern(filters, excludes, filename, expectedResult) {
process.argv = process.argv.concat(...filters.map((p) => ['--filter', p]));
process.argv = process.argv.concat(...excludes.map((p) => ['--exclude', p]));
process.argv = process.argv.concat(['bench']);
const cli = new CLI('', { 'arrayArgs': ['filter', 'exclude'] });
assert.deepStrictEqual(cli.shouldSkip(filename), expectedResult);
process.argv = originalArgv;
}
testFilterPattern([], [], 'foo', false);
testFilterPattern(['foo'], [], 'foo', false);
testFilterPattern(['foo'], [], 'bar', true);
testFilterPattern(['foo', 'bar'], [], 'foo', false);
testFilterPattern(['foo', 'bar'], [], 'bar', false);
testFilterPattern([], ['foo'], 'foo', true);
testFilterPattern([], ['foo'], 'bar', false);
testFilterPattern([], ['foo', 'bar'], 'foo', true);
testFilterPattern([], ['foo', 'bar'], 'bar', true);
testFilterPattern(['foo'], ['bar'], 'foo', false);
testFilterPattern(['foo'], ['bar'], 'foo-bar', true);