Print error message if cannot open `.blazerc` file

PiperOrigin-RevId: 474406363
Change-Id: Ice887df811751a6840b9f30465ee6db3ffdd2208
diff --git a/src/test/cpp/rc_options_test.cc b/src/test/cpp/rc_options_test.cc
index 354ed87..44bf26e 100644
--- a/src/test/cpp/rc_options_test.cc
+++ b/src/test/cpp/rc_options_test.cc
@@ -31,6 +31,12 @@
 using std::vector;
 using ::testing::MatchesRegex;
 
+#if _WIN32
+constexpr bool kIsWindows = true;
+#else
+constexpr bool kIsWindows = false;
+#endif
+
 class RcOptionsTest : public ::testing::Test {
  protected:
   RcOptionsTest()
@@ -400,8 +406,10 @@
   EXPECT_EQ(error, RcFile::ParseError::UNREADABLE_FILE);
   ASSERT_THAT(
       error_text,
-      MatchesRegex(
-          "Unexpected error reading .blazerc file '.*not_a_file.bazelrc'"));
+      MatchesRegex(kIsWindows
+        ? "Unexpected error reading \\.blazerc file '.*not_a_file\\.bazelrc':.*"
+        : "Unexpected error reading \\.blazerc file '.*not_a_file\\.bazelrc': "
+          "\\(error: 2\\): No such file or directory"));
 }
 
 TEST_F(RcOptionsTest, ImportedFileDoesNotExist) {
@@ -413,7 +421,14 @@
   std::unique_ptr<RcFile> rc =
       Parse("import_fake_file.bazelrc", &error, &error_text);
   EXPECT_EQ(error, RcFile::ParseError::UNREADABLE_FILE);
-  ASSERT_EQ(error_text, "Unexpected error reading .blazerc file 'somefile'");
+  if (kIsWindows) {
+    ASSERT_THAT(error_text, MatchesRegex(
+      "Unexpected error reading \\.blazerc file 'somefile':.*"));
+  } else {
+    ASSERT_EQ(error_text,
+      "Unexpected error reading .blazerc file 'somefile': (error: 2): No such "
+      "file or directory");
+  }
 }
 
 TEST_F(RcOptionsTest, TryImportedFileDoesNotExist) {