Commit bf44ef99 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Don't attempt to separately close the underlying file descriptor in the format other test

Summary: Windows automatically closes the underlying file descriptor when you call fclose, however fclose is not a function that can be easily overriden in the portability layer, so choose to just not call `close` on Windows instead.

Reviewed By: yfeldblum

Differential Revision: D4190524

fbshipit-source-id: a68edccd04e63f89c178ade584fa7192845773f8
parent b6746598
......@@ -321,4 +321,10 @@ constexpr auto kIsLinux = true;
#else
constexpr auto kIsLinux = false;
#endif
#if defined(_WIN32)
constexpr auto kIsWindows = true;
#else
constexpr auto kIsWindows = false;
#endif
}
......@@ -20,10 +20,11 @@
#include <folly/FBVector.h>
#include <folly/FileUtil.h>
#include <folly/Portability.h>
#include <folly/dynamic.h>
#include <folly/json.h>
#include <folly/small_vector.h>
#include <folly/portability/GTest.h>
#include <folly/small_vector.h>
using namespace folly;
......@@ -33,7 +34,13 @@ TEST(FormatOther, file) {
{
int fds[2];
CHECK_ERR(pipe(fds));
SCOPE_EXIT { closeNoInt(fds[1]); };
SCOPE_EXIT {
// fclose on Windows automatically closes the underlying
// file descriptor.
if (!kIsWindows) {
closeNoInt(fds[1]);
}
};
{
FILE* fp = fdopen(fds[1], "wb");
PCHECK(fp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment