Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: net/test/test_server.cc

Issue 9545019: Add "run_testserver --sync-test" for easy chromiumsync_test.py launching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/test/test_server.h ('k') | net/test/test_server_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/test_server.cc
diff --git a/net/test/test_server.cc b/net/test/test_server.cc
index f38abfaccd421ad07d0a6cc738ccf8684961a182..324099d047a841df7a125f7f029313a3079da34e 100644
--- a/net/test/test_server.cc
+++ b/net/test/test_server.cc
@@ -98,23 +98,32 @@ TestServer::~TestServer() {
Stop();
}
+FilePath TestServer::GetTestServerDirectory() {
+ // Get path to python server script.
+ FilePath testserver_dir;
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_dir)) {
+ LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
+ return FilePath();
+ }
+
+ testserver_dir = testserver_dir
+ .Append(FILE_PATH_LITERAL("net"))
+ .Append(FILE_PATH_LITERAL("tools"))
+ .Append(FILE_PATH_LITERAL("testserver"));
+ return testserver_dir;
+}
+
bool TestServer::Start() {
if (type_ == TYPE_HTTPS) {
if (!LoadTestRootCert())
return false;
}
- // Get path to python server script
- FilePath testserver_path;
- if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) {
- LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
+ FilePath testserver_path(GetTestServerDirectory());
+ if (testserver_path.empty())
return false;
- }
- testserver_path = testserver_path
- .Append(FILE_PATH_LITERAL("net"))
- .Append(FILE_PATH_LITERAL("tools"))
- .Append(FILE_PATH_LITERAL("testserver"))
- .Append(FILE_PATH_LITERAL("testserver.py"));
+ testserver_path =
+ testserver_path.Append(FILE_PATH_LITERAL("testserver.py"));
if (!SetPythonPath())
return false;
@@ -283,6 +292,30 @@ void TestServer::Init(const std::string& host, const FilePath& document_root) {
log_to_console_ = true;
}
+// static
+bool TestServer::RunSyncTest() {
+ if (!SetPythonPath()) {
+ LOG(ERROR) << "Error trying to set python path. Exiting.";
+ return false;
+ }
+
+ FilePath sync_test_path(GetTestServerDirectory());
+ if (sync_test_path.empty()) {
+ LOG(ERROR) << "Error trying to get python test server path.";
+ return false;
+ }
+
+ sync_test_path =
+ sync_test_path.Append(FILE_PATH_LITERAL("chromiumsync_test.py"));
+ CommandLine python_command(GetAbsolutePythonCommandPath());
+ python_command.AppendArgPath(sync_test_path);
+ if (!base::LaunchProcess(python_command, base::LaunchOptions(), NULL)) {
akalin 2012/03/03 01:18:32 can you add a VLOG of the final command line somew
+ LOG(ERROR) << "Failed to launch test script.";
+ return false;
+ }
+ return true;
+}
+
bool TestServer::SetPythonPath() {
FilePath third_party_dir;
if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) {
« no previous file with comments | « net/test/test_server.h ('k') | net/test/test_server_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698