Commit 888b9e06 authored by Pavlo Solntsev's avatar Pavlo Solntsev Committed by Daniel Espinosa Ortiz

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.
parent e6b90dd1
......@@ -1046,6 +1046,8 @@ tests/value-holders/Makefile
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
......
# 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)
......@@ -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)
......
......@@ -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);
......
# 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
])
#! /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"]="" # Red.
color_map["grn"]="" # Green.
color_map["lgn"]="" # Light green.
color_map["blu"]="" # Blue.
color_map["mgn"]="" # Magenta.
color_map["std"]="" # 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";
}