summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_test.cc9
-rw-r--r--content/public/test/browser_test_utils.cc7
-rw-r--r--content/test/layout_test_http_server.cc4
-rw-r--r--net/test/local_test_server_posix.cc8
-rw-r--r--net/test/local_test_server_win.cc10
-rw-r--r--net/test/python_utils.cc21
-rw-r--r--net/test/python_utils.h5
-rw-r--r--net/test/python_utils_unittest.cc5
-rw-r--r--net/tools/testserver/run_testserver.cc6
9 files changed, 36 insertions, 39 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc
index 0233626..ccec75c 100644
--- a/chrome/browser/safe_browsing/safe_browsing_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_test.cc
@@ -144,9 +144,12 @@ class SafeBrowsingTestServer {
pyproto_code_dir = pyproto_code_dir.Append(FILE_PATH_LITERAL("google"));
AppendToPythonPath(pyproto_code_dir);
- CommandLine cmd_line(CommandLine::NO_PROGRAM);
- EXPECT_TRUE(GetPythonCommand(&cmd_line));
-
+ FilePath python_runtime;
+ EXPECT_TRUE(GetPythonRunTime(&python_runtime));
+ CommandLine cmd_line(python_runtime);
+ // Make python stdout and stderr unbuffered, to prevent incomplete stderr on
+ // win bots, and also fix mixed up ordering of stdout and stderr.
+ cmd_line.AppendSwitch("-u");
FilePath datafile = testserver_path.Append(datafile_);
cmd_line.AppendArgPath(testserver);
cmd_line.AppendArg(base::StringPrintf("--port=%d", kPort_));
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index f49ce92..ed0379d 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -514,10 +514,9 @@ bool TestWebSocketServer::Start(const FilePath& root_directory) {
CommandLine* TestWebSocketServer::CreatePythonCommandLine() {
// Note: Python's first argument must be the script; do not append CommandLine
// switches, as they would precede the script path and break this CommandLine.
- CommandLine* cmd_line = new CommandLine(CommandLine::NO_PROGRAM);
- // TODO(phajdan.jr): Instead of CHECKing, return a boolean indicating success.
- CHECK(GetPythonCommand(cmd_line));
- return cmd_line;
+ FilePath path;
+ CHECK(GetPythonRunTime(&path));
+ return new CommandLine(path);
}
void TestWebSocketServer::SetPythonPath() {
diff --git a/content/test/layout_test_http_server.cc b/content/test/layout_test_http_server.cc
index 37f04e4..783c596 100644
--- a/content/test/layout_test_http_server.cc
+++ b/content/test/layout_test_http_server.cc
@@ -23,8 +23,10 @@ bool PrepareCommandLine(CommandLine* cmd_line) {
if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_path))
return false;
- if (!GetPythonCommand(cmd_line))
+ FilePath python_runtime;
+ if (!GetPythonRunTime(&python_runtime))
return false;
+ cmd_line->SetProgram(python_runtime);
FilePath script_path(src_path);
script_path = script_path.AppendASCII("third_party");
diff --git a/net/test/local_test_server_posix.cc b/net/test/local_test_server_posix.cc
index eda65fd..7afd422 100644
--- a/net/test/local_test_server_posix.cc
+++ b/net/test/local_test_server_posix.cc
@@ -97,11 +97,9 @@ 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(CommandLine::NO_PROGRAM);
- if (!GetPythonCommand(&python_command))
- return false;
+ 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))
diff --git a/net/test/local_test_server_win.cc b/net/test/local_test_server_win.cc
index ba2a8cd..0b30312 100644
--- a/net/test/local_test_server_win.cc
+++ b/net/test/local_test_server_win.cc
@@ -20,7 +20,6 @@
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "base/win/scoped_handle.h"
-#include "net/test/python_utils.h"
#pragma comment(lib, "crypt32.lib")
@@ -86,10 +85,15 @@ bool ReadData(HANDLE read_fd, HANDLE write_fd,
namespace net {
bool LocalTestServer::LaunchPython(const FilePath& testserver_path) {
- CommandLine python_command(CommandLine::NO_PROGRAM);
- if (!GetPythonCommand(&python_command))
+ FilePath python_exe;
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &python_exe))
return false;
+ python_exe = python_exe
+ .Append(FILE_PATH_LITERAL("third_party"))
+ .Append(FILE_PATH_LITERAL("python_26"))
+ .Append(FILE_PATH_LITERAL("python.exe"));
+ CommandLine python_command(python_exe);
python_command.AppendArgPath(testserver_path);
if (!AddCommandLineArguments(&python_command))
return false;
diff --git a/net/test/python_utils.cc b/net/test/python_utils.cc
index 82d0c5c..0eec816 100644
--- a/net/test/python_utils.cc
+++ b/net/test/python_utils.cc
@@ -5,7 +5,6 @@
#include "net/test/python_utils.h"
#include "base/base_paths.h"
-#include "base/command_line.h"
#include "base/environment.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -104,23 +103,15 @@ bool GetPyProtoPath(FilePath* dir) {
return true;
}
-bool GetPythonCommand(CommandLine* python_cmd) {
- DCHECK(python_cmd);
- FilePath dir;
+bool GetPythonRunTime(FilePath* dir) {
#if defined(OS_WIN)
- if (!PathService::Get(base::DIR_SOURCE_ROOT, &dir))
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, dir))
return false;
- dir = dir.Append(FILE_PATH_LITERAL("third_party"))
- .Append(FILE_PATH_LITERAL("python_26"))
- .Append(FILE_PATH_LITERAL("python.exe"));
+ *dir = dir->Append(FILE_PATH_LITERAL("third_party"))
+ .Append(FILE_PATH_LITERAL("python_26"))
+ .Append(FILE_PATH_LITERAL("python.exe"));
#elif defined(OS_POSIX)
- dir = FilePath("python");
+ *dir = FilePath("python");
#endif
- python_cmd->SetProgram(dir);
-
- // Launch python in unbuffered mode, so that python output doesn't mix with
- // gtest output in buildbot log files. See http://crbug.com/147368.
- python_cmd->AppendArg("-u");
-
return true;
}
diff --git a/net/test/python_utils.h b/net/test/python_utils.h
index c7cf289..583fb27 100644
--- a/net/test/python_utils.h
+++ b/net/test/python_utils.h
@@ -7,7 +7,6 @@
#include "base/compiler_specific.h"
-class CommandLine;
class FilePath;
// This is the python path variable name.
@@ -19,7 +18,7 @@ void AppendToPythonPath(const FilePath& dir);
// Return the location of the compiler-generated python protobuf.
bool GetPyProtoPath(FilePath* dir);
-// Returns the command that should be used to launch Python.
-bool GetPythonCommand(CommandLine* python_cmd) WARN_UNUSED_RESULT;
+// Returns the path that should be used to launch Python.
+bool GetPythonRunTime(FilePath* path) WARN_UNUSED_RESULT;
#endif // NET_TEST_PYTHON_UTILS_H_
diff --git a/net/test/python_utils_unittest.cc b/net/test/python_utils_unittest.cc
index f81a440..0114774 100644
--- a/net/test/python_utils_unittest.cc
+++ b/net/test/python_utils_unittest.cc
@@ -45,11 +45,12 @@ TEST(PythonUtils, Append) {
}
TEST(PythonUtils, PythonRunTime) {
- CommandLine cmd_line(CommandLine::NO_PROGRAM);
- EXPECT_TRUE(GetPythonCommand(&cmd_line));
+ FilePath dir;
+ EXPECT_TRUE(GetPythonRunTime(&dir));
// Run a python command to print a string and make sure the output is what
// we want.
+ CommandLine cmd_line(dir);
cmd_line.AppendArg("-c");
std::string input("PythonUtilsTest");
std::string python_cmd = StringPrintf("print '%s';", input.c_str());
diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc
index 9ad0f7d..c02d4d6 100644
--- a/net/tools/testserver/run_testserver.cc
+++ b/net/tools/testserver/run_testserver.cc
@@ -40,13 +40,13 @@ static bool RunSyncTest() {
sync_test_path =
sync_test_path.Append(FILE_PATH_LITERAL("chromiumsync_test.py"));
-
- CommandLine python_command(CommandLine::NO_PROGRAM);
- if (!GetPythonCommand(&python_command)) {
+ FilePath python_runtime;
+ if (!GetPythonRunTime(&python_runtime)) {
LOG(ERROR) << "Could not get python runtime command.";
return false;
}
+ CommandLine python_command(python_runtime);
python_command.AppendArgPath(sync_test_path);
if (!base::LaunchProcess(python_command, base::LaunchOptions(), NULL)) {
LOG(ERROR) << "Failed to launch test script.";