You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/03/23 00:12:33 UTC

svn commit: r1460053 - in /incubator/mesos/trunk/src/tests: utils.cpp utils.hpp

Author: vinodkone
Date: Fri Mar 22 23:12:33 2013
New Revision: 1460053

URL: http://svn.apache.org/r1460053
Log:
Fixed TemporaryDirectoryTest to clean up the sandbox, and use ASSERTs
instead of CHECKs.

From: Ben Mahler <be...@gmail.com>
Review: https://reviews.apache.org/r/10077

Modified:
    incubator/mesos/trunk/src/tests/utils.cpp
    incubator/mesos/trunk/src/tests/utils.hpp

Modified: incubator/mesos/trunk/src/tests/utils.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.cpp?rev=1460053&r1=1460052&r2=1460053&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/utils.cpp (original)
+++ incubator/mesos/trunk/src/tests/utils.cpp Fri Mar 22 23:12:33 2013
@@ -74,23 +74,29 @@ void TemporaryDirectoryTest::SetUp()
   // Create a temporary directory for the test.
   Try<string> directory = mkdtemp();
 
-  CHECK_SOME(directory) << "Failed to create mkdtemp";
+  ASSERT_SOME(directory) << "Failed to mkdtemp";
+
+  sandbox = directory.get();
 
   if (flags.verbose) {
-    std::cerr << "Using temporary directory '"
-              << directory.get() << "'" << std::endl;
+    std::cout << "Using temporary directory '"
+              << sandbox.get() << "'" << std::endl;
   }
 
   // Run the test out of the temporary directory we created.
-  PCHECK(os::chdir(directory.get()))
-    << "Failed to chdir into '" << directory.get() << "'";
+  ASSERT_TRUE(os::chdir(sandbox.get()))
+    << "Failed to chdir into '" << sandbox.get() << "'";
 }
 
 
 void TemporaryDirectoryTest::TearDown()
 {
-  // Return to previous working directory.
-  PCHECK(os::chdir(cwd));
+  // Return to previous working directory and cleanup the sandbox.
+  ASSERT_TRUE(os::chdir(cwd));
+
+  if (sandbox.isSome()) {
+    ASSERT_SOME(os::rmdir(sandbox.get()));
+  }
 }
 
 } // namespace tests {

Modified: incubator/mesos/trunk/src/tests/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.hpp?rev=1460053&r1=1460052&r2=1460053&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/utils.hpp (original)
+++ incubator/mesos/trunk/src/tests/utils.hpp Fri Mar 22 23:12:33 2013
@@ -110,6 +110,7 @@ protected:
 
 private:
   std::string cwd;
+  Option<std::string> sandbox;
 };