Skip to content

Commit 332d178

Browse files
committed
Zipmerge: allow test to be run from internal repo
1 parent 4094db4 commit 332d178

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

misc/bazel/internal/zipmerge/zipmerge_test.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
#include <sstream>
66
#include <string>
77
#include <cstring>
8+
#include <filesystem>
89

910
#include <gtest/gtest.h>
1011
#include <gmock/gmock.h>
1112
#include "tools/cpp/runfiles/runfiles.h"
1213

1314
using bazel::tools::cpp::runfiles::Runfiles;
1415
using namespace std::string_literals;
16+
namespace fs = std::filesystem;
1517

1618
namespace codeql_testing {
1719

@@ -72,7 +74,15 @@ std::string get_file(const char* name) {
7274
EXPECT_TRUE(ret) << error;
7375
return ret;
7476
}();
75-
return runfiles->Rlocation("_main/misc/bazel/internal/zipmerge/test-files/"s + name);
77+
// this works from both `codeql` and the internal repository
78+
for (auto prefix : {"_main", "codeql~"}) {
79+
auto ret = runfiles->Rlocation(prefix + "/misc/bazel/internal/zipmerge/test-files/"s + name);
80+
if (fs::exists(ret)) {
81+
return ret;
82+
}
83+
}
84+
EXPECT_TRUE(false) << "test file " << name << " not found";
85+
return "";
7686
}
7787

7888
void expect_same_file(const char* actual, const char* expected) {

0 commit comments

Comments
 (0)