From: Michael Lee Date: Sat, 5 Mar 2016 00:06:40 +0000 (-0800) Subject: Switch from tmpdir to TemporaryDirectory X-Git-Tag: deprecate-dynamic-initializer~4 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=61f94b617246b8ca6b5d183f9179e687e741bd51;hp=30ec44d3646f1eb6b6a4ef02d7589c53a84ee8fe 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 --- 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");},