OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/test/python_utils.h" | 5 #include "net/test/python_utils.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/environment.h" | 11 #include "base/environment.h" |
10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
12 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 15 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/process/launch.h" | 17 #include "base/process/launch.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 | 20 |
20 #if defined(OS_MACOSX) | 21 #if defined(OS_MACOSX) |
21 #include "base/mac/foundation_util.h" | 22 #include "base/mac/foundation_util.h" |
22 #endif | 23 #endif |
23 | 24 |
24 const char kPythonPathEnv[] = "PYTHONPATH"; | 25 const char kPythonPathEnv[] = "PYTHONPATH"; |
25 | 26 |
26 void AppendToPythonPath(const base::FilePath& dir) { | 27 void AppendToPythonPath(const base::FilePath& dir) { |
27 scoped_ptr<base::Environment> env(base::Environment::Create()); | 28 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
28 std::string old_path; | 29 std::string old_path; |
29 std::string dir_path; | 30 std::string dir_path; |
30 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
31 dir_path = base::WideToUTF8(dir.value()); | 32 dir_path = base::WideToUTF8(dir.value()); |
32 #elif defined(OS_POSIX) | 33 #elif defined(OS_POSIX) |
33 dir_path = dir.value(); | 34 dir_path = dir.value(); |
34 #endif | 35 #endif |
35 if (!env->GetVar(kPythonPathEnv, &old_path)) { | 36 if (!env->GetVar(kPythonPathEnv, &old_path)) { |
36 env->SetVar(kPythonPathEnv, dir_path.c_str()); | 37 env->SetVar(kPythonPathEnv, dir_path.c_str()); |
37 } else if (old_path.find(dir_path) == std::string::npos) { | 38 } else if (old_path.find(dir_path) == std::string::npos) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #else | 111 #else |
111 python_cmd->SetProgram(base::FilePath(FILE_PATH_LITERAL("python"))); | 112 python_cmd->SetProgram(base::FilePath(FILE_PATH_LITERAL("python"))); |
112 #endif | 113 #endif |
113 | 114 |
114 // Launch python in unbuffered mode, so that python output doesn't mix with | 115 // Launch python in unbuffered mode, so that python output doesn't mix with |
115 // gtest output in buildbot log files. See http://crbug.com/147368. | 116 // gtest output in buildbot log files. See http://crbug.com/147368. |
116 python_cmd->AppendArg("-u"); | 117 python_cmd->AppendArg("-u"); |
117 | 118 |
118 return true; | 119 return true; |
119 } | 120 } |
OLD | NEW |