[glom] Add a document-loading test and self-hosting test
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Add a document-loading test and self-hosting test
- Date: Sat, 24 Apr 2010 21:02:23 +0000 (UTC)
commit 98b37402e5b1bad59a0dcab1a729423a9f4ff288
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Apr 24 23:02:17 2010 +0200
Add a document-loading test and self-hosting test
* glom/Makefile_tests.am: Added the tests.
* glom/libglom/test_document.cc: Renamed to example_document_load.cc.
* tests/test_document_load/test_document_load.cc: Added this new test to
load a document, checking some known parts of its structure.
* glom/libglom/document/bakery/document.cc: write_to_disk(): Create the
parent directory if necessary, instead of failing with a Gio exception.
* test/test_selfhosting_newempty/test_selfhosting_newempty.cc: Saves a new
file from an example, starts self-hosting of it, and stops self-hosting.
This needs work and expansion.
ChangeLog | 15 +++
Makefile.am | 3 +-
Makefile_tests.am | 21 +++-
glom/dialog_existing_or_new.cc | 9 +-
glom/libglom/document/bakery/document.cc | 54 ++++++----
glom/libglom/sharedptr.h | 7 +-
glom/libglom/test_document.cc | 164 ------------------------------
po/cs.po | 32 ++++--
8 files changed, 98 insertions(+), 207 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c4f7a02..3d6a2ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2010-04-23 Murray Cumming <murrayc murrayc com>
+
+ Add a document-loading test and self-hosting test
+
+ * glom/Makefile_tests.am: Added the tests.
+ * glom/libglom/test_document.cc: Renamed to example_document_load.cc.
+ * tests/test_document_load/test_document_load.cc: Added this new test to
+ load a document, checking some known parts of its structure.
+
+ * glom/libglom/document/bakery/document.cc: write_to_disk(): Create the
+ parent directory if necessary, instead of failing with a Gio exception.
+ * test/test_selfhosting_newempty/test_selfhosting_newempty.cc: Saves a new
+ file from an example, starts self-hosting of it, and stops self-hosting.
+ This needs work and expansion.
+
2010-04-20 Murray Cumming <murrayc murrayc com>
Python Glom module: Improve sphinx-generated documentation.
diff --git a/Makefile.am b/Makefile.am
index efb7c82..db915a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -176,7 +176,8 @@ glom_localedir = $(prefix)/$(DATADIRNAME)/locale
glom_includes = -I$(top_builddir)/glom -I$(top_srcdir)/glom -I$(top_builddir) -I$(top_srcdir)
glom_defines = \
-DGLOM_DATADIR=\""$(datadir)"\" \
--DGLOM_DOCDIR=\""$(docdir)"\" \
+-DGLOM_DOCDIR_EXAMPLES=\""$(docdir)/examples"\" \
+-DGLOM_DOCDIR_EXAMPLES_NOTINSTALLED=\""$(abs_top_srcdir)/examples"\" \
-DGLOM_LOCALEDIR=\""$(glom_localedir)"\" \
-DGLOM_PKGDATADIR=\""$(pkgdatadir)"\" \
-DGLOM_PKGDATADIR_NOTINSTALLED=\""$(top_srcdir)/glom"\"
diff --git a/Makefile_tests.am b/Makefile_tests.am
index c90c3cb..0beda70 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -17,10 +17,11 @@
check_PROGRAMS = \
glom/libglom/test_connectionpool \
- glom/libglom/test_document \
+ glom/libglom/example_document_load \
glom/libglom/test_sharedptr_layoutitem \
glom/utility_widgets/test_flowtable \
glom/test_pyembed \
+ tests/test_document_load/test_document_load \
tests/test_parsing_time \
tests/test_signal_reemit \
tests/test_load_python_library\
@@ -31,9 +32,11 @@ check_PROGRAMS = \
tests/import/test_parsing \
tests/import/test_signals \
tests/test_glade_derived_instantiation \
- tests/glade_toplevels_instantiation
+ tests/glade_toplevels_instantiation \
+ tests/test_selfhosting_new_empty/test_selfhosting_new_empty
-TESTS = tests/test_parsing_time \
+TESTS = tests/test_document_load/test_document_load \
+ tests/test_parsing_time \
tests/test_signal_reemit \
tests/test_dtd_file_validation.sh \
tests/test_glade_file_validation.sh \
@@ -43,7 +46,8 @@ TESTS = tests/test_parsing_time \
tests/test_python_module \
tests/test_python_execute_func \
tests/test_python_execute_func_date \
- tests/test_python_execute_script
+ tests/test_python_execute_script \
+ tests/test_selfhosting_new_empty/test_selfhosting_new_empty
# These hang most of the time, but not always:
# tests/import/test_parsing \
@@ -61,9 +65,11 @@ LIBGLOM_LA = glom/libglom/libglom-$(GLOM_ABI_VERSION).la $(LIBGLOM_LIBS)
tests_ldadd = $(LIBGLOM_LA)
glom_libglom_test_connectionpool_SOURCES = glom/libglom/test_connectionpool.cc
-glom_libglom_test_document_SOURCES = glom/libglom/test_document.cc
+glom_libglom_example_document_load_SOURCES = glom/libglom/example_document_load.cc
glom_libglom_test_sharedptr_layoutitem_SOURCES = glom/libglom/test_sharedptr_layoutitem.cc
glom_test_pyembed_SOURCES = glom/test_pyembed.cc
+
+tests_test_document_load_test_document_load_SOURCES = tests/test_document_load/test_document_load.cc
tests_test_parsing_time_SOURCES = tests/test_parsing_time.cc
tests_test_signal_reemit_SOURCES = tests/test_signal_reemit.cc
tests_test_load_python_library_SOURCES = tests/test_load_python_library.cc
@@ -87,9 +93,10 @@ tests_import_test_signals_SOURCES = \
tests/import/utils.h\
tests/import/test_signals.cc
tests_test_glade_derived_instantiation_SOURCES = tests/test_glade_derived_instantiation.cc $(glom_source_files)
+tests_test_selfhosting_new_empty_test_selfhosting_new_empty_SOURCES = tests/test_selfhosting_new_empty/test_selfhosting_new_empty.cc
glom_libglom_test_connectionpool_LDADD = $(tests_ldadd)
-glom_libglom_test_document_LDADD = $(tests_ldadd)
+glom_libglom_example_document_load_LDADD = $(tests_ldadd)
glom_libglom_test_sharedptr_layoutitem_LDADD = $(tests_ldadd)
glom_utility_widgets_test_flowtable_SOURCES = \
@@ -121,6 +128,7 @@ tests_glade_toplevels_instantiation_LDADD = $(tests_ldadd) $(LIBGLOM_LIBS) $(GLO
glom_test_pyembed_LDADD = $(LIBGLOM_LIBS) $(PYTHON_LIBS)
tests_test_parsing_time_LDADD = $(tests_ldadd)
+tests_test_document_load_test_document_load_LDADD = $(tests_ldadd) $(LIBGLOM_LIBS)
tests_test_signal_reemit_LDADD = $(LIBGLOM_LIBS)
tests_test_load_python_library_LDADD = $(LIBGLOM_LIBS)
tests_test_python_module_LDADD = $(tests_ldadd) $(PYTHON_LIBS)
@@ -130,3 +138,4 @@ tests_test_python_execute_script_LDADD = $(tests_ldadd) $(GLOM_LIBS) $(PYTHON_LI
tests_import_test_parsing_LDADD = $(LIBGLOM_LIBS) $(GLOM_LIBS)
tests_import_test_signals_LDADD = $(LIBGLOM_LIBS) $(GLOM_LIBS)
tests_test_glade_derived_instantiation_LDADD = $(glom_all_libs)
+tests_test_selfhosting_new_empty_test_selfhosting_new_empty_LDADD = $(tests_ldadd) $(LIBGLOM_LIBS)
diff --git a/glom/dialog_existing_or_new.cc b/glom/dialog_existing_or_new.cc
index 7411b86..8618a28 100644
--- a/glom/dialog_existing_or_new.cc
+++ b/glom/dialog_existing_or_new.cc
@@ -164,12 +164,15 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
g_free(dir);
if(!Glib::file_test(path, Glib::FILE_TEST_EXISTS))
- path = GLOM_DOCDIR G_DIR_SEPARATOR_S "examples";
+ path = GLOM_DOCDIR_EXAMPLES;
#else
- const char *const path = GLOM_DOCDIR G_DIR_SEPARATOR_S "examples";
+ const char *const path = GLOM_DOCDIR_EXAMPLES;
#endif //G_OS_WIN32
- list_examples_at_path(path);
+ //Show the installed example files,
+ //falling back to the ones from the local source tree if none are installed:
+ if(!list_examples_at_path(path))
+ list_examples_at_path(GLOM_DOCDIR_EXAMPLES_NOTINSTALLED);
#endif //!GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index 08fb936..7b46bc4 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -268,7 +268,7 @@ bool Document::read_from_disk(int& failure_code)
#else
if(error.get())
{
- std::cerr << "Error: " << error->what() << std::endl;
+ std::cerr << "Bakery::Document::read_from_disk(): Error: " << error->what() << std::endl;
#endif
// If the operation was not successful, print the error and abort
return false; //print_error(ex, input_uri_string);
@@ -293,35 +293,46 @@ bool Document::write_to_disk()
Glib::RefPtr<Gio::FileOutputStream> stream;
//Create the file if it does not already exist:
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- try
+ if(file->query_exists())
{
- if(file->query_exists())
+ try
{
stream = file->replace(); //Instead of append_to().
}
- else
+ catch(const Gio::Error& ex)
{
- //By default files created are generally readable by everyone, but if we pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.
- //TODO: Do we want to specify 0660 exactly? (means "this user and his group can read and write this non-executable file".)
- stream = file->create_file();
+ std::cerr << "Bakery::Document::write_to_disk(): Error from Gio::File::replace(): " << ex.what() << std::endl;
+ return false;
}
}
- catch(const Gio::Error& ex)
- {
-#else
- std::auto_ptr<Glib::Error> error;
- stream = file->replace(std::string(), false, Gio::FILE_CREATE_NONE, error);
- if(error.get())
+ else
{
- std::cout << "Error: " << error->what() << std::endl;
-#endif
- // If the operation was not successful, print the error and abort
- std::cout << "Error: " << ex.what() << std::endl;
+ //Make sure that all the parent directories exist, creating them if necessary:
+ Glib::RefPtr<Gio::File> parent = file->get_parent();
+ try
+ {
+ parent->make_directory_with_parents();
+ }
+ catch(const Gio::Error& ex)
+ {
+ std::cerr << "Bakery::Document::write_to_disk(): Error from Gio::File::make_directory_with_parents(): uri=" << m_file_uri << "error=" << ex.what() << std::endl;
+ return false;
+ }
- return false; // print_error(ex, output_uri_string);
- }
+ //Create the file:
+ //By default files created are generally readable by everyone, but if we pass FILE_CREATE_PRIVATE in flags the file will be made readable only to the current user, to the level that is supported on the target filesystem.
+ //TODO: Do we want to specify 0660 exactly? (means "this user and his group can read and write this non-executable file".)
+ try
+ {
+ stream = file->create_file();
+ }
+ catch(const Gio::Error& ex)
+ {
+ std::cerr << "Bakery::Document::write_to_disk(): Error from Gio::File::create_file():" << m_file_uri << "error=" << ex.what() << std::endl;
+ return false;
+ }
+ }
if(!stream)
return false;
@@ -345,9 +356,10 @@ bool Document::write_to_disk()
stream->write(m_strContents.data(), m_strContents.bytes(), gerror);
if(gerror.get())
{
- std::cerr << "Error: "<< gerror.get() << std::endl;
+ std::cerr << "akery::Document::write_to_disk(): Error from Gio stream.write(): "<< gerror.get() << std::endl;
#endif
// If the operation was not successful, print the error and abort
+ std::cerr << "Bakery::Document::write_to_disk(): Error from Gio stream.write(): " << ex.what() << std::endl;
return false; //print_error(ex, output_uri_string);
}
diff --git a/glom/libglom/sharedptr.h b/glom/libglom/sharedptr.h
index f3082f9..3b94c1a 100644
--- a/glom/libglom/sharedptr.h
+++ b/glom/libglom/sharedptr.h
@@ -28,9 +28,9 @@
namespace Glom
{
-/**A ref-counting smart-pointer for the underlying C object.
- * You can copy these smarpointers-of-C-resources, and therefore the C++ classes can
- * have simple copy constructors which just share the underlying C resources.
+/**A ref-counting smart-pointer for the underlying C++ object.
+ * You can copy these smarpointers-of-C++-resources, and therefore the C++ classes can
+ * have simple copy constructors which just share the underlying resources.
*
*/
template< typename T_obj >
@@ -38,6 +38,7 @@ class sharedptr
{
public:
typedef size_t size_type;
+ typedef T_obj object_type;
sharedptr();
diff --git a/po/cs.po b/po/cs.po
index 45666eb..05bd8e6 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -12,8 +12,8 @@ msgid ""
msgstr ""
"Project-Id-Version: glom gnome-master\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-04-22 23:53+0200\n"
-"PO-Revision-Date: 2010-04-17 23:42+0200\n"
+"POT-Creation-Date: 2010-04-17 21:05+0200\n"
+"PO-Revision-Date: 2010-04-07 15:31+0200\n"
"Last-Translator: Marek Ä?ernocký <marek manet cz>\n"
"Language-Team: Czech <gnome-cs-list gnome org>\n"
"MIME-Version: 1.0\n"
@@ -33,8 +33,9 @@ msgid ""
msgstr "ProsÃm poÄ?kejte dokud Glom nepÅ?ipravà váš systém pro sdÃlenà na sÃti."
#: ../glom/application.cc:181
+#, fuzzy
msgid "© 2000-2010 Murray Cumming"
-msgstr "© 2000-2010 Murray Cumming"
+msgstr "© 2000-2005 Murray Cumming"
#: ../glom/application.cc:181
msgid "A Database GUI"
@@ -119,11 +120,13 @@ msgid "_User Level"
msgstr "Ã?roveÅ? _uživatele"
#: ../glom/application.cc:452
+#, fuzzy
msgctxt "User-level menu item"
msgid "_Developer"
msgstr "_VývojáÅ?"
#: ../glom/application.cc:456
+#, fuzzy
msgctxt "User-level menu item"
msgid "_Operator"
msgstr "_Operátor"
@@ -143,6 +146,7 @@ msgid "_Find"
msgstr "_Hledat"
#: ../glom/application.cc:477
+#, fuzzy
msgctxt "Developer menu title"
msgid "_Developer"
msgstr "_VývojáÅ?"
@@ -789,11 +793,13 @@ msgstr "Žádná kritéria hledánÃ"
#. show user level:
#. The _C macro provides translator context.
#: ../glom/frame_glom.cc:1525
+#, fuzzy
msgctxt "Mode"
msgid "Operator"
msgstr "Operátor"
#: ../glom/frame_glom.cc:1527
+#, fuzzy
msgctxt "Mode"
msgid "Developer"
msgstr "VývojáÅ?"
@@ -888,8 +894,9 @@ msgid "<b>Groups</b>"
msgstr "<b>Skupiny</b>"
#: ../glom/glom_developer.glade.h:12
+#, fuzzy
msgid "<b>Image:</b>"
-msgstr "<b>Obrázek:</b>"
+msgstr "<b>Obrázek</b>"
#: ../glom/glom_developer.glade.h:13
msgid "<b>Label:</b>"
@@ -952,8 +959,9 @@ msgid "<b>Text Formatting</b>"
msgstr "<b>Formátovánà textu</b>"
#: ../glom/glom_developer.glade.h:28
+#, fuzzy
msgid "<b>Text:</b>"
-msgstr "<b>Text:</b>"
+msgstr "<b>Text</b>"
#: ../glom/glom_developer.glade.h:29
msgid "<b>Title:</b>"
@@ -1355,6 +1363,7 @@ msgstr "FormátovánÃ"
#. Translators: FROM as in SQL's FROM
#: ../glom/glom_developer.glade.h:116
+#, fuzzy
msgid "From field:"
msgstr "Od pole:"
@@ -1386,8 +1395,9 @@ msgid "Group Properties"
msgstr "Vlastnosti skupiny"
#: ../glom/glom_developer.glade.h:122
+#, fuzzy
msgid "Group name:"
-msgstr "Název skupiny:"
+msgstr "Název skupiny"
#: ../glom/glom_developer.glade.h:123
msgid "Groups"
@@ -1490,8 +1500,9 @@ msgid "Name of new relationship:"
msgstr "Název nového vztahu:"
#: ../glom/glom_developer.glade.h:144
+#, fuzzy
msgid "Name:"
-msgstr "Název:"
+msgstr "_Název:"
#: ../glom/glom_developer.glade.h:145
msgid "No Choices"
@@ -1565,8 +1576,9 @@ msgid "Restrict data to these choices"
msgstr "Omezit data na tyto možnosti"
#: ../glom/glom_developer.glade.h:161
+#, fuzzy
msgid "Script Library"
-msgstr "Knihovna skriptů"
+msgstr "K_nihovna skriptů"
#: ../glom/glom_developer.glade.h:162
msgid "Script name:"
@@ -1788,8 +1800,9 @@ msgstr "Vy_poÄ?Ãtat hodnotu"
#. Translators: This is the verb
#: ../glom/glom_developer.glade.h:210
+#, fuzzy
msgid "_Check"
-msgstr "Z_kontrolovat"
+msgstr "Zvolte"
#: ../glom/glom_developer.glade.h:211
msgid "_Confirm Password:"
@@ -3398,6 +3411,7 @@ msgstr "Plný pÅ?Ãstup."
#. Append the View columns:
#: ../glom/mode_design/users/dialog_users_list.cc:67
+#, fuzzy
msgctxt "Users List"
msgid "User"
msgstr "Uživatel"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]