[libgda/wip/xml-ddl-tool: 4/5] API modification and test environment setup
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/wip/xml-ddl-tool: 4/5] API modification and test environment setup
- Date: Tue, 15 May 2018 15:38:54 +0000 (UTC)
commit 274fbb9b788906d2c444b18111e6c1e56a69debf
Author: Pavlo Solntsev <p sun fun gmail com>
Date: Thu Apr 19 22:56:17 2018 -0500
API modification and test environment setup
API for GdaDdlBase was changed and appropriate test was modified.
Test files were added as suggested by Glib documentation.
configure.ac | 1 +
glib-tap.mk | 98 ++++++
libgda/gda-ddl-base.c | 163 ++++------
libgda/gda-ddl-base.h | 23 +-
m4/glibtests.m4 | 31 ++
tap-driver.sh | 652 +++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 2 +-
tests/ddl/check-ddl-base.c | 101 +++---
tests/ddl/libgda-ddl-creator.dtd | 44 +++
9 files changed, 943 insertions(+), 172 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0d92d651c..1ef4cbdd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1059,6 +1059,7 @@ tests/meta-store/Makefile
tests/multi-threading/Makefile
tests/ui/Makefile
tests/vala/Makefile
+tests/ddl/Makefile
doc/Makefile
doc/C/Makefile
doc/C/libgda.types
diff --git a/glib-tap.mk b/glib-tap.mk
new file mode 100644
index 000000000..ef1a5122f
--- /dev/null
+++ b/glib-tap.mk
@@ -0,0 +1,98 @@
+# GLIB - Library of useful C routines
+
+AM_TESTS_ENVIRONMENT= \
+ GDA_TOP_SRC_DIR="$(top_srcdir)" \
+ GDA_TOP_BUILD_DIR="$(top_builddir)" \
+ G_DEBUG=gc-friendly \
+ MALLOC_CHECK_=2 \
+ MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
+LOG_COMPILER = $(top_srcdir)/tap-test
+
+NULL =
+
+# initialize variables for unconditional += appending
+BUILT_SOURCES =
+BUILT_EXTRA_DIST =
+CLEANFILES = *.log *.trs
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+EXTRA_DIST =
+TESTS =
+
+noinst_LTLIBRARIES =
+noinst_PROGRAMS =
+noinst_SCRIPTS =
+noinst_DATA =
+
+check_LTLIBRARIES =
+check_PROGRAMS =
+check_SCRIPTS =
+check_DATA =
+
+# We support a fairly large range of possible variables. It is expected that all types of files in a test
suite
+# will belong in exactly one of the following variables.
+#
+# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
+#
+# test_programs, test_scripts, test_data, test_ltlibraries
+#
+# The above are used to list files that are involved in both uninstalled and installed testing. The
+# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
+# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data
is
+# installed in the same way as it appears in the package layout.
+#
+# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
+# like so:
+#
+# installed_test_programs, uninstalled_test_programs
+# installed_test_scripts, uninstalled_test_scripts
+# installed_test_data, uninstalled_test_data
+# installed_test_ltlibraries, uninstalled_test_ltlibraries
+#
+# Additionally, we support 'extra' infixes for programs and scripts. This is used for support
programs/scripts
+# that should not themselves be run as testcases (but exist to be used from other testcases):
+#
+# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
+# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
+#
+# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or
data
+# file automatically end up in the tarball.
+#
+# dist_test_scripts, dist_test_data, dist_test_extra_scripts
+# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
+# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
+#
+# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows
the
+# standard automake convention of not disting programs scripts or data by default.
+#
+# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their
disted
+# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
+# gtester. That's a bit strange for scripts, but it's possible.
+
+TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
+ $(dist_test_scripts) $(dist_uninstalled_test_scripts)
+
+# Note: build even the installed-only targets during 'make check' to ensure that they still work.
+# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
+# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
+# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
+all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
+ $(test_extra_programs) $(uninstalled_test_extra_programs)
$(installed_test_extra_programs)
+all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
+ $(test_extra_scripts) $(uninstalled_test_extra_scripts)
$(installed_test_extra_scripts)
+all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts)
\
+ $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts)
$(dist_installed_test_extra_scripts)
+all_test_scripts += $(all_dist_test_scripts)
+EXTRA_DIST += $(all_dist_test_scripts)
+all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data)
+all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
+all_test_data += $(all_dist_test_data)
+EXTRA_DIST += $(all_dist_test_data)
+all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
+
+check_LTLIBRARIES += $(all_test_ltlibs)
+check_PROGRAMS += $(all_test_programs)
+check_SCRIPTS += $(all_test_scripts)
+check_DATA += $(all_test_data)
+
diff --git a/libgda/gda-ddl-base.c b/libgda/gda-ddl-base.c
index 112ff6705..aee1a8dec 100644
--- a/libgda/gda-ddl-base.c
+++ b/libgda/gda-ddl-base.c
@@ -18,9 +18,6 @@
#include "gda-ddl-base.h"
#include <glib/gi18n.h>
-
-G_DEFINE_QUARK (gda_ddl_base_error,gda_ddl_base_error)
-
typedef struct
{
gchar *m_catalog;
@@ -36,12 +33,19 @@ enum {
PROP_CATALOG,
PROP_SCHEMA,
PROP_NAME,
- /*<prvate>*/
+ /*<private>*/
N_PROPS
};
-static GParamSpec *properties [N_PROPS];
+static GParamSpec *properties [N_PROPS] = {NULL};
+/**
+ * gda_ddl_base_new:
+ *
+ * Create a new #GdaDdlBase instance
+ *
+ * Returns: #GdaDdlBase instance
+ */
GdaDdlBase *
gda_ddl_base_new (void)
{
@@ -141,99 +145,72 @@ gda_ddl_base_init (GdaDdlBase *self)
* @schema: a schema associated with table
* @name: a table name associated with table
*
- * Allow to set table name. @catalog and @schema can be %NULL but
- * @name always should be a valid, not %NULL string. The @name must be alsways
+ * Sets database object name. @catalog and @schema can be %NULL but
+ * @name always should be a valid, not %NULL string. The @name must be always
* set. If @catalog is %NULL @schema may not be %NULL but if @schema is
* %NULL @catalog also should be %NULL.
*
* Since: 6.0
* */
-gboolean
+void
gda_ddl_base_set_names (GdaDdlBase *self,
const gchar* catalog,
const gchar* schema,
- const gchar* name,
- GError **error)
+ const gchar* name)
{
- g_return_val_if_fail (self,FALSE);
-
- if (!name) {
- g_set_error (error,GDA_DDL_BASE_ERROR,
- GDA_DDL_BASE_UNVALID_NAME,
- _("Provided table name can't be null\n"));
- return FALSE;
- }
-
- /* Check if catalog NULL but schema is not NULL */
- if (catalog && !schema) {
- g_set_error (error,GDA_DDL_BASE_ERROR,
- GDA_DDL_BASE_NAME_MISSMATCH,
- _("Schema name is not set while catalog name is set\n"));
- return FALSE;
- }
+ g_return_if_fail (self);
+ g_return_if_fail (name);
GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
g_free (priv->m_name);
- priv->m_name = g_strdup (name);
-
g_free (priv->m_schema);
g_free (priv->m_catalog);
+ g_free (priv->m_fullname);
+
+ priv->m_name = g_strdup (name);
+ priv->m_schema = NULL;
+ priv->m_catalog = NULL;
if (schema)
priv->m_schema = g_strdup (schema);
- else
- priv->m_catalog = NULL;
if (catalog)
priv->m_catalog = g_strdup (catalog);
- else
- priv->m_catalog = NULL;
-
- g_free (priv->m_fullname);
GString *fullnamestr = NULL;
fullnamestr = g_string_new (NULL);
- if (priv->m_catalog && priv->m_schema) {
+ if (priv->m_catalog && priv->m_schema)
g_string_printf (fullnamestr,"%s.%s.%s",priv->m_catalog,priv->m_schema,priv->m_name);
- } else {
- /* In this block catalog is NULL */
- if (priv->m_schema)
- g_string_printf (fullnamestr,"%s.%s",priv->m_schema,priv->m_name);
- else
- g_string_printf (fullnamestr,"%s",priv->m_name);
- }
+ else if (priv->m_schema)
+ g_string_printf (fullnamestr,"%s.%s",priv->m_schema,priv->m_name);
+ else
+ g_string_printf (fullnamestr,"%s",priv->m_name);
priv->m_fullname = g_strdup (fullnamestr->str);
g_string_free (fullnamestr, TRUE);
- return TRUE;
}
/**
* gda_ddl_base_get_full_name:
+ * @self: an instance of #GdaDdlBase
*
- * If NULL is returned, database
- * object name hasn't been set yet.
+ * This method returns full name in the format catalog.schema.name.
+ * If schema is %NULL but catalog and name are not, then only name is
+ * returned. If catalog is %NULL then full name will be in the format:
+ * schema.name. If all three components are not set, then %NULL is returned.
*
- * Returns: Full name of the database object. This string should not be freed.
+ * Returns: Full name of the database object.
*/
const gchar*
-gda_ddl_base_get_full_name (GdaDdlBase *self,
- GError **error)
+gda_ddl_base_get_full_name (GdaDdlBase *self)
{
g_return_val_if_fail (self,NULL);
GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
- /* if (!priv->m_fullname) { */
- /* g_set_error (error,GDA_DDL_BASE_ERROR, */
- /* GDA_DDL_BASE_NAME_IS_NULL, */
- /* _("Name is NULL. It should be set before use.\n")); */
- /* return NULL; */
- /* } */
-
GString *fullnamestr = NULL;
fullnamestr = g_string_new (NULL);
@@ -244,14 +221,9 @@ gda_ddl_base_get_full_name (GdaDdlBase *self,
g_string_printf (fullnamestr,"%s.%s",priv->m_schema,priv->m_name);
else if (priv->m_name)
g_string_printf (fullnamestr,"%s",priv->m_name);
- else {
- g_set_error (error,GDA_DDL_BASE_ERROR,
- GDA_DDL_BASE_NAME_IS_NULL,
- _("Name is NULL. It should be set before use.\n"));
+ else
return NULL;
- }
- /* In this block catalog is NULL */
priv->m_fullname = g_strdup (fullnamestr->str);
g_string_free (fullnamestr, TRUE);
@@ -262,28 +234,19 @@ gda_ddl_base_get_full_name (GdaDdlBase *self,
* gda_ddl_base_get_catalog:
*
* @self: GdaDdlBase object
- * @error: an error holder
*
* Returns current catalog name. The returned string should not be freed.
* In case of error, the @error is set appropriatly and %NULL is returned.
*
- * Returns: Current catalog or NULL
+ * Returns: Current catalog or %NULL
*/
const gchar*
-gda_ddl_base_get_catalog (GdaDdlBase *self,
- GError **error)
+gda_ddl_base_get_catalog (GdaDdlBase *self)
{
g_return_val_if_fail (self,NULL);
GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
- if (!priv->m_catalog) {
- g_set_error (error,GDA_DDL_BASE_ERROR,
- GDA_DDL_BASE_NAME_IS_NULL,
- _("Catalog is NULL. It should be set before use.\n"));
- return NULL;
- }
-
return priv->m_catalog;
}
@@ -291,28 +254,18 @@ gda_ddl_base_get_catalog (GdaDdlBase *self,
* gda_ddl_base_get_schema:
*
* @self: GdaDdlBase object
- * @error: an error holder
*
* Returns current schema name. The returned string should not be freed.
- * In case of error, the @error is set appropriatly and %NULL is returned.
*
- * Returns: Current catalog or NULL
+ * Returns: Current catalog or %NULL
*/
const gchar*
-gda_ddl_base_get_schema (GdaDdlBase *self,
- GError **error)
+gda_ddl_base_get_schema (GdaDdlBase *self)
{
g_return_val_if_fail (self,NULL);
GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
- if (!priv->m_schema) {
- g_set_error (error,GDA_DDL_BASE_ERROR,
- GDA_DDL_BASE_NAME_IS_NULL,
- _("Schema is NULL. It should be set before use.\n"));
- return NULL;
- }
-
return priv->m_schema;
}
@@ -323,35 +276,39 @@ gda_ddl_base_get_schema (GdaDdlBase *self,
* @error: an error holder
*
* Returns current object name. The returned string should not be freed.
- * In case of error, the @error is set appropriatly and %NULL is returned.
*
- * Returns: Current catalog or NULL
+ * Returns: Current object name or %NULL
*/
const gchar*
-gda_ddl_base_get_name (GdaDdlBase *self,
- GError **error)
+gda_ddl_base_get_name (GdaDdlBase *self)
{
g_return_val_if_fail (self,NULL);
GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
- if (!priv->m_name) {
- g_set_error (error,GDA_DDL_BASE_ERROR,
- GDA_DDL_BASE_NAME_IS_NULL,
- _("Name is NULL. It should be set before use.\n"));
- return NULL;
- }
-
return priv->m_name;
}
-
+/**
+ * gda_ddl_base_free:
+ * @self: an instance of #GdaDdlBase to free.
+ * A convenient method to free the memory.
+ * It is a wrapper around g_clear_object().
+ *
+ */
void
gda_ddl_base_free (GdaDdlBase *self)
{
g_clear_object (&self);
}
+/**
+ * gda_ddl_base_set_catalog:
+ *
+ * @self: a #GdaDdlBase instance
+ * @catalog: Catalog name as a string
+ *
+ */
void
gda_ddl_base_set_catalog (GdaDdlBase *self,
const gchar *catalog)
@@ -364,6 +321,13 @@ gda_ddl_base_set_catalog (GdaDdlBase *self,
priv->m_catalog = g_strdup (catalog);
}
+/**
+ * gda_ddl_base_set_schema:
+ *
+ * @self: a #GdaDdlBase instance
+ * @schema: Schema name as a string
+ *
+ */
void
gda_ddl_base_set_schema (GdaDdlBase *self,
const gchar *schema)
@@ -376,6 +340,13 @@ gda_ddl_base_set_schema (GdaDdlBase *self,
priv->m_schema = g_strdup (schema);
}
+/**
+ * gda_ddl_base_set_name:
+ *
+ * @self: a #GdaDdlBase instance
+ * @name: Object name as a string
+ *
+ */
void
gda_ddl_base_set_name (GdaDdlBase *self,
const gchar *name)
diff --git a/libgda/gda-ddl-base.h b/libgda/gda-ddl-base.h
index cda28085b..cd7fc3d11 100644
--- a/libgda/gda-ddl-base.h
+++ b/libgda/gda-ddl-base.h
@@ -33,34 +33,23 @@ struct _GdaDdlBaseClass
GObjectClass parent;
};
-typedef enum {
- GDA_DDL_BASE_UNVALID_NAME,
- GDA_DDL_BASE_NAME_MISSMATCH,
- GDA_DDL_BASE_FULLNAME,
- GDA_DDL_BASE_NAME_IS_NULL
-}GdaDdlBaseError;
-
-#define GDA_DDL_BASE_ERROR gda_ddl_base_error_quark()
-GQuark gda_ddl_base_error_quark(void);
-
GdaDdlBase* gda_ddl_base_new (void);
-gboolean gda_ddl_base_set_names (GdaDdlBase *self,
+void gda_ddl_base_set_names (GdaDdlBase *self,
const gchar *catalog,
const gchar *schema,
- const gchar *name,
- GError **error);
+ const gchar *name);
-const gchar* gda_ddl_base_get_full_name (GdaDdlBase *self, GError **error);
-const gchar* gda_ddl_base_get_name (GdaDdlBase *self, GError **error);
+const gchar* gda_ddl_base_get_full_name (GdaDdlBase *self);
+const gchar* gda_ddl_base_get_name (GdaDdlBase *self);
void gda_ddl_base_set_name (GdaDdlBase *self,
const gchar *name);
-const gchar* gda_ddl_base_get_catalog (GdaDdlBase *self, GError **error);
+const gchar* gda_ddl_base_get_catalog (GdaDdlBase *self);
void gda_ddl_base_set_catalog (GdaDdlBase *self,
const gchar
*catalog);
-const gchar* gda_ddl_base_get_schema (GdaDdlBase *self, GError **error);
+const gchar* gda_ddl_base_get_schema (GdaDdlBase *self);
void gda_ddl_base_set_schema (GdaDdlBase *self,
const gchar *name);
diff --git a/m4/glibtests.m4 b/m4/glibtests.m4
new file mode 100644
index 000000000..581726a51
--- /dev/null
+++ b/m4/glibtests.m4
@@ -0,0 +1,31 @@
+# Increment this whenever this file is changed.
+#serial 1
+
+dnl GLIB_TESTS
+dnl
+
+AC_DEFUN([GLIB_TESTS],
+[
+ AC_ARG_ENABLE(installed-tests,
+ AS_HELP_STRING([--enable-installed-tests],
+ [Enable installation of some test cases]),
+ [case ${enableval} in
+ yes) ENABLE_INSTALLED_TESTS="1" ;;
+ no) ENABLE_INSTALLED_TESTS="" ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-installed-tests]) ;;
+ esac])
+ AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], test "$ENABLE_INSTALLED_TESTS" = "1")
+ AC_ARG_ENABLE(always-build-tests,
+ AS_HELP_STRING([--enable-always-build-tests],
+ [Enable always building tests during 'make all']),
+ [case ${enableval} in
+ yes) ENABLE_ALWAYS_BUILD_TESTS="1" ;;
+ no) ENABLE_ALWAYS_BUILD_TESTS="" ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-always-build-tests]) ;;
+ esac])
+ AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS], test "$ENABLE_ALWAYS_BUILD_TESTS" = "1")
+ if test "$ENABLE_INSTALLED_TESTS" = "1"; then
+ AC_SUBST(installed_test_metadir, [${datadir}/installed-tests/]AC_PACKAGE_NAME)
+ AC_SUBST(installed_testdir, [${libexecdir}/installed-tests/]AC_PACKAGE_NAME)
+ fi
+])
diff --git a/tap-driver.sh b/tap-driver.sh
new file mode 100755
index 000000000..64e3eb674
--- /dev/null
+++ b/tap-driver.sh
@@ -0,0 +1,652 @@
+#! /bin/sh
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake gnu org> or send patches to
+# <automake-patches gnu org>.
+
+scriptversion=2011-12-27.17; # UTC
+
+# Make unconditional expansion of undefined variables an error. This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+me=tap-driver.sh
+
+fatal ()
+{
+ echo "$me: fatal: $*" >&2
+ exit 1
+}
+
+usage_error ()
+{
+ echo "$me: $*" >&2
+ print_usage >&2
+ exit 2
+}
+
+print_usage ()
+{
+ cat <<END
+Usage:
+ tap-driver.sh --test-name=NAME --log-file=PATH --trs-file=PATH
+ [--expect-failure={yes|no}] [--color-tests={yes|no}]
+ [--enable-hard-errors={yes|no}] [--ignore-exit]
+ [--diagnostic-string=STRING] [--merge|--no-merge]
+ [--comments|--no-comments] [--] TEST-COMMAND
+The \`--test-name', \`--log-file' and \`--trs-file' options are mandatory.
+END
+}
+
+# TODO: better error handling in option parsing (in particular, ensure
+# TODO: $log_file, $trs_file and $test_name are defined).
+test_name= # Used for reporting.
+log_file= # Where to save the result and output of the test script.
+trs_file= # Where to save the metadata of the test run.
+expect_failure=0
+color_tests=0
+merge=0
+ignore_exit=0
+comments=0
+diag_string='#'
+while test $# -gt 0; do
+ case $1 in
+ --help) print_usage; exit $?;;
+ --version) echo "$me $scriptversion"; exit $?;;
+ --test-name) test_name=$2; shift;;
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --color-tests) color_tests=$2; shift;;
+ --expect-failure) expect_failure=$2; shift;;
+ --enable-hard-errors) shift;; # No-op.
+ --merge) merge=1;;
+ --no-merge) merge=0;;
+ --ignore-exit) ignore_exit=1;;
+ --comments) comments=1;;
+ --no-comments) comments=0;;
+ --diagnostic-string) diag_string=$2; shift;;
+ --) shift; break;;
+ -*) usage_error "invalid option: '$1'";;
+ esac
+ shift
+done
+
+test $# -gt 0 || usage_error "missing test command"
+
+case $expect_failure in
+ yes) expect_failure=1;;
+ *) expect_failure=0;;
+esac
+
+if test $color_tests = yes; then
+ init_colors='
+ color_map["red"]="[0;31m" # Red.
+ color_map["grn"]="[0;32m" # Green.
+ color_map["lgn"]="[1;32m" # Light green.
+ color_map["blu"]="[1;34m" # Blue.
+ color_map["mgn"]="[0;35m" # Magenta.
+ color_map["std"]="[m" # No color.
+ color_for_result["ERROR"] = "mgn"
+ color_for_result["PASS"] = "grn"
+ color_for_result["XPASS"] = "red"
+ color_for_result["FAIL"] = "red"
+ color_for_result["XFAIL"] = "lgn"
+ color_for_result["SKIP"] = "blu"'
+else
+ init_colors=''
+fi
+
+# :; is there to work around a bug in bash 3.2 (and earlier) which
+# does not always set '$?' properly on redirection failure.
+# See the Autoconf manual for more details.
+:;{
+ (
+ # Ignore common signals (in this subshell only!), to avoid potential
+ # problems with Korn shells. Some Korn shells are known to propagate
+ # to themselves signals that have killed a child process they were
+ # waiting for; this is done at least for SIGINT (and usually only for
+ # it, in truth). Without the `trap' below, such a behaviour could
+ # cause a premature exit in the current subshell, e.g., in case the
+ # test command it runs gets terminated by a SIGINT. Thus, the awk
+ # script we are piping into would never seen the exit status it
+ # expects on its last input line (which is displayed below by the
+ # last `echo $?' statement), and would thus die reporting an internal
+ # error.
+ # For more information, see the Autoconf manual and the threads:
+ # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+ # <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
+ trap : 1 3 2 13 15
+ if test $merge -gt 0; then
+ exec 2>&1
+ else
+ exec 2>&3
+ fi
+ "$@"
+ echo $?
+ ) | LC_ALL=C ${AM_TAP_AWK-awk} \
+ -v me="$me" \
+ -v test_script_name="$test_name" \
+ -v log_file="$log_file" \
+ -v trs_file="$trs_file" \
+ -v expect_failure="$expect_failure" \
+ -v merge="$merge" \
+ -v ignore_exit="$ignore_exit" \
+ -v comments="$comments" \
+ -v diag_string="$diag_string" \
+'
+# FIXME: the usages of "cat >&3" below could be optimized when using
+# FIXME: GNU awk, and/or on systems that supports /dev/fd/.
+
+# Implementation note: in what follows, `result_obj` will be an
+# associative array that (partly) simulates a TAP result object
+# from the `TAP::Parser` perl module.
+
+## ----------- ##
+## FUNCTIONS ##
+## ----------- ##
+
+function fatal(msg)
+{
+ print me ": " msg | "cat >&2"
+ exit 1
+}
+
+function abort(where)
+{
+ fatal("internal error " where)
+}
+
+# Convert a boolean to a "yes"/"no" string.
+function yn(bool)
+{
+ return bool ? "yes" : "no";
+}
+
+function add_test_result(result)
+{
+ if (!test_results_index)
+ test_results_index = 0
+ test_results_list[test_results_index] = result
+ test_results_index += 1
+ test_results_seen[result] = 1;
+}
+
+# Whether the test script should be re-run by "make recheck".
+function must_recheck()
+{
+ for (k in test_results_seen)
+ if (k != "XFAIL" && k != "PASS" && k != "SKIP")
+ return 1
+ return 0
+}
+
+# Whether the content of the log file associated to this test should
+# be copied into the "global" test-suite.log.
+function copy_in_global_log()
+{
+ for (k in test_results_seen)
+ if (k != "PASS")
+ return 1
+ return 0
+}
+
+# FIXME: this can certainly be improved ...
+function get_global_test_result()
+{
+ if ("ERROR" in test_results_seen)
+ return "ERROR"
+ if ("FAIL" in test_results_seen || "XPASS" in test_results_seen)
+ return "FAIL"
+ all_skipped = 1
+ for (k in test_results_seen)
+ if (k != "SKIP")
+ all_skipped = 0
+ if (all_skipped)
+ return "SKIP"
+ return "PASS";
+}
+
+function stringify_result_obj(result_obj)
+{
+ if (result_obj["is_unplanned"] || result_obj["number"] != testno)
+ return "ERROR"
+
+ if (plan_seen == LATE_PLAN)
+ return "ERROR"
+
+ if (result_obj["directive"] == "TODO")
+ return result_obj["is_ok"] ? "XPASS" : "XFAIL"
+
+ if (result_obj["directive"] == "SKIP")
+ return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL;
+
+ if (length(result_obj["directive"]))
+ abort("in function stringify_result_obj()")
+
+ return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL
+}
+
+function decorate_result(result)
+{
+ color_name = color_for_result[result]
+ if (color_name)
+ return color_map[color_name] "" result "" color_map["std"]
+ # If we are not using colorized output, or if we do not know how
+ # to colorize the given result, we should return it unchanged.
+ return result
+}
+
+function report(result, details)
+{
+ if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/)
+ {
+ msg = ": " test_script_name
+ add_test_result(result)
+ }
+ else if (result == "#")
+ {
+ msg = " " test_script_name ":"
+ }
+ else
+ {
+ abort("in function report()")
+ }
+ if (length(details))
+ msg = msg " " details
+ # Output on console might be colorized.
+ print decorate_result(result) msg
+ # Log the result in the log file too, to help debugging (this is
+ # especially true when said result is a TAP error or "Bail out!").
+ print result msg | "cat >&3";
+}
+
+function testsuite_error(error_message)
+{
+ report("ERROR", "- " error_message)
+}
+
+function handle_tap_result()
+{
+ details = result_obj["number"];
+ if (length(result_obj["description"]))
+ details = details " " result_obj["description"]
+
+ if (plan_seen == LATE_PLAN)
+ {
+ details = details " # AFTER LATE PLAN";
+ }
+ else if (result_obj["is_unplanned"])
+ {
+ details = details " # UNPLANNED";
+ }
+ else if (result_obj["number"] != testno)
+ {
+ details = sprintf("%s # OUT-OF-ORDER (expecting %d)",
+ details, testno);
+ }
+ else if (result_obj["directive"])
+ {
+ details = details " # " result_obj["directive"];
+ if (length(result_obj["explanation"]))
+ details = details " " result_obj["explanation"]
+ }
+
+ report(stringify_result_obj(result_obj), details)
+}
+
+# `skip_reason` should be empty whenever planned > 0.
+function handle_tap_plan(planned, skip_reason)
+{
+ planned += 0 # Avoid getting confused if, say, `planned` is "00"
+ if (length(skip_reason) && planned > 0)
+ abort("in function handle_tap_plan()")
+ if (plan_seen)
+ {
+ # Error, only one plan per stream is acceptable.
+ testsuite_error("multiple test plans")
+ return;
+ }
+ planned_tests = planned
+ # The TAP plan can come before or after *all* the TAP results; we speak
+ # respectively of an "early" or a "late" plan. If we see the plan line
+ # after at least one TAP result has been seen, assume we have a late
+ # plan; in this case, any further test result seen after the plan will
+ # be flagged as an error.
+ plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN)
+ # If testno > 0, we have an error ("too many tests run") that will be
+ # automatically dealt with later, so do not worry about it here. If
+ # $plan_seen is true, we have an error due to a repeated plan, and that
+ # has already been dealt with above. Otherwise, we have a valid "plan
+ # with SKIP" specification, and should report it as a particular kind
+ # of SKIP result.
+ if (planned == 0 && testno == 0)
+ {
+ if (length(skip_reason))
+ skip_reason = "- " skip_reason;
+ report("SKIP", skip_reason);
+ }
+}
+
+function extract_tap_comment(line)
+{
+ if (index(line, diag_string) == 1)
+ {
+ # Strip leading `diag_string` from `line`.
+ line = substr(line, length(diag_string) + 1)
+ # And strip any leading and trailing whitespace left.
+ sub("^[ \t]*", "", line)
+ sub("[ \t]*$", "", line)
+ # Return what is left (if any).
+ return line;
+ }
+ return "";
+}
+
+# When this function is called, we know that line is a TAP result line,
+# so that it matches the (perl) RE "^(not )?ok\b".
+function setup_result_obj(line)
+{
+ # Get the result, and remove it from the line.
+ result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0)
+ sub("^(not )?ok[ \t]*", "", line)
+
+ # If the result has an explicit number, get it and strip it; otherwise,
+ # automatically assing the next progresive number to it.
+ if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/)
+ {
+ match(line, "^[0-9]+")
+ # The final `+ 0` is to normalize numbers with leading zeros.
+ result_obj["number"] = substr(line, 1, RLENGTH) + 0
+ line = substr(line, RLENGTH + 1)
+ }
+ else
+ {
+ result_obj["number"] = testno
+ }
+
+ if (plan_seen == LATE_PLAN)
+ # No further test results are acceptable after a "late" TAP plan
+ # has been seen.
+ result_obj["is_unplanned"] = 1
+ else if (plan_seen && testno > planned_tests)
+ result_obj["is_unplanned"] = 1
+ else
+ result_obj["is_unplanned"] = 0
+
+ # Strip trailing and leading whitespace.
+ sub("^[ \t]*", "", line)
+ sub("[ \t]*$", "", line)
+
+ # This will have to be corrected if we have a "TODO"/"SKIP" directive.
+ result_obj["description"] = line
+ result_obj["directive"] = ""
+ result_obj["explanation"] = ""
+
+ if (index(line, "#") == 0)
+ return # No possible directive, nothing more to do.
+
+ # Directives are case-insensitive.
+ rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*"
+
+ # See whether we have the directive, and if yes, where.
+ pos = match(line, rx "$")
+ if (!pos)
+ pos = match(line, rx "[^a-zA-Z0-9_]")
+
+ # If there was no TAP directive, we have nothing more to do.
+ if (!pos)
+ return
+
+ # Let`s now see if the TAP directive has been escaped. For example:
+ # escaped: ok \# SKIP
+ # not escaped: ok \\# SKIP
+ # escaped: ok \\\\\# SKIP
+ # not escaped: ok \ # SKIP
+ if (substr(line, pos, 1) == "#")
+ {
+ bslash_count = 0
+ for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--)
+ bslash_count += 1
+ if (bslash_count % 2)
+ return # Directive was escaped.
+ }
+
+ # Strip the directive and its explanation (if any) from the test
+ # description.
+ result_obj["description"] = substr(line, 1, pos - 1)
+ # Now remove the test description from the line, that has been dealt
+ # with already.
+ line = substr(line, pos)
+ # Strip the directive, and save its value (normalized to upper case).
+ sub("^[ \t]*#[ \t]*", "", line)
+ result_obj["directive"] = toupper(substr(line, 1, 4))
+ line = substr(line, 5)
+ # Now get the explanation for the directive (if any), with leading
+ # and trailing whitespace removed.
+ sub("^[ \t]*", "", line)
+ sub("[ \t]*$", "", line)
+ result_obj["explanation"] = line
+}
+
+function get_test_exit_message(status)
+{
+ if (status == 0)
+ return ""
+ if (status !~ /^[1-9][0-9]*$/)
+ abort("getting exit status")
+ if (status < 127)
+ exit_details = ""
+ else if (status == 127)
+ exit_details = " (command not found?)"
+ else if (status >= 128 && status <= 255)
+ exit_details = sprintf(" (terminated by signal %d?)", status - 128)
+ else if (status > 256 && status <= 384)
+ # We used to report an "abnormal termination" here, but some Korn
+ # shells, when a child process die due to signal number n, can leave
+ # in $? an exit status of 256+n instead of the more standard 128+n.
+ # Apparently, both behaviours are allowed by POSIX (2008), so be
+ # prepared to handle them both. See also Austing Group report ID
+ # 0000051 <http://www.austingroupbugs.net/view.php?id=51>
+ exit_details = sprintf(" (terminated by signal %d?)", status - 256)
+ else
+ # Never seen in practice.
+ exit_details = " (abnormal termination)"
+ return sprintf("exited with status %d%s", status, exit_details)
+}
+
+function write_test_results()
+{
+ print ":global-test-result: " get_global_test_result() > trs_file
+ print ":recheck: " yn(must_recheck()) > trs_file
+ print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file
+ for (i = 0; i < test_results_index; i += 1)
+ print ":test-result: " test_results_list[i] > trs_file
+ close(trs_file);
+}
+
+BEGIN {
+
+## ------- ##
+## SETUP ##
+## ------- ##
+
+'"$init_colors"'
+
+# Properly initialized once the TAP plan is seen.
+planned_tests = 0
+
+COOKED_PASS = expect_failure ? "XPASS": "PASS";
+COOKED_FAIL = expect_failure ? "XFAIL": "FAIL";
+
+# Enumeration-like constants to remember which kind of plan (if any)
+# has been seen. It is important that NO_PLAN evaluates "false" as
+# a boolean.
+NO_PLAN = 0
+EARLY_PLAN = 1
+LATE_PLAN = 2
+
+testno = 0 # Number of test results seen so far.
+bailed_out = 0 # Whether a "Bail out!" directive has been seen.
+
+# Whether the TAP plan has been seen or not, and if yes, which kind
+# it is ("early" is seen before any test result, "late" otherwise).
+plan_seen = NO_PLAN
+
+## --------- ##
+## PARSING ##
+## --------- ##
+
+is_first_read = 1
+
+while (1)
+ {
+ # Involutions required so that we are able to read the exit status
+ # from the last input line.
+ st = getline
+ if (st < 0) # I/O error.
+ fatal("I/O error while reading from input stream")
+ else if (st == 0) # End-of-input
+ {
+ if (is_first_read)
+ abort("in input loop: only one input line")
+ break
+ }
+ if (is_first_read)
+ {
+ is_first_read = 0
+ nextline = $0
+ continue
+ }
+ else
+ {
+ curline = nextline
+ nextline = $0
+ $0 = curline
+ }
+ # Copy any input line verbatim into the log file.
+ print | "cat >&3"
+ # Parsing of TAP input should stop after a "Bail out!" directive.
+ if (bailed_out)
+ continue
+
+ # TAP test result.
+ if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/)
+ {
+ testno += 1
+ setup_result_obj($0)
+ handle_tap_result()
+ }
+ # TAP plan (normal or "SKIP" without explanation).
+ else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/)
+ {
+ # The next two lines will put the number of planned tests in $0.
+ sub("^1\\.\\.", "")
+ sub("[^0-9]*$", "")
+ handle_tap_plan($0, "")
+ continue
+ }
+ # TAP "SKIP" plan, with an explanation.
+ else if ($0 ~ /^1\.\.0+[ \t]*#/)
+ {
+ # The next lines will put the skip explanation in $0, stripping
+ # any leading and trailing whitespace. This is a little more
+ # tricky in truth, since we want to also strip a potential leading
+ # "SKIP" string from the message.
+ sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "")
+ sub("[ \t]*$", "");
+ handle_tap_plan(0, $0)
+ }
+ # "Bail out!" magic.
+ # Older versions of prove and TAP::Harness (e.g., 3.17) did not
+ # recognize a "Bail out!" directive when preceded by leading
+ # whitespace, but more modern versions (e.g., 3.23) do. So we
+ # emulate the latter, "more modern" behaviour.
+ else if ($0 ~ /^[ \t]*Bail out!/)
+ {
+ bailed_out = 1
+ # Get the bailout message (if any), with leading and trailing
+ # whitespace stripped. The message remains stored in `$0`.
+ sub("^[ \t]*Bail out![ \t]*", "");
+ sub("[ \t]*$", "");
+ # Format the error message for the
+ bailout_message = "Bail out!"
+ if (length($0))
+ bailout_message = bailout_message " " $0
+ testsuite_error(bailout_message)
+ }
+ # Maybe we have too look for dianogtic comments too.
+ else if (comments != 0)
+ {
+ comment = extract_tap_comment($0);
+ if (length(comment))
+ report("#", comment);
+ }
+ }
+
+## -------- ##
+## FINISH ##
+## -------- ##
+
+# A "Bail out!" directive should cause us to ignore any following TAP
+# error, as well as a non-zero exit status from the TAP producer.
+if (!bailed_out)
+ {
+ if (!plan_seen)
+ {
+ testsuite_error("missing test plan")
+ }
+ else if (planned_tests != testno)
+ {
+ bad_amount = testno > planned_tests ? "many" : "few"
+ testsuite_error(sprintf("too %s tests run (expected %d, got %d)",
+ bad_amount, planned_tests, testno))
+ }
+ if (!ignore_exit)
+ {
+ # Fetch exit status from the last line.
+ exit_message = get_test_exit_message(nextline)
+ if (exit_message)
+ testsuite_error(exit_message)
+ }
+ }
+
+write_test_results()
+
+exit 0
+
+} # End of "BEGIN" block.
+'
+
+# TODO: document that we consume the file descriptor 3 :-(
+} 3>"$log_file"
+
+test $? -eq 0 || fatal "I/O or internal error"
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8487455c5..e314fb993 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,7 +12,7 @@ if HAVE_UI
UI_EXTENSION = ui
endif
-SUBDIRS = providers parser value-holders meta-store data-models multi-threading $(UI_EXTENSION)
$(VALA_EXTENSIONS)
+SUBDIRS = providers parser value-holders meta-store data-models multi-threading ddl $(UI_EXTENSION)
$(VALA_EXTENSIONS)
AM_CPPFLAGS = \
-I$(top_builddir) \
diff --git a/tests/ddl/check-ddl-base.c b/tests/ddl/check-ddl-base.c
index f114421f5..b2cf11539 100644
--- a/tests/ddl/check-ddl-base.c
+++ b/tests/ddl/check-ddl-base.c
@@ -53,28 +53,21 @@ test_ddl_base_run1 (BaseFixture *self,
const gchar *schema = "Second";
const gchar *name = "Third";
- gboolean res = gda_ddl_base_set_names (self->obj,
- catalog,
- schema,
- name,
- NULL);
+ gda_ddl_base_set_names (self->obj,catalog,schema,name);
- g_assert_true (res);
-
-
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj,NULL);
+ const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
g_assert_cmpstr (ret_catalog, ==, catalog);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj,NULL);
+ const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
g_assert_cmpstr (ret_schema, ==, schema);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj,NULL);
+ const gchar *ret_name = gda_ddl_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj,NULL);
+ const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
g_assert_cmpstr (full_name, ==, "First.Second.Third");
}
@@ -89,23 +82,23 @@ test_ddl_base_run2 (BaseFixture *self,
gda_ddl_base_set_catalog (self->obj,catalog);
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj,NULL);
+ const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
g_assert_cmpstr (ret_catalog, ==, catalog);
gda_ddl_base_set_schema (self->obj,schema);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj,NULL);
+ const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
g_assert_cmpstr (ret_schema, ==, schema);
gda_ddl_base_set_name (self->obj,name);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj,NULL);
+ const gchar *ret_name = gda_ddl_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj,NULL);
+ const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
g_assert_cmpstr (full_name, ==, "First.Second.Third");
}
@@ -114,32 +107,24 @@ static void
test_ddl_base_run3 (BaseFixture *self,
gconstpointer user_data)
{
- const gchar *catalog = "First";
const gchar *schema = "Second";
const gchar *name = "Third";
- gboolean res = gda_ddl_base_set_names (self->obj,
- NULL,
- schema,
- name,
- NULL);
-
- g_assert_true (res);
+ gda_ddl_base_set_names (self->obj,NULL,schema,name);
-
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj,NULL);
+ const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
g_assert_cmpstr (ret_catalog, ==, NULL);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj,NULL);
+ const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
g_assert_cmpstr (ret_schema, ==, schema);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj,NULL);
+ const gchar *ret_name = gda_ddl_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj,NULL);
+ const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
g_assert_cmpstr (full_name, ==, "Second.Third");
@@ -149,17 +134,25 @@ static void
test_ddl_base_run4 (BaseFixture *self,
gconstpointer user_data)
{
- const gchar *catalog = "First";
- const gchar *schema = "Second";
const gchar *name = "Third";
- gboolean res = gda_ddl_base_set_names (self->obj,
- catalog,
- NULL,
- name,
- NULL);
+ gda_ddl_base_set_names (self->obj,NULL,NULL,name);
+
+ const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
+
+ g_assert_cmpstr (ret_catalog, ==, NULL);
+
+ const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
+
+ g_assert_cmpstr (ret_schema, ==, NULL);
+
+ const gchar *ret_name = gda_ddl_base_get_name (self->obj);
+
+ g_assert_cmpstr (ret_name, ==, name);
+
+ const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
- g_assert_false (res);
+ g_assert_cmpstr (full_name, ==, "Third");
}
static void
@@ -167,35 +160,27 @@ test_ddl_base_run5 (BaseFixture *self,
gconstpointer user_data)
{
const gchar *catalog = "First";
- const gchar *schema = "Second";
const gchar *name = "Third";
- gboolean res = gda_ddl_base_set_names (self->obj,
- NULL,
- NULL,
- name,
- NULL);
-
- g_assert_true (res);
-
-
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj,NULL);
-
- g_assert_cmpstr (ret_catalog, ==, NULL);
+ const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj,NULL);
+ g_assert_null (full_name);
- g_assert_cmpstr (ret_schema, ==, NULL);
+ gda_ddl_base_set_name (self->obj,name);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj,NULL);
+ const gchar *ret_name = gda_ddl_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj,NULL);
+ gda_ddl_base_set_catalog (self->obj,catalog);
- g_assert_cmpstr (full_name, ==, "Third");
-}
+ const gchar *full_name2 = gda_ddl_base_get_full_name (self->obj);
+ /* Only catalog and name are set.
+ * In this case only name should be returned.
+ */
+ g_assert_cmpstr (full_name2, ==, name);
+}
gint
main (gint argc,
@@ -227,14 +212,14 @@ main (gint argc,
test_ddl_base_run3,
test_ddl_base_finish);
- g_test_add ("/test-ddl/base-catalog-name",
+ g_test_add ("/test-ddl/base-name",
BaseFixture,
NULL,
test_ddl_base_start,
test_ddl_base_run4,
test_ddl_base_finish);
- g_test_add ("/test-ddl/base-name",
+ g_test_add ("/test-ddl/base-one",
BaseFixture,
NULL,
test_ddl_base_start,
diff --git a/tests/ddl/libgda-ddl-creator.dtd b/tests/ddl/libgda-ddl-creator.dtd
new file mode 100644
index 000000000..b97804363
--- /dev/null
+++ b/tests/ddl/libgda-ddl-creator.dtd
@@ -0,0 +1,44 @@
+<!-- libgda-ddl-creator.dtd
+ DTD for libgda's ddl objects
+ Version 1.0
+ Copyright (C) 2018 Pavlo Solntsev
+-->
+
+<!ELEMENT schema (table+, view*)>
+<!ATTLIST schema name ID #REQUIRED>
+
+<!ELEMENT table (comment?,column+, fkey*)>
+<!ATTLIST table temptable (TRUE|FALSE) "FALSE">
+<!ATTLIST table name ID #REQUIRED>
+<!ATTLIST table space CDATA #IMPLIED>
+
+<!ELEMENT column (comment?, size?, default?, check?)>
+<!ATTLIST column name ID #REQUIRED>
+<!ATTLIST column type CDATA #REQUIRED>
+<!ATTLIST column pkey (TRUE|FALSE) "FALSE">
+<!ATTLIST column unique (TRUE|FALSE) "FALSE">
+<!ATTLIST column autoinc (TRUE|FALSE) "FALSE">
+<!ATTLIST column nnul (TRUE|FALSE) "FALSE">
+
+<!ELEMENT comment (#PCDATA)>
+<!ELEMENT size (#PCDATA)>
+<!ELEMENT default (#PCDATA)>
+<!ELEMENT check (#PCDATA)>
+
+<!ELEMENT fkey (fk_field?)>
+<!ATTLIST fkey reftable IDREF #IMPLIED>
+<!ATTLIST fkey onupdate (RESTRICT|CASCADE|SET_NULL|NO_ACTION|SET_DEFAULT) #IMPLIED>
+<!ATTLIST fkey ondelete (RESTRICT|CASCADE|SET_NULL|NO_ACTION|SET_DEFAULT) #IMPLIED>
+
+<!ELEMENT fk_field (#PCDATA)>
+<!ATTLIST fk_field name IDREF #REQUIRED>
+<!ATTLIST fk_field reffield IDREF #REQUIRED>
+
+<!ELEMENT view (definition)>
+<!ATTLIST view name ID #REQUIRED>
+<!ATTLIST view replace (TRUE|FALSE) "FALSE">
+<!ATTLIST view temp (TRUE|FALSE) "FALSE">
+<!ATTLIST view ifnotexists (TRUE|FALSE) "TRUE">
+
+<!ELEMENT definition (#PCDATA)>
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]