From 838c6a7a992098c8197c8d079387f577f9f2b6ec Mon Sep 17 00:00:00 2001 From: "agl@chromium.org" Date: Tue, 12 Oct 2010 21:20:52 +0000 Subject: testserver: try harder to find the pyproto directory on OS X BUG=58522 TEST=sync_integration_tests on OS X Review URL: http://codereview.chromium.org/3671004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62335 0039d316-1c4b-4281-b951-d872f2087c98 --- net/test/test_server.cc | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'net') diff --git a/net/test/test_server.cc b/net/test/test_server.cc index 55d0faf..10f4b2a 100644 --- a/net/test/test_server.cc +++ b/net/test/test_server.cc @@ -238,9 +238,28 @@ bool TestServer::SetPythonPath() { LOG(ERROR) << "Failed to get DIR_EXE"; return false; } - generated_code_dir = generated_code_dir.Append(FILE_PATH_LITERAL("pyproto")); - AppendToPythonPath(generated_code_dir); - AppendToPythonPath(generated_code_dir.Append(FILE_PATH_LITERAL("sync_pb"))); + + static const FilePath kPyProto(FILE_PATH_LITERAL("pyproto")); + +#if defined(OS_MACOSX) + // On Mac, DIR_EXE might be pointing deep into the Release/ (or Debug/) + // directory and we can't depend on how far down it goes. So we walk upwards + // from DIR_EXE until we find a likely looking spot. + while (!file_util::DirectoryExists(generated_code_dir.Append(kPyProto))) { + FilePath parent = generated_code_dir.DirName(); + if (parent == generated_code_dir) { + // We hit the root directory. Maybe we didn't build any targets which + // produced Python protocol buffers. + PathService::Get(base::DIR_EXE, &generated_code_dir); + break; + } + generated_code_dir = parent; + } +#endif + + AppendToPythonPath(generated_code_dir.Append(kPyProto)); + AppendToPythonPath(generated_code_dir.Append(kPyProto). + Append(FILE_PATH_LITERAL("sync_pb"))); return true; } -- cgit v1.1