[glom] tests: Add try/catch around all calls of the test functions.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] tests: Add try/catch around all calls of the test functions.
- Date: Fri, 11 Jan 2013 15:35:29 +0000 (UTC)
commit 99acb3ec00b5d448216f665ecef57b669dac9840
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Jan 6 14:41:48 2013 +0100
tests: Add try/catch around all calls of the test functions.
* tests/test_selfhosting_utils.[h|cc]:
Check for uncaught exceptions.
ChangeLog | 7 ++++++
tests/test_selfhosting_utils.cc | 41 ++++++++++++++++++++++++++------------
tests/test_selfhosting_utils.h | 2 +
3 files changed, 37 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 14763a5..f563ea6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2013-01-06 Murray Cumming <murrayc murrayc com>
+ tests: Add try/catch around all calls of the test functions.
+
+ * tests/test_selfhosting_utils.[h|cc]:
+ Check for uncaught exceptions.
+
+2013-01-06 Murray Cumming <murrayc murrayc com>
+
tests: Add: test_selfhosting_new_from_example_float.cc
* Makefile_tests.am:
diff --git a/tests/test_selfhosting_utils.cc b/tests/test_selfhosting_utils.cc
index a09c986..7b3b295 100644
--- a/tests/test_selfhosting_utils.cc
+++ b/tests/test_selfhosting_utils.cc
@@ -526,29 +526,44 @@ bool test_example_musiccollection_data(const Glom::Document* document)
return test_example_musiccollection_data_related(document, album_id);
}
-int test_all_hosting_modes(const SlotTest& slot)
+static bool test_hosting_mode(const SlotTest& slot, Glom::Document::HostingMode hosting_mode, const Glib::ustring name)
{
- if(!slot(Glom::Document::HOSTING_MODE_POSTGRES_SELF))
+ try
{
- std::cerr << "Failed with PostgreSQL" << std::endl;
- test_selfhosting_cleanup();
- return EXIT_FAILURE;
+ if(!slot(hosting_mode))
+ {
+ std::cerr << "Failed with " << name << std::endl;
+ test_selfhosting_cleanup();
+ return false;
+ }
}
-
- if(!slot(Glom::Document::HOSTING_MODE_SQLITE))
+ catch(const std::exception& ex)
{
- std::cerr << "Failed with SQLite" << std::endl;
+ std::cerr << "Failed with " << name << " with exception: " << ex.what() << std::endl;
test_selfhosting_cleanup();
- return EXIT_FAILURE;
+ return false;
}
-
- if(!slot(Glom::Document::HOSTING_MODE_MYSQL_SELF))
+ catch(...)
{
- std::cerr << "Failed with MySQL" << std::endl;
+ std::cerr << "Failed with " << name << " with unknown exception: " << std::endl;
test_selfhosting_cleanup();
- return EXIT_FAILURE;
+ return false;
}
+ return true;
+}
+
+int test_all_hosting_modes(const SlotTest& slot)
+{
+ if(!test_hosting_mode(slot, Glom::Document::HOSTING_MODE_SQLITE, "SQLite"))
+ return EXIT_FAILURE;
+
+ if(!test_hosting_mode(slot, Glom::Document::HOSTING_MODE_MYSQL_SELF, "MySQL"))
+ return EXIT_FAILURE;
+
+ if(!test_hosting_mode(slot, Glom::Document::HOSTING_MODE_POSTGRES_SELF, "PostgreSQL"))
+ return EXIT_FAILURE;
+
return EXIT_SUCCESS;
}
diff --git a/tests/test_selfhosting_utils.h b/tests/test_selfhosting_utils.h
index fc7ce07..5075f92 100644
--- a/tests/test_selfhosting_utils.h
+++ b/tests/test_selfhosting_utils.h
@@ -94,6 +94,8 @@ typedef sigc::slot<bool, Glom::Document::HostingMode> SlotTest;
*/
int test_all_hosting_modes(const SlotTest& slot);
+/** Return true if the Value does not have an expected numeric type.
+ */
bool test_check_numeric_value_type(Glom::Document::HostingMode hosting_mode, const Gnome::Gda::Value& value);
#endif //GLOM_TEST_SELFHOSTING_UTILS_H
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]