Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: base/base_paths_linux.cc

Issue 192064: Hack to make tests work if out is a symlink: see if the current dir is the source root. (Closed)
Patch Set: use path.DirName().DirName() Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/memory_test/memory_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/base_paths_linux.cc
diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc
index 151c4117e27ced541c867270f9403d1eba083cea..ca5ca4e6a6f4977d24a435b1fb134caaefd6b5bb 100644
--- a/base/base_paths_linux.cc
+++ b/base/base_paths_linux.cc
@@ -39,12 +39,23 @@ bool PathProviderLinux(int key, FilePath* result) {
case base::DIR_SOURCE_ROOT:
// On linux, unit tests execute two levels deep from the source root.
// For example: sconsbuild/{Debug|Release}/net_unittest
- if (!PathService::Get(base::DIR_EXE, &path))
- return false;
- path = path.Append(FilePath::kParentDirectory)
- .Append(FilePath::kParentDirectory);
- *result = path;
- return true;
+ if (PathService::Get(base::DIR_EXE, &path)) {
+ path = path.DirName().DirName();
+ if (file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
+ *result = path;
+ return true;
+ }
+ }
+ // If that failed (maybe the build output is symlinked to a different
+ // drive) try assuming the current directory is the source root.
+ if (file_util::GetCurrentDirectory(&path) &&
+ file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
+ *result = path;
+ return true;
+ }
+ LOG(ERROR) << "Couldn't find your source root. "
+ << "Try running from your chromium/src directory.";
+ return false;
}
return false;
}
« no previous file with comments | « no previous file | chrome/test/memory_test/memory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698