[glom/glom-1-14] test_document_autosave: Change the temp filename to avoid a clash.



commit adb80e47277c98cb0c9730bcb4baa34e4d06036a
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Aug 9 14:49:00 2010 +0200

    test_document_autosave: Change the temp filename to avoid a clash.
    
    * tests/test_document_autosave.cc: Rename the file because we sometimes
      seem to clash with a directory of the same name.

 ChangeLog                       |    7 +++++++
 tests/test_document_autosave.cc |   24 +++++++++++++-----------
 2 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f26a726..7b8fe9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-08-09  Murray Cumming  <murrayc murrayc com>
+
+	test_document_autosave: Change the temp filename to avoid a clash.
+
+	* tests/test_document_autosave.cc: Rename the file because we sometimes
+  seem to clash with a directory of the same name.
+
 2010-08-10  Murray Cumming  <murrayc murrayc com>
 
 	Catch exceptions from std::locale::global().
diff --git a/tests/test_document_autosave.cc b/tests/test_document_autosave.cc
index 796ea3e..9ef3496 100644
--- a/tests/test_document_autosave.cc
+++ b/tests/test_document_autosave.cc
@@ -30,7 +30,7 @@ void cleanup()
   {
     //TODO: Catch exceptions:
     Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(file_uri);
-    file->remove();
+    file->remove(); //This should be OK because it is a file, not a directory.
   }
   catch(const Gio::Error& ex)
   {
@@ -38,12 +38,14 @@ void cleanup()
     if(ex.code() == Gio::Error::NOT_FOUND)
       return;
 
-    std::cerr << "Exception from Gio::File::remove(): " << ex.what();
+    std::cerr << G_STRFUNC << ": Exception from Gio::File::remove(): " << ex.what() << std::endl
+      << "  file_uri= " << file_uri << std::endl;
     exit(EXIT_FAILURE);
   }
   catch(const Glib::Error& ex)
   {
-    std::cerr << "Exception from Gio::File::remove(): " << ex.what();
+    std::cerr << G_STRFUNC << ":Exception from Gio::File::remove(): " << ex.what() << std::endl
+      << "  file_uri= " << file_uri << std::endl;
     exit(EXIT_FAILURE);
   }
 }
@@ -53,16 +55,16 @@ int main()
   Glom::libglom_init();
 
   //For instance, /tmp/testfile.glom");
-  const std::string temp_filename = "testglom";
-  const std::string temp_filepath = Glib::build_filename(Glib::get_tmp_dir(), 
+  const std::string temp_filename = "testglom_document_autosave";
+  const std::string temp_filepath = Glib::build_filename(Glib::get_tmp_dir(),
     temp_filename);
   file_uri = Glib::filename_to_uri(temp_filepath);
-  
+
   //Make sure that the file does not exist yet:
   cleanup();
 
   const Glib::ustring test_title = "test_title";
-  
+
   //Test manual saving:
   {
     Glom::Document document;
@@ -78,7 +80,7 @@ int main()
     int failure_code = 0;
     const bool test = document.load(failure_code);
     g_assert(test);
-    
+
     g_assert( document.get_database_title() == test_title );
   }
 
@@ -99,12 +101,12 @@ int main()
     int failure_code = 0;
     const bool test = document.load(failure_code);
     g_assert(test);
-    
+
     g_assert( document.get_database_title() == test_title );
   }
-  
+
   cleanup();
-  
+
   Glom::libglom_deinit();
 
   return EXIT_SUCCESS;



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