-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
benchmark: improve
--filter
pattern matching
* Let users provide more than one pattern by repeating the flag * Add new flag --exclude to exclude patterns * Add tests for --filter * Document --filter This commit also fixes a bug where things like `compare.js --new --old binary --new binary` was acceptable (now the script will exit and print the usage message). PR-URL: #29987 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
Showing
5 changed files
with
152 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); |