Skip to content

Commit 1c0fb1a

Browse files
committed
Revert "Revert "Address different handling of runfiles in bzlmod.""
This reverts commit 8fa4805.
1 parent ba40143 commit 1c0fb1a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ namespace {
3333

3434
std::string GetRlocation(const std::string& file) {
3535
static std::unique_ptr<Runfiles> runfiles(Runfiles::CreateForTest());
36-
return runfiles->Rlocation(file);
36+
std::string path = runfiles->Rlocation(rulesproto::kWorkspaceRlocation + file);
37+
std::ifstream input(path, std::ifstream::binary);
38+
if (!input) {
39+
path = runfiles->Rlocation(rulesproto::kWorkspaceRlocationBzlmod + file);
40+
}
41+
return path;
3742
}
3843

3944
template <typename T, typename K>
@@ -66,7 +71,7 @@ void AssertFileDescriptorSetContains(
6671
const std::vector<std::string>& expected_proto_files) {
6772
std::vector<std::string> actual_proto_files =
6873
ReadFileDescriptorSet(
69-
GetRlocation(rulesproto::kWorkspaceRlocation + path));
74+
GetRlocation(path));
7075
EXPECT_EQ(expected_proto_files, actual_proto_files);
7176
}
7277

Diff for: tests/utils/workspace_constants.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
namespace rulesproto {
2323

2424
constexpr char kWorkspaceRlocation[] = "rules_proto/";
25+
constexpr char kWorkspaceRlocationBzlmod[] = "__main__/";
2526

2627
} // namespace rulesproto

0 commit comments

Comments
 (0)