From 61f94b617246b8ca6b5d183f9179e687e741bd51 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Fri, 4 Mar 2016 16:06:40 -0800 Subject: [PATCH 1/1] Switch from tmpdir to TemporaryDirectory Summary: tmpdir does not work on all platforms. TemporaryDirectory is more robust. Reviewed By: yfeldblum Differential Revision: D3013866 fb-gh-sync-id: 51e2b7ec2348eb95b99c125a27bb2aca2b87ac21 shipit-source-id: 51e2b7ec2348eb95b99c125a27bb2aca2b87ac21 --- folly/test/ExceptionTest.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/folly/test/ExceptionTest.cpp b/folly/test/ExceptionTest.cpp index 49232faa..30a70da0 100644 --- a/folly/test/ExceptionTest.cpp +++ b/folly/test/ExceptionTest.cpp @@ -16,6 +16,8 @@ #include +#include + #include #include @@ -72,15 +74,18 @@ TEST(ExceptionTest, Simple) { EXPECT_SYSTEM_ERROR({checkUnixErrorExplicit(-1, EIO, "hello", " world");}, EIO, "hello world"); - std::shared_ptr fp(tmpfile(), fclose); + TemporaryDirectory tmpdir; + auto exnpath = tmpdir.path() / "ExceptionTest"; + auto fp = fopen(exnpath.c_str(), "w+b"); ASSERT_TRUE(fp != nullptr); + SCOPE_EXIT { fclose(fp); }; - EXPECT_NO_THROW({checkFopenError(fp.get(), "hello", " world");}); + EXPECT_NO_THROW({ checkFopenError(fp, "hello", " world"); }); errno = ERANGE; EXPECT_SYSTEM_ERROR({checkFopenError(nullptr, "hello", " world");}, ERANGE, "hello world"); - EXPECT_NO_THROW({checkFopenErrorExplicit(fp.get(), EIO, "hello", " world");}); + EXPECT_NO_THROW({ checkFopenErrorExplicit(fp, EIO, "hello", " world"); }); errno = ERANGE; EXPECT_SYSTEM_ERROR({checkFopenErrorExplicit(nullptr, EIO, "hello", " world");}, -- 2.34.1