Bazel client: fix reporting of ignored RC files
(This commit is a roll-forward of commit e9a908560133770614eca89ef64681bdf3f04b3e
that was rolled back by commit 37335187bf31dac48155e77f404bd11008d68ea7. The culprit
of the breakage is fixed in the Google-internal
depot.)
Compute the difference between the read RC files
and the ignored ones based on their canonical
paths, not on the textual value of the path.
This aids for proper reporting of ignored RC
files, while reporting them with a path familiar
to the user (e.g. paths the user passed with flags
rather than the potentially different canonical
version of the same path).
Also: respect $HOME on Windows when Bazel is
running inside of a test, to avoid picking up the
real RC file from the user's home directory. This
fixes //src/test/cpp:rc_file_test on Windows.
Fixes https://github.com/bazelbuild/bazel/issues/6138
Fixes https://github.com/bazelbuild/bazel/issues/6469
Closes #6910.
PiperOrigin-RevId: 225832065
diff --git a/src/test/cpp/rc_file_test.cc b/src/test/cpp/rc_file_test.cc
index 01a4d5a..25baaaa 100644
--- a/src/test/cpp/rc_file_test.cc
+++ b/src/test/cpp/rc_file_test.cc
@@ -173,8 +173,10 @@
ASSERT_EQ(2, parsed_rcs.size());
const std::deque<std::string> expected_system_rc_que = {system_rc};
const std::deque<std::string> expected_workspace_rc_que = {workspace_rc};
- EXPECT_EQ(expected_system_rc_que, parsed_rcs[0].get()->sources());
- EXPECT_EQ(expected_workspace_rc_que, parsed_rcs[1].get()->sources());
+ EXPECT_EQ(expected_system_rc_que,
+ parsed_rcs[0].get()->canonical_source_paths());
+ EXPECT_EQ(expected_workspace_rc_que,
+ parsed_rcs[1].get()->canonical_source_paths());
}
TEST_F(GetRcFileTest, GetRcFilesRespectsNoSystemRc) {
@@ -195,7 +197,8 @@
ASSERT_EQ(1, parsed_rcs.size());
const std::deque<std::string> expected_workspace_rc_que = {workspace_rc};
- EXPECT_EQ(expected_workspace_rc_que, parsed_rcs[0].get()->sources());
+ EXPECT_EQ(expected_workspace_rc_que,
+ parsed_rcs[0].get()->canonical_source_paths());
}
TEST_F(GetRcFileTest, GetRcFilesRespectsNoWorkspaceRc) {
@@ -216,7 +219,8 @@
ASSERT_EQ(1, parsed_rcs.size());
const std::deque<std::string> expected_system_rc_que = {system_rc};
- EXPECT_EQ(expected_system_rc_que, parsed_rcs[0].get()->sources());
+ EXPECT_EQ(expected_system_rc_que,
+ parsed_rcs[0].get()->canonical_source_paths());
}
TEST_F(GetRcFileTest, GetRcFilesRespectsNoWorkspaceRcAndNoSystemCombined) {
@@ -317,8 +321,9 @@
// Because of the variety of path representations in windows, this
// equality test does not attempt to check the entire path.
ASSERT_EQ(1, parsed_rcs.size());
- ASSERT_EQ(1, parsed_rcs[0].get()->sources().size());
- EXPECT_THAT(parsed_rcs[0].get()->sources().front(), HasSubstr("mybazelrc"));
+ ASSERT_EQ(1, parsed_rcs[0].get()->canonical_source_paths().size());
+ EXPECT_THAT(parsed_rcs[0].get()->canonical_source_paths().front(),
+ HasSubstr("mybazelrc"));
}
TEST_F(GetRcFileTest, GetRcFilesAcceptsNullCommandLineRc) {
@@ -338,7 +343,7 @@
// but it does technically count as a file
ASSERT_EQ(1, parsed_rcs.size());
const std::deque<std::string> expected_rc_que = {kNullDevice};
- EXPECT_EQ(expected_rc_que, parsed_rcs[0].get()->sources());
+ EXPECT_EQ(expected_rc_que, parsed_rcs[0].get()->canonical_source_paths());
}
class ParseOptionsTest : public RcFileTest {