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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/memory_test/memory_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/base_paths_linux.h" 5 #include "base/base_paths_linux.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 21 matching lines...) Expand all
32 NOTREACHED() << "Unable to resolve " << kSelfExe << "."; 32 NOTREACHED() << "Unable to resolve " << kSelfExe << ".";
33 return false; 33 return false;
34 } 34 }
35 bin_dir[bin_dir_size] = 0; 35 bin_dir[bin_dir_size] = 0;
36 *result = FilePath(bin_dir); 36 *result = FilePath(bin_dir);
37 return true; 37 return true;
38 } 38 }
39 case base::DIR_SOURCE_ROOT: 39 case base::DIR_SOURCE_ROOT:
40 // On linux, unit tests execute two levels deep from the source root. 40 // On linux, unit tests execute two levels deep from the source root.
41 // For example: sconsbuild/{Debug|Release}/net_unittest 41 // For example: sconsbuild/{Debug|Release}/net_unittest
42 if (!PathService::Get(base::DIR_EXE, &path)) 42 if (PathService::Get(base::DIR_EXE, &path)) {
43 return false; 43 path = path.DirName().DirName();
44 path = path.Append(FilePath::kParentDirectory) 44 if (file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
45 .Append(FilePath::kParentDirectory); 45 *result = path;
46 *result = path; 46 return true;
47 return true; 47 }
48 }
49 // If that failed (maybe the build output is symlinked to a different
50 // drive) try assuming the current directory is the source root.
51 if (file_util::GetCurrentDirectory(&path) &&
52 file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
53 *result = path;
54 return true;
55 }
56 LOG(ERROR) << "Couldn't find your source root. "
57 << "Try running from your chromium/src directory.";
58 return false;
48 } 59 }
49 return false; 60 return false;
50 } 61 }
51 62
52 } // namespace base 63 } // namespace base
OLDNEW
« 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