diff options
-rw-r--r-- | base/base_paths_linux.cc | 23 | ||||
-rw-r--r-- | chrome/test/memory_test/memory_test.cc | 4 | ||||
-rw-r--r-- | chrome/test/page_cycler/page_cycler_test.cc | 4 | ||||
-rw-r--r-- | chrome/test/tab_switching/tab_switching_test.cc | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 4 |
5 files changed, 22 insertions, 17 deletions
diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc index 151c411..ca5ca4e 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; } diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc index 014d601..63367d3 100644 --- a/chrome/test/memory_test/memory_test.cc +++ b/chrome/test/memory_test/memory_test.cc @@ -48,9 +48,7 @@ class MemoryTest : public UITest { if (profile_dir.empty()) { // Compute the user-data-dir which contains our test cache. - PathService::Get(base::DIR_EXE, &profile_dir); - profile_dir = profile_dir.DirName(); - profile_dir = profile_dir.DirName(); + PathService::Get(base::DIR_SOURCE_ROOT, &profile_dir); profile_dir = profile_dir.AppendASCII("data"); profile_dir = profile_dir.AppendASCII("memory_test"); profile_dir = profile_dir.AppendASCII("general_mix"); diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc index b927807..06d61de 100644 --- a/chrome/test/page_cycler/page_cycler_test.cc +++ b/chrome/test/page_cycler/page_cycler_test.cc @@ -180,9 +180,7 @@ class PageCyclerTest : public UITest { // Make sure the test data is checked out FilePath test_path; - PathService::Get(base::DIR_EXE, &test_path); - test_path = test_path.DirName(); - test_path = test_path.DirName(); + PathService::Get(base::DIR_SOURCE_ROOT, &test_path); test_path = test_path.Append(FILE_PATH_LITERAL("data")); test_path = test_path.Append(FILE_PATH_LITERAL("page_cycler")); test_path = test_path.AppendASCII(name); diff --git a/chrome/test/tab_switching/tab_switching_test.cc b/chrome/test/tab_switching/tab_switching_test.cc index 234b777..1bce9c3 100644 --- a/chrome/test/tab_switching/tab_switching_test.cc +++ b/chrome/test/tab_switching/tab_switching_test.cc @@ -29,9 +29,7 @@ namespace { class TabSwitchingUITest : public UITest { public: TabSwitchingUITest() { - PathService::Get(base::DIR_EXE, &path_prefix_); - path_prefix_ = path_prefix_.DirName(); - path_prefix_ = path_prefix_.DirName(); + PathService::Get(base::DIR_SOURCE_ROOT, &path_prefix_); path_prefix_ = path_prefix_.AppendASCII("data"); path_prefix_ = path_prefix_.AppendASCII("tab_switching"); diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 72864e2..87e80a5 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -612,8 +612,8 @@ std::string TestShell::RewriteLocalUrl(const std::string& url) { std::string new_url(url); if (url.compare(0, kPrefixLen, kPrefix, kPrefixLen) == 0) { FilePath replace_path; - PathService::Get(base::DIR_EXE, &replace_path); - replace_path = replace_path.DirName().DirName().Append( + PathService::Get(base::DIR_SOURCE_ROOT, &replace_path); + replace_path = replace_path.Append( "webkit/data/layout_tests/LayoutTests/"); new_url = std::string("file://") + replace_path.value() + url.substr(kPrefixLen); |