summaryrefslogtreecommitdiffstats
path: root/net/test/test_server_posix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/test/test_server_posix.cc')
-rw-r--r--net/test/test_server_posix.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/net/test/test_server_posix.cc b/net/test/test_server_posix.cc
index 7741d89..783bdc3 100644
--- a/net/test/test_server_posix.cc
+++ b/net/test/test_server_posix.cc
@@ -9,6 +9,22 @@
#include "base/string_number_conversions.h"
namespace net {
+
+// static
+void TestServer::AppendToPythonPath(const FilePath& dir) {
+ const char kPythonPath[] = "PYTHONPATH";
+ const char* oldpath = getenv(kPythonPath);
+ // setenv() leaks memory intentionally on Mac
+ if (!oldpath) {
+ setenv(kPythonPath, dir.value().c_str(), 1);
+ } else if (!strstr(oldpath, dir.value().c_str())) {
+ std::string newpath(oldpath);
+ newpath.append(":");
+ newpath.append(dir.value());
+ setenv(kPythonPath, newpath.c_str(), 1);
+ }
+}
+
bool TestServer::LaunchPython(const FilePath& testserver_path) {
std::vector<std::string> command_line;
command_line.push_back("python");