aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo List <ilist@google.com>2022-10-18 13:36:01 +0200
committerIvo List <ilist@google.com>2022-10-18 13:36:01 +0200
commit1c0fb1a61cc0591f13d7c9b9d62d793ee21e3d68 (patch)
treed72a679b24ea77fd0f0b95a9ed6aea0cdf5a12d0
parentba401432feeb79a4174a134f533aef4054331343 (diff)
downloadbazelbuild-rules-proto-1c0fb1a61cc0591f13d7c9b9d62d793ee21e3d68.tar.gz
Revert "Revert "Address different handling of runfiles in bzlmod.""
This reverts commit 8fa4805757a913f035315be8e26cd81df5abc4c3.
-rw-r--r--tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc9
-rw-r--r--tests/utils/workspace_constants.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc b/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc
index f1d407c..c48b8c4 100644
--- a/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc
+++ b/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc
@@ -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>
@@ -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);
}
diff --git a/tests/utils/workspace_constants.h b/tests/utils/workspace_constants.h
index d1eae5e..2658003 100644
--- a/tests/utils/workspace_constants.h
+++ b/tests/utils/workspace_constants.h
@@ -22,5 +22,6 @@
namespace rulesproto {
constexpr char kWorkspaceRlocation[] = "rules_proto/";
+constexpr char kWorkspaceRlocationBzlmod[] = "__main__/";
} // namespace rulesproto