[glom/glom-1-20] test_selfhosting_new_empty: Simplify the cleanup code.



commit c681ab76cb581a935c3303b84a1480cbcdaddd2c
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jan 30 20:55:25 2012 +0100

    test_selfhosting_new_empty: Simplify the cleanup code.
    
    * tests/test_selfhosting_new_empty.cc: Call cleanup if test() returns
    false, like we in the other tests, to avoid calling it in too many
    places.

 ChangeLog                           |    8 ++++++++
 tests/test_selfhosting_new_empty.cc |    8 +++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 27f6403..4e9be92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2012-01-30  Murray Cumming  <murrayc murrayc com>
 
+	test_selfhosting_new_empty: Simplify the cleanup code.
+
+	* tests/test_selfhosting_new_empty.cc: Call cleanup if test() returns 
+	false, like we in the other tests, to avoid calling it in too many
+	places.
+
+2012-01-30  Murray Cumming  <murrayc murrayc com>
+
 	Require the latest goocanvas because it has fixes that PrintLayout needs.
 
 	* configure.ac: Require goocanvas 2.0.1.
diff --git a/tests/test_selfhosting_new_empty.cc b/tests/test_selfhosting_new_empty.cc
index 743ec35..93b3808 100644
--- a/tests/test_selfhosting_new_empty.cc
+++ b/tests/test_selfhosting_new_empty.cc
@@ -124,7 +124,6 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   if(db_name.empty())
   {
     std::cerr << "DbUtils::get_unused_database_name) failed." << std::endl;
-    cleanup();
     return false;
   }
 
@@ -134,7 +133,6 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   if(!created)
   {
     std::cerr << "DbUtils::create_database() failed." << std::endl;
-    cleanup();
     return false;
   }
 
@@ -150,12 +148,10 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   catch(const Glom::ExceptionConnection& ex)
   {
     std::cerr << "Exception: " << ex.what() << std::endl;
-    cleanup();
     return false;
   }
-  
+
   cleanup();
-  
   return true;
 }
 
@@ -166,12 +162,14 @@ int main()
   if(!test(Glom::Document::HOSTING_MODE_POSTGRES_SELF))
   {
     std::cerr << "Failed with PostgreSQL" << std::endl;
+    cleanup();
     return EXIT_FAILURE;
   }
   
   if(!test(Glom::Document::HOSTING_MODE_SQLITE))
   {
     std::cerr << "Failed with SQLite" << std::endl;
+    cleanup();
     return EXIT_FAILURE;
   }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]