Skip to content

Commit

Permalink
Address different handling of runfiles in bzlmod.
Browse files Browse the repository at this point in the history
  • Loading branch information
comius committed Sep 20, 2022
1 parent 27232d2 commit 940e468
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ namespace {

std::string GetRlocation(const std::string& file) {
static std::unique_ptr<Runfiles> runfiles(Runfiles::CreateForTest());
return runfiles->Rlocation(file);
std::string path = runfiles->Rlocation(rulesproto::kWorkspaceRlocation + file);
std::ifstream input(path, std::ifstream::binary);
if (!input) {
path = runfiles->Rlocation(rulesproto::kWorkspaceRlocationBzlmod + file);
}
return path;
}

template <typename T, typename K>
Expand Down Expand Up @@ -66,7 +71,7 @@ void AssertFileDescriptorSetContains(
const std::vector<std::string>& expected_proto_files) {
std::vector<std::string> actual_proto_files =
ReadFileDescriptorSet(
GetRlocation(rulesproto::kWorkspaceRlocation + path));
GetRlocation(path));
EXPECT_EQ(expected_proto_files, actual_proto_files);
}

Expand Down
1 change: 1 addition & 0 deletions tests/utils/workspace_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
namespace rulesproto {

constexpr char kWorkspaceRlocation[] = "rules_proto/";
constexpr char kWorkspaceRlocationBzlmod[] = "__main__/";

} // namespace rulesproto

0 comments on commit 940e468

Please sign in to comment.