diff options
author | Blaze Rules Copybara <blaze-rules@google.com> | 2022-10-18 06:36:44 -0700 |
---|---|---|
committer | Blaze Rules Copybara <blaze-rules@google.com> | 2022-10-18 06:36:44 -0700 |
commit | 63556dec09bde629d76f416eae2a1d04529a8a10 (patch) | |
tree | e6a7dede33c987612f7782358ae2c60b89241461 | |
parent | ba401432feeb79a4174a134f533aef4054331343 (diff) | |
parent | 0ec8c838b9dd5be1a00f4688226f58c6f6c7d324 (diff) | |
download | bazelbuild-rules-proto-63556dec09bde629d76f416eae2a1d04529a8a10.tar.gz |
Merge pull request #156 from comius:workspace-with-main
PiperOrigin-RevId: 481905618
-rw-r--r-- | WORKSPACE.bzlmod | 2 | ||||
-rw-r--r-- | tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc | 9 | ||||
-rw-r--r-- | tests/utils/workspace_constants.h | 1 |
3 files changed, 8 insertions, 4 deletions
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index e2857dc..e69de29 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -1,2 +0,0 @@ -# TODO(bazel-team): Without following line runfiles use __main__ as a repo name. -workspace(name = "rules_proto") 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..890ca60 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 |