diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-17 22:39:23 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-17 22:39:23 +0000 |
commit | e1cf85a22ed6ef28ba7db5d2108e3a48a306c507 (patch) | |
tree | a043133fbe5da9c6cd8c2d3c77d3d9665a39da81 | |
parent | 53b986553fe8d155692f27ebe12d98f8eadbb416 (diff) | |
download | chromium_src-e1cf85a22ed6ef28ba7db5d2108e3a48a306c507.zip chromium_src-e1cf85a22ed6ef28ba7db5d2108e3a48a306c507.tar.gz chromium_src-e1cf85a22ed6ef28ba7db5d2108e3a48a306c507.tar.bz2 |
Make content_browsertests support restarts across a test.
BUG=90448
Review URL: https://chromiumcodereview.appspot.com/10855231
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152174 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/base/chrome_test_launcher.cc | 20 | ||||
-rw-r--r-- | content/public/test/test_launcher.cc | 19 | ||||
-rw-r--r-- | content/public/test/test_launcher.h | 4 | ||||
-rw-r--r-- | content/shell/shell_browser_context.cc | 7 | ||||
-rw-r--r-- | content/shell/shell_switches.cc | 3 | ||||
-rw-r--r-- | content/shell/shell_switches.h | 1 | ||||
-rw-r--r-- | content/test/content_test_launcher.cc | 6 |
7 files changed, 35 insertions, 25 deletions
diff --git a/chrome/test/base/chrome_test_launcher.cc b/chrome/test/base/chrome_test_launcher.cc index 6318ef4..6f07e17 100644 --- a/chrome/test/base/chrome_test_launcher.cc +++ b/chrome/test/base/chrome_test_launcher.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "base/memory/linked_ptr.h" #include "base/run_loop.h" -#include "base/scoped_temp_dir.h" #include "base/test/test_file_util.h" #include "chrome/app/chrome_main_delegate.h" #include "chrome/common/chrome_switches.h" @@ -78,7 +77,7 @@ class ChromeTestLauncherDelegate : public test_launcher::TestLauncherDelegate { } virtual bool AdjustChildProcessCommandLine( - CommandLine* command_line) OVERRIDE { + CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE { CommandLine new_command_line(command_line->GetProgram()); CommandLine::SwitchMap switches = command_line->GetSwitches(); @@ -90,20 +89,7 @@ class ChromeTestLauncherDelegate : public test_launcher::TestLauncherDelegate { new_command_line.AppendSwitchNative((*iter).first, (*iter).second); } - // Clean up previous temp dir. - // We Take() the directory and delete it ourselves so that the next - // CreateUniqueTempDir will succeed even if deleting the directory fails. - if (!temp_dir_.path().empty() && - !file_util::DieFileDie(temp_dir_.Take(), true)) { - LOG(ERROR) << "Error deleting previous temp profile directory"; - } - - // Create a new user data dir and pass it to the child. - if (!temp_dir_.CreateUniqueTempDir() || !temp_dir_.IsValid()) { - LOG(ERROR) << "Error creating temp profile directory"; - return false; - } - new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_dir_.path()); + new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_data_dir); // file:// access for ChromeOS. new_command_line.AppendSwitch(switches::kAllowFileAccess); @@ -133,8 +119,6 @@ class ChromeTestLauncherDelegate : public test_launcher::TestLauncherDelegate { } private: - ScopedTempDir temp_dir_; - #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) std::stack<linked_ptr<views::AcceleratorHandler> > handlers_; #endif diff --git a/content/public/test/test_launcher.cc b/content/public/test/test_launcher.cc index 26e6a89e..1224461 100644 --- a/content/public/test/test_launcher.cc +++ b/content/public/test/test_launcher.cc @@ -61,6 +61,10 @@ const char kPreTestPrefix[] = "PRE_"; // add a new binary that must be compiled on all builds. const char kManualTestPrefix[] = "MANUAL_"; +// Tests with this suffix are expected to crash, so it won't count as a failure. +// A test that uses this must have a PRE_ prefix. +const char kCrashTestSuffix[] = "_CRASH"; + TestLauncherDelegate* g_launcher_delegate; } @@ -331,8 +335,10 @@ int RunTestInternal(const testing::TestCase* test_case, if (cur_test_name == pre_test_name) { int exit_code = RunTestInternal(test_case, pre_test_name, command_line, default_timeout, was_timeout); - if (exit_code != 0) + if (exit_code != 0 && + !EndsWith(pre_test_name, kCrashTestSuffix, true)) { return exit_code; + } } } } @@ -440,8 +446,17 @@ int RunTest(TestLauncherDelegate* launcher_delegate, // failure status back to the parent. new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); - if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line)) + ScopedTempDir temp_dir; + // Create a new data dir and pass it to the child. + if (!temp_dir.CreateUniqueTempDir() || !temp_dir.IsValid()) { + LOG(ERROR) << "Error creating temp data directory"; return -1; + } + + if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line, + temp_dir.path())) { + return -1; + } return RunTestInternal( test_case, test_name, &new_cmd_line, default_timeout, was_timeout); diff --git a/content/public/test/test_launcher.h b/content/public/test/test_launcher.h index 42a7aba..4efdb66 100644 --- a/content/public/test/test_launcher.h +++ b/content/public/test/test_launcher.h @@ -11,6 +11,7 @@ #include "base/compiler_specific.h" class CommandLine; +class FilePath; namespace base { class RunLoop; @@ -38,7 +39,8 @@ class TestLauncherDelegate { virtual std::string GetEmptyTestName() = 0; virtual bool Run(int argc, char** argv, int* return_code) = 0; virtual int RunTestSuite(int argc, char** argv) = 0; - virtual bool AdjustChildProcessCommandLine(CommandLine* command_line) = 0; + virtual bool AdjustChildProcessCommandLine(CommandLine* command_line, + const FilePath& temp_data_dir) = 0; virtual void PreRunMessageLoop(base::RunLoop* run_loop) {} virtual void PostRunMessageLoop() {} diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index dbde11a..e30d75f 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -41,12 +41,15 @@ ShellBrowserContext::~ShellBrowserContext() { void ShellBrowserContext::InitWhileIOAllowed() { CommandLine* cmd_line = CommandLine::ForCurrentProcess(); - if (cmd_line->HasSwitch(switches::kContentBrowserTest) || - cmd_line->HasSwitch(switches::kDumpRenderTree)) { + if (cmd_line->HasSwitch(switches::kDumpRenderTree)) { CHECK(testing_path_.CreateUniqueTempDir()); path_ = testing_path_.path(); return; } + if (cmd_line->HasSwitch(switches::kContentShellDataPath)) { + path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath); + return; + } #if defined(OS_WIN) CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); path_ = path_.Append(std::wstring(L"content_shell")); diff --git a/content/shell/shell_switches.cc b/content/shell/shell_switches.cc index 07daec5..09ca6f2 100644 --- a/content/shell/shell_switches.cc +++ b/content/shell/shell_switches.cc @@ -12,6 +12,9 @@ const char kCheckLayoutTestSysDeps[] = "check-layout-test-sys-deps"; // Tells Content Shell that it's running as a content_browsertest. const char kContentBrowserTest[] = "browser-test"; +// Makes Content Shell use the given path for its data directory. +const char kContentShellDataPath[] = "data-path"; + // Request pages to be dumped as text once they finished loading. const char kDumpRenderTree[] = "dump-render-tree"; diff --git a/content/shell/shell_switches.h b/content/shell/shell_switches.h index cbc2860..d07e06c 100644 --- a/content/shell/shell_switches.h +++ b/content/shell/shell_switches.h @@ -11,6 +11,7 @@ namespace switches { extern const char kCheckLayoutTestSysDeps[]; extern const char kContentBrowserTest[]; +extern const char kContentShellDataPath[]; extern const char kDumpRenderTree[]; extern const char kNoTimeout[]; diff --git a/content/test/content_test_launcher.cc b/content/test/content_test_launcher.cc index efa0c72..5ab1910 100644 --- a/content/test/content_test_launcher.cc +++ b/content/test/content_test_launcher.cc @@ -8,7 +8,6 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/scoped_temp_dir.h" #include "base/test/test_suite.h" #include "content/public/app/content_main.h" #include "content/public/common/content_switches.h" @@ -16,6 +15,7 @@ #include "content/shell/shell_content_browser_client.h" #include "content/shell/shell_content_client.h" #include "content/shell/shell_main_delegate.h" +#include "content/shell/shell_switches.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(OS_WIN) @@ -121,7 +121,9 @@ class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { } virtual bool AdjustChildProcessCommandLine( - CommandLine* command_line) OVERRIDE { + CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE { + command_line->AppendSwitchPath(switches::kContentShellDataPath, + temp_data_dir); return true; } |