| 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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 base::FilePath source_dir; | 78 base::FilePath source_dir; |
| 79 if (!PathService::Get(base::DIR_SOURCE_ROOT, &source_dir)) { | 79 if (!PathService::Get(base::DIR_SOURCE_ROOT, &source_dir)) { |
| 80 LOG(ERROR) << "Can't find " << source_dir.value(); | 80 LOG(ERROR) << "Can't find " << source_dir.value(); |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 // On Mac, and possibly Chrome OS, DIR_EXE might be pointing deep | 83 // On Mac, and possibly Chrome OS, DIR_EXE might be pointing deep |
| 84 // into the Release/ (or Debug/) directory and we can't depend on | 84 // into the Release/ (or Debug/) directory and we can't depend on |
| 85 // how far down it goes. So we walk upwards from DIR_EXE until we | 85 // how far down it goes. So we walk upwards from DIR_EXE until we |
| 86 // find a likely looking spot. | 86 // find a likely looking spot. |
| 87 if (!TryRelativeToDir(generated_code_dir, kPyProto, dir)) { | 87 if (!TryRelativeToDir(generated_code_dir, kPyProto, dir)) { |
| 88 LOG(WARNING) << "Can't find " << kPyProto.value() | 88 LOG(WARNING) << "Can't find " << kPyProto.value() << " next to " |
| 89 << " next to " << generated_code_dir.value(); | 89 << generated_code_dir.value(); |
| 90 // On Chrome OS, we may have installed the test binaries and support tools | 90 // On Chrome OS, we may have installed the test binaries and support tools |
| 91 // in a wholly separate location, relative to DIR_SOURCE_ROOT. We'll want | 91 // in a wholly separate location, relative to DIR_SOURCE_ROOT. We'll want |
| 92 // to do a similar investigation from that point as well. | 92 // to do a similar investigation from that point as well. |
| 93 generated_code_dir = source_dir | 93 generated_code_dir = source_dir.Append(FILE_PATH_LITERAL("out")) |
| 94 .Append(FILE_PATH_LITERAL("out")) | 94 .Append(FILE_PATH_LITERAL("Release")); |
| 95 .Append(FILE_PATH_LITERAL("Release")); | |
| 96 if (!TryRelativeToDir(generated_code_dir, kPyProto, dir)) { | 95 if (!TryRelativeToDir(generated_code_dir, kPyProto, dir)) { |
| 97 LOG(WARNING) << "Can't find " << kPyProto.value() | 96 LOG(WARNING) << "Can't find " << kPyProto.value() << " next to " |
| 98 << " next to " << generated_code_dir.value(); | 97 << generated_code_dir.value(); |
| 99 return false; | 98 return false; |
| 100 } | 99 } |
| 101 } | 100 } |
| 102 generated_code_dir = *dir; | 101 generated_code_dir = *dir; |
| 103 #endif | 102 #endif |
| 104 *dir = generated_code_dir.Append(kPyProto); | 103 *dir = generated_code_dir.Append(kPyProto); |
| 105 VLOG(2) << "Found " << kPyProto.value() << " in " << dir->value(); | 104 VLOG(2) << "Found " << kPyProto.value() << " in " << dir->value(); |
| 106 return true; | 105 return true; |
| 107 } | 106 } |
| 108 | 107 |
| 109 bool GetPythonCommand(CommandLine* python_cmd) { | 108 bool GetPythonCommand(CommandLine* python_cmd) { |
| 110 DCHECK(python_cmd); | 109 DCHECK(python_cmd); |
| 111 | 110 |
| 112 #if defined(OS_WIN) | 111 #if defined(OS_WIN) |
| 113 // This permits finding the proper python in path even if it is a .bat file. | 112 // This permits finding the proper python in path even if it is a .bat file. |
| 114 python_cmd->SetProgram(base::FilePath(FILE_PATH_LITERAL("cmd.exe"))); | 113 python_cmd->SetProgram(base::FilePath(FILE_PATH_LITERAL("cmd.exe"))); |
| 115 python_cmd->AppendArg("/c"); | 114 python_cmd->AppendArg("/c"); |
| 116 python_cmd->AppendArg("python"); | 115 python_cmd->AppendArg("python"); |
| 117 #else | 116 #else |
| 118 python_cmd->SetProgram(base::FilePath(FILE_PATH_LITERAL("python"))); | 117 python_cmd->SetProgram(base::FilePath(FILE_PATH_LITERAL("python"))); |
| 119 #endif // defined(OS_WIN) | 118 #endif // defined(OS_WIN) |
| 120 // Launch python in unbuffered mode, so that python output doesn't mix with | 119 // Launch python in unbuffered mode, so that python output doesn't mix with |
| 121 // gtest output in buildbot log files. See http://crbug.com/147368. | 120 // gtest output in buildbot log files. See http://crbug.com/147368. |
| 122 python_cmd->AppendArg("-u"); | 121 python_cmd->AppendArg("-u"); |
| 123 | 122 |
| 124 return true; | 123 return true; |
| 125 } | 124 } |
| OLD | NEW |