aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/cpp
diff options
context:
space:
mode:
authorGravatar ajmichael <ajmichael@google.com>2018-02-07 11:11:03 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-07 11:13:26 -0800
commite1ed133298cb65189fb7e2339a0920bbc4d42f07 (patch)
treea53d2b91188a723f4d6397d3086fc8bb5bac7042 /src/test/cpp
parentda4522fa5bdf251a345d61ca91fb2a8708242572 (diff)
Combine WorkspaceRcFileSearchPath and FindCandidateBlazercPaths and add a test.
RELNOTES: None PiperOrigin-RevId: 184865343
Diffstat (limited to 'src/test/cpp')
-rw-r--r--src/test/cpp/workspace_layout_test.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/cpp/workspace_layout_test.cc b/src/test/cpp/workspace_layout_test.cc
index e2a68eef22..781a54ebbe 100644
--- a/src/test/cpp/workspace_layout_test.cc
+++ b/src/test/cpp/workspace_layout_test.cc
@@ -67,4 +67,31 @@ TEST_F(WorkspaceLayoutTest, GetWorkspace) {
ASSERT_EQ(build_root_, workspace_layout_->GetWorkspace(cwd));
}
+TEST_F(WorkspaceLayoutTest, FindCandidateBlazercPaths) {
+ const std::string binary_dir = blaze_util::JoinPath(build_root_, "bazeldir");
+ const std::string tools_dir = blaze_util::JoinPath(build_root_, "tools");
+ const std::string workspace_rc_path =
+ blaze_util::JoinPath(build_root_, "tools/bazel.rc");
+ const std::string binary_rc_path =
+ blaze_util::JoinPath(binary_dir, "bazel.bazelrc");
+ ASSERT_TRUE(blaze_util::MakeDirectories(binary_dir, 0755));
+ ASSERT_TRUE(blaze_util::MakeDirectories(tools_dir, 0755));
+ ASSERT_TRUE(blaze_util::WriteFile("", workspace_rc_path, 0755));
+ ASSERT_TRUE(blaze_util::WriteFile("", binary_rc_path, 0755));
+
+ std::vector<std::string> expected = {workspace_rc_path, binary_rc_path};
+ std::vector<std::string> actual =
+ workspace_layout_->FindCandidateBlazercPaths(
+ build_root_, build_root_, "bazeldir/bazel", {});
+ // The third entry is the system wide blazerc path, /etc/bazel.bazelrc, which
+ // we do not mock within this test because it is not within the sandbox. It
+ // may or may not exist on the system running the test, so we do not check for
+ // it.
+ // TODO(https://github.com/bazelbuild/bazel/issues/4502): Make the system-wide
+ // master bazelrc location configurable and add test coverage for it.
+ std::vector<std::string> actual_first_two_entries(actual.begin(),
+ actual.begin() + 2);
+ ASSERT_EQ(expected, actual_first_two_entries);
+}
+
} // namespace blaze