Commit 2b121025 authored by Chong Zhang's avatar Chong Zhang Committed by Commit Bot

TestLauncher: Support multiple filter files

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 <chongz@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590513}
parent eccfdf3b
...@@ -948,12 +948,18 @@ bool TestLauncher::Init() { ...@@ -948,12 +948,18 @@ bool TestLauncher::Init() {
std::vector<std::string> positive_gtest_filter; std::vector<std::string> positive_gtest_filter;
if (command_line->HasSwitch(switches::kTestLauncherFilterFile)) { if (command_line->HasSwitch(switches::kTestLauncherFilterFile)) {
base::FilePath filter_file_path = base::MakeAbsoluteFilePath( auto filter =
command_line->GetSwitchValuePath(switches::kTestLauncherFilterFile)); 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, if (!LoadFilterFile(filter_file_path, &positive_file_filter,
&negative_test_filter_)) &negative_test_filter_))
return false; return false;
} }
}
// Split --gtest_filter at '-', if there is one, to separate into // Split --gtest_filter at '-', if there is one, to separate into
// positive filter and negative filter portions. // positive filter and negative filter portions.
......
...@@ -76,6 +76,7 @@ void PrintUsage() { ...@@ -76,6 +76,7 @@ void PrintUsage() {
" Other flags:\n" " Other flags:\n"
" --test-launcher-filter-file=PATH\n" " --test-launcher-filter-file=PATH\n"
" Like --gtest_filter, but read the test filter from 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" " One pattern per line; lines starting with '-' are exclusions.\n"
" See also //testing/buildbot/filters/README.md file.\n" " See also //testing/buildbot/filters/README.md file.\n"
"\n" "\n"
......
...@@ -23,7 +23,8 @@ const char switches::kTestLauncherDebugLauncher[] = ...@@ -23,7 +23,8 @@ const char switches::kTestLauncherDebugLauncher[] =
const char switches::kTestLauncherForceRunBrokenTests[] = const char switches::kTestLauncherForceRunBrokenTests[] =
"test-launcher-force-run-broken-tests"; "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"; const char switches::kTestLauncherFilterFile[] = "test-launcher-filter-file";
// Whether the test launcher should launch in "interactive mode", which disables // Whether the test launcher should launch in "interactive mode", which disables
......
...@@ -45,13 +45,22 @@ Example test filter file for excluding a set of tests: ...@@ -45,13 +45,22 @@ Example test filter file for excluding a set of tests:
## Usage ## Usage
When running tests on desktop platforms, the test filter file can be specified 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 ```bash
$ out/dbg/content_browsertests \ $ out/dbg/content_browsertests \
--test-launcher-filter-file=testing/buildbot/filters/foo.content_browsertests.filter --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 When running tests on Android, the test filter file can also be specified using
`--test-launcher-filter-file` command line flag. Example test invocation: `--test-launcher-filter-file` command line flag. Example test invocation:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment