From 61827fc91483531271ac3f00cd5768d452737901 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 12 Mar 2016 09:19:28 +0000 Subject: [PATCH] Fix Git repo detection tests failing on Windows Due to an incorrect file path - because the build path can vary, --- src/tests/backend/helpers/test_git_helper.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tests/backend/helpers/test_git_helper.h b/src/tests/backend/helpers/test_git_helper.h index aee0a226..ef40d144 100644 --- a/src/tests/backend/helpers/test_git_helper.h +++ b/src/tests/backend/helpers/test_git_helper.h @@ -31,11 +31,16 @@ along with LOOT. If not, see namespace loot { namespace test { -#ifdef _WIN32 - boost::filesystem::path parentRepoRoot = boost::filesystem::current_path().parent_path().parent_path(); -#else - boost::filesystem::path parentRepoRoot = boost::filesystem::current_path().parent_path(); -#endif + boost::filesystem::path getRepoRoot() { + boost::filesystem::path dir = boost::filesystem::current_path(); + while (!boost::filesystem::exists(dir / ".git")) { + dir = dir.parent_path(); + } + + return dir; + } + + boost::filesystem::path parentRepoRoot = getRepoRoot(); TEST(GitHelper, ConstructorAndDestructor) { GitHelper * git = new GitHelper();