From a2cf54fca2d51d1fff205934beea543d0314bbb9 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 3 May 2014 16:21:01 -0700 Subject: [PATCH] Fix test. --- test/gtest-extra-test.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index 53e72e1e..a9de03f2 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -167,6 +167,7 @@ bool IsClosedInternal(int fd) { // Checks if the file is closed. # define EXPECT_CLOSED(fd) EXPECT_TRUE(IsClosedInternal(fd)) #else +// Reading from a closed file causes death on Windows. # define EXPECT_CLOSED(fd) EXPECT_DEATH(IsClosedInternal(fd), "") #endif @@ -245,11 +246,17 @@ TEST(FileTest, CloseFileInDtor) { TEST(FileTest, DtorCloseError) { File *f = new File(".travis.yml", File::RDONLY); +#ifndef _WIN32 // The close function must be called inside EXPECT_STDERR, otherwise // the system may allocate freed file descriptor when redirecting the // output in EXPECT_STDERR. EXPECT_STDERR(FMT_POSIX(close(f->descriptor())); delete f, FormatSystemErrorMessage(EBADF, "cannot close file") + "\n"); +#else + close(f->descriptor()); + // Closing file twice causes death on Windows. + EXPECT_DEATH(delete f, ""); +#endif } TEST(FileTest, Close) {