Skip to content

Commit

Permalink
TestLauncher: Support multiple filter files
Browse files Browse the repository at this point in the history
Make --test-launcher-filter-file support multiple filter files separated
by ';'.

Bug: 881438
Change-Id: Ibe17d1e8443cbb490a2d1b8942bb003c96a79525
Reviewed-on: https://chromium-review.googlesource.com/1213866
Commit-Queue: Chong Zhang <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Kenneth Russell <[email protected]>
Cr-Commit-Position: refs/heads/master@{#590513}
  • Loading branch information
Chong Zhang authored and Commit Bot committed Sep 11, 2018
1 parent eccfdf3 commit 2b12102
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
16 changes: 11 additions & 5 deletions base/test/launcher/test_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,17 @@ bool TestLauncher::Init() {
std::vector<std::string> positive_gtest_filter;

if (command_line->HasSwitch(switches::kTestLauncherFilterFile)) {
base::FilePath filter_file_path = base::MakeAbsoluteFilePath(
command_line->GetSwitchValuePath(switches::kTestLauncherFilterFile));
if (!LoadFilterFile(filter_file_path, &positive_file_filter,
&negative_test_filter_))
return false;
auto filter =
command_line->GetSwitchValueNative(switches::kTestLauncherFilterFile);
for (auto filter_file :
SplitString(filter, FILE_PATH_LITERAL(";"), base::TRIM_WHITESPACE,
base::SPLIT_WANT_ALL)) {
base::FilePath filter_file_path =
base::MakeAbsoluteFilePath(FilePath(filter_file));
if (!LoadFilterFile(filter_file_path, &positive_file_filter,
&negative_test_filter_))
return false;
}
}

// Split --gtest_filter at '-', if there is one, to separate into
Expand Down
1 change: 1 addition & 0 deletions base/test/launcher/unit_test_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void PrintUsage() {
" Other flags:\n"
" --test-launcher-filter-file=PATH\n"
" Like --gtest_filter, but read the test filter from PATH.\n"
" Supports multiple filter paths separated by ';'.\n"
" One pattern per line; lines starting with '-' are exclusions.\n"
" See also //testing/buildbot/filters/README.md file.\n"
"\n"
Expand Down
3 changes: 2 additions & 1 deletion base/test/test_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const char switches::kTestLauncherDebugLauncher[] =
const char switches::kTestLauncherForceRunBrokenTests[] =
"test-launcher-force-run-broken-tests";

// Path to file containing test filter (one pattern per line).
// List of paths to files (separated by ';') containing test filters (one
// pattern per line).
const char switches::kTestLauncherFilterFile[] = "test-launcher-filter-file";

// Whether the test launcher should launch in "interactive mode", which disables
Expand Down
11 changes: 10 additions & 1 deletion testing/buildbot/filters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@ Example test filter file for excluding a set of tests:
## Usage

When running tests on desktop platforms, the test filter file can be specified
using `--test-launcher-filter-file` command line flag. Example test invocation:
using `--test-launcher-filter-file` command line flag. Example test invocation
(single filter file):

```bash
$ out/dbg/content_browsertests \
--test-launcher-filter-file=testing/buildbot/filters/foo.content_browsertests.filter
```

Example test invocation (multiple filter files, separated by ';'):

```bash
$ out/dbg/content_browsertests \
--test-launcher-filter-file=testing/buildbot/filters/foo.content_browsertests.filter;\
testing/buildbot/filters/foo.chromeos.content_browsertests.filter
```

When running tests on Android, the test filter file can also be specified using
`--test-launcher-filter-file` command line flag. Example test invocation:

Expand Down

0 comments on commit 2b12102

Please sign in to comment.