Summary:
There is no longer anything keeping them from working on Windows.
Except for that `signal(SIGPIPE, SIG_IGN)` call; that has to stay disabled.
Reviewed By: simpkins
Differential Revision:
D5308007
fbshipit-source-id:
74a392cf484404f41a6c51e50b5a9e6fbd05b4a9
std::string data;
auto ret = folly::readFile(tmpFile.path().string().c_str(), data);
std::string data;
auto ret = folly::readFile(tmpFile.path().string().c_str(), data);
EXPECT_EQ(expected, data);
}
EXPECT_EQ(expected, data);
}
namespace {
static std::vector<std::string>* internalWarnings;
namespace {
static std::vector<std::string>* internalWarnings;
std::array<int, 2> fds;
auto rc = pipe(fds.data());
folly::checkUnixError(rc, "failed to create pipe");
std::array<int, 2> fds;
auto rc = pipe(fds.data());
folly::checkUnixError(rc, "failed to create pipe");
signal(SIGPIPE, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
::close(fds[0]);
// Log a bunch of messages to the writer
::close(fds[0]);
// Log a bunch of messages to the writer
// AsyncFileWriter should have some internal warning messages about the
// log failures. This will generally be many fewer than the number of
// messages we wrote, though, since it performs write batching.
// AsyncFileWriter should have some internal warning messages about the
// log failures. This will generally be many fewer than the number of
// messages we wrote, though, since it performs write batching.
+ //
+ // GTest on Windows doesn't support alternation in the regex syntax -_-....
+ const std::string kExpectedErrorMessage =
+#if _WIN32
+ // The `pipe` call above is actually implemented via sockets, so we get
+ // a different error message.
+ "An established connection was aborted by the software in your host machine\\.";
+#else
+ "Broken pipe";
+#endif
+
for (const auto& msg : logErrors) {
EXPECT_THAT(
msg,
testing::ContainsRegex(
for (const auto& msg : logErrors) {
EXPECT_THAT(
msg,
testing::ContainsRegex(
- "error writing to log file .* in AsyncFileWriter.*: Broken pipe"));
+ "error writing to log file .* in AsyncFileWriter.*: " +
+ kExpectedErrorMessage));
}
EXPECT_GT(logErrors.size(), 0);
EXPECT_LE(logErrors.size(), numMessages);
}
EXPECT_GT(logErrors.size(), 0);
EXPECT_LE(logErrors.size(), numMessages);
// Make sure flush completes successfully now
future.get(10ms);
}
// Make sure flush completes successfully now
future.get(10ms);
}
// A large-ish message suffix, just to consume space and help fill up
// log buffers faster.
// A large-ish message suffix, just to consume space and help fill up
// log buffers faster.