diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 05:13:30 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 05:13:30 +0000 |
commit | 6e289c7216e44f42496a0e05b457c5c5ca24e8d5 (patch) | |
tree | 6b3687329189a6d9e1af1a5db92af91537c71e8a /net/test | |
parent | 4a63af5b5aefe6e4b7601b78ad288e969f4fedbe (diff) | |
download | chromium_src-6e289c7216e44f42496a0e05b457c5c5ca24e8d5.zip chromium_src-6e289c7216e44f42496a0e05b457c5c5ca24e8d5.tar.gz chromium_src-6e289c7216e44f42496a0e05b457c5c5ca24e8d5.tar.bz2 |
Add "run_testserver --sync-test" for easy chromiumsync_test.py launching.
BUG=none
TEST=type that command. see tests run.
Review URL: https://chromiumcodereview.appspot.com/9545019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126847 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-rw-r--r-- | net/test/local_test_server.cc | 29 | ||||
-rw-r--r-- | net/test/local_test_server.h | 11 | ||||
-rw-r--r-- | net/test/local_test_server_posix.cc | 6 |
3 files changed, 34 insertions, 12 deletions
diff --git a/net/test/local_test_server.cc b/net/test/local_test_server.cc index 463cd80..7fe3e58 100644 --- a/net/test/local_test_server.cc +++ b/net/test/local_test_server.cc @@ -76,18 +76,30 @@ LocalTestServer::~LocalTestServer() { Stop(); } -bool LocalTestServer::Start() { - // Get path to Python server script. - FilePath testserver_path; - if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) { +// static +bool LocalTestServer::GetTestServerDirectory(FilePath* directory) { + // 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 false; } - testserver_path = testserver_path + + testserver_dir = testserver_dir .Append(FILE_PATH_LITERAL("net")) .Append(FILE_PATH_LITERAL("tools")) - .Append(FILE_PATH_LITERAL("testserver")) - .Append(FILE_PATH_LITERAL("testserver.py")); + .Append(FILE_PATH_LITERAL("testserver")); + *directory = testserver_dir; + return true; +} + +bool LocalTestServer::Start() { + // Get path to Python server script. + FilePath testserver_path; + if (!GetTestServerDirectory(&testserver_path)) + return false; + testserver_path = + testserver_path.Append(FILE_PATH_LITERAL("testserver.py")); if (!SetPythonPath()) return false; @@ -146,7 +158,8 @@ bool LocalTestServer::Init(const FilePath& document_root) { return true; } -bool LocalTestServer::SetPythonPath() const { +// static +bool LocalTestServer::SetPythonPath() { FilePath third_party_dir; if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; diff --git a/net/test/local_test_server.h b/net/test/local_test_server.h index 48c2186..90ba160 100644 --- a/net/test/local_test_server.h +++ b/net/test/local_test_server.h @@ -42,12 +42,16 @@ class LocalTestServer : public BaseTestServer { // Stop the server started by Start(). bool Stop(); + // Modify PYTHONPATH to contain libraries we need. + static bool SetPythonPath() WARN_UNUSED_RESULT; + + // Returns true if successfully stored the FilePath for the directory of the + // testserver python script in |*directory|. + static bool GetTestServerDirectory(FilePath* directory) WARN_UNUSED_RESULT; + private: bool Init(const FilePath& document_root); - // Modify PYTHONPATH to contain libraries we need. - bool SetPythonPath() const WARN_UNUSED_RESULT; - // Launches the Python test server. Returns true on success. bool LaunchPython(const FilePath& testserver_path) WARN_UNUSED_RESULT; @@ -84,4 +88,3 @@ class LocalTestServer : public BaseTestServer { } // namespace net #endif // NET_TEST_LOCAL_TEST_SERVER_H_ - diff --git a/net/test/local_test_server_posix.cc b/net/test/local_test_server_posix.cc index 0cb4857..3756b69 100644 --- a/net/test/local_test_server_posix.cc +++ b/net/test/local_test_server_posix.cc @@ -15,6 +15,7 @@ #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/test/test_timeouts.h" +#include "net/test/python_utils.h" namespace { @@ -94,7 +95,12 @@ bool ReadData(int fd, ssize_t bytes_max, uint8* buffer, namespace net { bool LocalTestServer::LaunchPython(const FilePath& testserver_path) { + // Log is useful in the event you want to run a nearby script (e.g. a test) in + // the same environment as the TestServer. + VLOG(1) << "LaunchPython called with PYTHONPATH = " << + getenv(kPythonPathEnv); CommandLine python_command(FilePath(FILE_PATH_LITERAL("python"))); + python_command.AppendArgPath(testserver_path); if (!AddCommandLineArguments(&python_command)) return false; |