Commit 95d050e3 authored by mattm@chromium.org's avatar mattm@chromium.org

Hack to make tests work if out is a symlink: see if the current dir is the source root.

Fix some tests that were manually getting sourcedir from DIR_EXE instead of using DIR_SOURCE_ROOT.

BUG=none
TEST=rm -r out, ln -s /somedir/out out, run tests

Review URL: http://codereview.chromium.org/192064

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25898 0039d316-1c4b-4281-b951-d872f2087c98
parent 697b87dd
......@@ -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;
}
......
......@@ -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");
......
......@@ -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);
......
......@@ -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");
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment