You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2018/09/26 20:58:08 UTC
[mesos] 01/03: Prevented leaking files in some stout tests.
This is an automated email from the ASF dual-hosted git repository.
bbannier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 75849ec73d8f596e138a9997e79c6f984eaf1b3f
Author: Benjamin Bannier <bb...@apache.org>
AuthorDate: Thu Sep 20 09:33:33 2018 +0200
Prevented leaking files in some stout tests.
Review: https://reviews.apache.org/r/68816
---
3rdparty/stout/tests/main.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/3rdparty/stout/tests/main.cpp b/3rdparty/stout/tests/main.cpp
index f08f62f..f98dec3 100644
--- a/3rdparty/stout/tests/main.cpp
+++ b/3rdparty/stout/tests/main.cpp
@@ -25,6 +25,7 @@
#include <stout/fs.hpp>
#include <stout/os/mkdtemp.hpp>
+#include <stout/os/rmdir.hpp>
#include <stout/os/socket.hpp> // For `wsa_*` on Windows.
#include <stout/os/touch.hpp>
@@ -44,13 +45,10 @@ using std::vector;
class SymlinkFilter : public TestFilter
{
public:
- SymlinkFilter()
+ SymlinkFilter() : temp_path(CHECK_NOTERROR(os::mkdtemp()))
{
- const Try<string> temp_path = os::mkdtemp();
- CHECK_SOME(temp_path);
-
- const string file = path::join(temp_path.get(), "file");
- const string link = path::join(temp_path.get(), "link");
+ const string file = path::join(temp_path, "file");
+ const string link = path::join(temp_path, "link");
CHECK_SOME(os::touch(file));
@@ -66,6 +64,11 @@ public:
}
}
+ ~SymlinkFilter() override
+ {
+ os::rmdir(temp_path);
+ }
+
bool disable(const ::testing::TestInfo* test) const override
{
return matches(test, "SYMLINK_") && !can_create_symlinks;
@@ -73,6 +76,7 @@ public:
private:
bool can_create_symlinks;
+ string temp_path;
};