Commit caa25d80 authored by jam@chromium.org's avatar jam@chromium.org

Add a MANUAL_ prefix for browser tests. These tests don't run unless --run-manual is specified.

This is helpful so that instead of adding new binaries for each different test suite that runs on its own bots (and so increading build times), we can still keep the tests in the same binaries. Instead, the specific bots would add --run-manual and can pass the test suite names as a command line flag.
Review URL: https://chromiumcodereview.appspot.com/10825311

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151212 0039d316-1c4b-4281-b951-d872f2087c98
parent 32392e97
...@@ -27,6 +27,7 @@ extern const char kGTestRunDisabledTestsFlag[]; ...@@ -27,6 +27,7 @@ extern const char kGTestRunDisabledTestsFlag[];
extern const char kGTestOutputFlag[]; extern const char kGTestOutputFlag[];
extern const char kSingleProcessTestsFlag[]; extern const char kSingleProcessTestsFlag[];
extern const char kSingleProcessTestsAndChromeFlag[]; extern const char kSingleProcessTestsAndChromeFlag[];
extern const char kRunManualTestsFlag[];
extern const char kHelpFlag[]; extern const char kHelpFlag[];
// Flag that causes only the kEmptyTestName test to be run. // Flag that causes only the kEmptyTestName test to be run.
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
namespace content { namespace content {
IN_PROC_BROWSER_TEST_F(ContentBrowserTest, MANUAL_ShouldntRun) {
// Ensures that tests with MANUAL_ prefix don't run automatically.
ASSERT_TRUE(false);
}
ContentBrowserTest::ContentBrowserTest() { ContentBrowserTest::ContentBrowserTest() {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// See comment in InProcessBrowserTest::InProcessBrowserTest(). // See comment in InProcessBrowserTest::InProcessBrowserTest().
......
...@@ -41,6 +41,26 @@ ...@@ -41,6 +41,26 @@
namespace test_launcher { namespace test_launcher {
namespace { namespace {
// A multiplier for slow tests. We generally avoid multiplying
// test timeouts by any constants. Here it is used as last resort
// to implement the SLOW_ test prefix.
const int kSlowTestTimeoutMultiplier = 5;
// Tests with this prefix have a longer timeout, see above.
const char kSlowTestPrefix[] = "SLOW_";
// Tests with this prefix run before the same test without it, and use the same
// profile. i.e. Foo.PRE_Test runs and then Foo.Test. This allows writing tests
// that span browser restarts.
const char kPreTestPrefix[] = "PRE_";
// Manual tests only run when --run-manual is specified. This allows writing
// tests that don't run automatically but are still in the same test binary.
// This is useful so that a team that wants to run a few tests doesn't have to
// add a new binary that must be compiled on all builds.
const char kManualTestPrefix[] = "MANUAL_";
TestLauncherDelegate* g_launcher_delegate; TestLauncherDelegate* g_launcher_delegate;
} }
...@@ -281,11 +301,6 @@ bool MatchesFilter(const std::string& name, const std::string& filter) { ...@@ -281,11 +301,6 @@ bool MatchesFilter(const std::string& name, const std::string& filter) {
} }
} }
// A multiplier for slow tests. We generally avoid multiplying
// test timeouts by any constants. Here it is used as last resort
// to implement the SLOW_ test prefix.
static const int kSlowTestTimeoutMultiplier = 5;
base::TimeDelta GetTestTerminationTimeout(const std::string& test_name, base::TimeDelta GetTestTerminationTimeout(const std::string& test_name,
base::TimeDelta default_timeout) { base::TimeDelta default_timeout) {
base::TimeDelta timeout = default_timeout; base::TimeDelta timeout = default_timeout;
...@@ -293,7 +308,7 @@ base::TimeDelta GetTestTerminationTimeout(const std::string& test_name, ...@@ -293,7 +308,7 @@ base::TimeDelta GetTestTerminationTimeout(const std::string& test_name,
// Make it possible for selected tests to request a longer timeout. // Make it possible for selected tests to request a longer timeout.
// Generally tests should really avoid doing too much, and splitting // Generally tests should really avoid doing too much, and splitting
// a test instead of using SLOW prefix is strongly preferred. // a test instead of using SLOW prefix is strongly preferred.
if (test_name.find("SLOW_") != std::string::npos) if (test_name.find(kSlowTestPrefix) != std::string::npos)
timeout *= kSlowTestTimeoutMultiplier; timeout *= kSlowTestTimeoutMultiplier;
return timeout; return timeout;
...@@ -306,7 +321,8 @@ int RunTestInternal(const testing::TestCase* test_case, ...@@ -306,7 +321,8 @@ int RunTestInternal(const testing::TestCase* test_case,
bool* was_timeout) { bool* was_timeout) {
if (test_case) { if (test_case) {
std::string pre_test_name = test_name; std::string pre_test_name = test_name;
ReplaceFirstSubstringAfterOffset(&pre_test_name, 0, ".", ".PRE_"); std::string replace_string = std::string(".") + kPreTestPrefix;
ReplaceFirstSubstringAfterOffset(&pre_test_name, 0, ".", replace_string);
for (int i = 0; i < test_case->total_test_count(); ++i) { for (int i = 0; i < test_case->total_test_count(); ++i) {
const testing::TestInfo* test_info = test_case->GetTestInfo(i); const testing::TestInfo* test_info = test_case->GetTestInfo(i);
std::string cur_test_name = test_info->test_case_name(); std::string cur_test_name = test_info->test_case_name();
...@@ -483,8 +499,13 @@ bool RunTests(TestLauncherDelegate* launcher_delegate, ...@@ -483,8 +499,13 @@ bool RunTests(TestLauncherDelegate* launcher_delegate,
continue; continue;
} }
if (StartsWithASCII(test_info->name(), "PRE_", true)) if (StartsWithASCII(test_info->name(), kPreTestPrefix, true))
continue;
if (StartsWithASCII(test_info->name(), kManualTestPrefix, true) &&
!command_line->HasSwitch(kRunManualTestsFlag)) {
continue; continue;
}
// Skip the test that doesn't match the filter string (if given). // Skip the test that doesn't match the filter string (if given).
if ((!positive_filter.empty() && if ((!positive_filter.empty() &&
...@@ -595,6 +616,10 @@ const char kGTestOutputFlag[] = "gtest_output"; ...@@ -595,6 +616,10 @@ const char kGTestOutputFlag[] = "gtest_output";
const char kSingleProcessTestsFlag[] = "single_process"; const char kSingleProcessTestsFlag[] = "single_process";
const char kSingleProcessTestsAndChromeFlag[] = "single-process"; const char kSingleProcessTestsAndChromeFlag[] = "single-process";
// See kManualTestPrefix above.
const char kRunManualTestsFlag[] = "run-manual";
// The following is kept for historical reasons (so people that are used to // The following is kept for historical reasons (so people that are used to
// using it don't get surprised). // using it don't get surprised).
const char kChildProcessFlag[] = "child"; const char kChildProcessFlag[] = "child";
......
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