Commit 61f94b61 authored by Michael Lee's avatar Michael Lee Committed by Facebook Github Bot 0

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
parent 30ec44d3
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <folly/Exception.h> #include <folly/Exception.h>
#include <folly/experimental/TestUtil.h>
#include <cstdio> #include <cstdio>
#include <memory> #include <memory>
...@@ -72,15 +74,18 @@ TEST(ExceptionTest, Simple) { ...@@ -72,15 +74,18 @@ TEST(ExceptionTest, Simple) {
EXPECT_SYSTEM_ERROR({checkUnixErrorExplicit(-1, EIO, "hello", " world");}, EXPECT_SYSTEM_ERROR({checkUnixErrorExplicit(-1, EIO, "hello", " world");},
EIO, "hello world"); EIO, "hello world");
std::shared_ptr<FILE> fp(tmpfile(), fclose); TemporaryDirectory tmpdir;
auto exnpath = tmpdir.path() / "ExceptionTest";
auto fp = fopen(exnpath.c_str(), "w+b");
ASSERT_TRUE(fp != nullptr); 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; errno = ERANGE;
EXPECT_SYSTEM_ERROR({checkFopenError(nullptr, "hello", " world");}, EXPECT_SYSTEM_ERROR({checkFopenError(nullptr, "hello", " world");},
ERANGE, "hello world"); ERANGE, "hello world");
EXPECT_NO_THROW({checkFopenErrorExplicit(fp.get(), EIO, "hello", " world");}); EXPECT_NO_THROW({ checkFopenErrorExplicit(fp, EIO, "hello", " world"); });
errno = ERANGE; errno = ERANGE;
EXPECT_SYSTEM_ERROR({checkFopenErrorExplicit(nullptr, EIO, EXPECT_SYSTEM_ERROR({checkFopenErrorExplicit(nullptr, EIO,
"hello", " world");}, "hello", " world");},
......
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