From 5e7dd9d43aad9eccb5fe6bc8ff6b1171f7ff3da8 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 24 Sep 2015 11:28:07 -0700 Subject: [PATCH] Fix distcheck. The trick in ff07762 that changing the automake default extension to cpp, thus forcing C++ linking even with C sources, while it worked, had the side-effect of breaking make-dist because it made automake look for *.cpp to put in the tarball and there weren't any such files. Instead, make the files which use test-engine-stuff.cpp also C++. --- src/app-utils/test/Makefile.am | 10 +++------- ...print-queries.c => test-print-queries.cpp} | 6 ++++-- ...ery-string.c => test-scm-query-string.cpp} | 6 ++++-- src/app-utils/test/{test-sx.c => test-sx.cpp} | 5 ++++- src/engine/test-core/test-engine-stuff.cpp | 8 +++++--- src/engine/test-core/test-engine-stuff.h | 5 +++-- src/engine/test/Makefile.am | 13 +++++++++++- ...count-object.c => test-account-object.cpp} | 6 ++++-- ...est-commodities.c => test-commodities.cpp} | 20 ++++++++++--------- .../test/{test-date.c => test-date.cpp} | 5 +++-- ...group-vs-book.c => test-group-vs-book.cpp} | 6 ++++-- .../test/{test-lots.c => test-lots.cpp} | 6 ++++-- .../test/{test-numeric.c => test-numeric.cpp} | 4 +++- .../test/{test-query.c => test-query.cpp} | 8 +++++--- .../{test-scm-query.c => test-scm-query.cpp} | 6 ++++-- ...vs-account.c => test-split-vs-account.cpp} | 4 +++- ...versal.c => test-transaction-reversal.cpp} | 18 +++++++++-------- ...voiding.c => test-transaction-voiding.cpp} | 6 ++++-- 18 files changed, 90 insertions(+), 52 deletions(-) rename src/app-utils/test/{test-print-queries.c => test-print-queries.cpp} (99%) rename src/app-utils/test/{test-scm-query-string.c => test-scm-query-string.cpp} (99%) rename src/app-utils/test/{test-sx.c => test-sx.cpp} (98%) rename src/engine/test/{test-account-object.c => test-account-object.cpp} (96%) rename src/engine/test/{test-commodities.c => test-commodities.cpp} (91%) rename src/engine/test/{test-date.c => test-date.cpp} (99%) rename src/engine/test/{test-group-vs-book.c => test-group-vs-book.cpp} (98%) rename src/engine/test/{test-lots.c => test-lots.cpp} (96%) rename src/engine/test/{test-numeric.c => test-numeric.cpp} (99%) rename src/engine/test/{test-query.c => test-query.cpp} (95%) rename src/engine/test/{test-scm-query.c => test-scm-query.cpp} (98%) rename src/engine/test/{test-split-vs-account.c => test-split-vs-account.cpp} (99%) rename src/engine/test/{test-transaction-reversal.c => test-transaction-reversal.cpp} (87%) rename src/engine/test/{test-transaction-voiding.c => test-transaction-voiding.cpp} (98%) diff --git a/src/app-utils/test/Makefile.am b/src/app-utils/test/Makefile.am index a8e759064c..8ff6b80fdc 100644 --- a/src/app-utils/test/Makefile.am +++ b/src/app-utils/test/Makefile.am @@ -8,17 +8,13 @@ check_PROGRAMS = \ test-sx \ test-app-utils -AM_DEFAULT_SOURCE_EXT = .cpp - TESTS = \ test-load-module \ ${check_PROGRAMS} -test_exp_parser_SOURCES = \ - test-exp-parser.c - -test_print_parse_amount_SOURCES = \ - test-print-parse-amount.cpp +test_scm_query_string_SOURCES = test-scm-query-string.cpp +test_sx_SOURCES = test-sx.cpp +test_print_parse_amount_SOURCES = test-print-parse-amount.cpp GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \ --gnc-module-dir ${top_builddir}/src/app-utils \ diff --git a/src/app-utils/test/test-print-queries.c b/src/app-utils/test/test-print-queries.cpp similarity index 99% rename from src/app-utils/test/test-print-queries.c rename to src/app-utils/test/test-print-queries.cpp index 5415ec2ea8..d396919f82 100644 --- a/src/app-utils/test/test-print-queries.c +++ b/src/app-utils/test/test-print-queries.cpp @@ -1,7 +1,9 @@ +#include +extern "C" +{ #include "config.h" #include -#include #include "guile-mappings.h" #include "engine-helpers-guile.h" @@ -10,7 +12,7 @@ #include "test-stuff.h" #include "Query.h" #include "TransLog.h" - +} static void test_query (Query *q, SCM val2str) diff --git a/src/app-utils/test/test-scm-query-string.c b/src/app-utils/test/test-scm-query-string.cpp similarity index 99% rename from src/app-utils/test/test-scm-query-string.c rename to src/app-utils/test/test-scm-query-string.cpp index e2831e8b09..f27ada2b9a 100644 --- a/src/app-utils/test/test-scm-query-string.c +++ b/src/app-utils/test/test-scm-query-string.cpp @@ -1,7 +1,9 @@ +#include +extern "C" +{ #include "config.h" #include -#include #include "guile-mappings.h" #include "engine-helpers-guile.h" @@ -11,7 +13,7 @@ #include "test-stuff.h" #include "Query.h" #include "TransLog.h" - +} static void test_query (Query *q, SCM val2str) diff --git a/src/app-utils/test/test-sx.c b/src/app-utils/test/test-sx.cpp similarity index 98% rename from src/app-utils/test/test-sx.c rename to src/app-utils/test/test-sx.cpp index 0cd4e8e769..713d6f2ce5 100644 --- a/src/app-utils/test/test-sx.c +++ b/src/app-utils/test/test-sx.cpp @@ -1,3 +1,5 @@ +extern "C" +{ #include "config.h" #include #include @@ -8,6 +10,7 @@ #include "test-stuff.h" #include "test-engine-stuff.h" +} static void test_basic() @@ -67,7 +70,7 @@ test_empty() GDate *end; GncSxInstanceModel *model; - end = g_date_new_dmy(31, 12, way_in_the_future_year); + end = g_date_new_dmy(31, (GDateMonth)12, way_in_the_future_year); model = gnc_sx_get_instances(end, TRUE); do_test(g_list_length(model->sx_instance_list) == 0, "no instances"); g_object_unref(G_OBJECT(model)); diff --git a/src/engine/test-core/test-engine-stuff.cpp b/src/engine/test-core/test-engine-stuff.cpp index 7dac8ef60b..202aef94b0 100644 --- a/src/engine/test-core/test-engine-stuff.cpp +++ b/src/engine/test-core/test-engine-stuff.cpp @@ -2133,7 +2133,8 @@ once_freq(const GDate *when) } static SchedXaction* -add_sx(gchar *name, const GDate *start, const GDate *end, const GDate *last_occur, Recurrence *r) +add_sx(const gchar *name, const GDate *start, const GDate *end, + const GDate *last_occur, Recurrence *r) { QofBook *book = qof_session_get_book(gnc_get_current_session()); SchedXaction *sx = xaccSchedXactionMalloc(book); @@ -2155,13 +2156,14 @@ add_sx(gchar *name, const GDate *start, const GDate *end, const GDate *last_occu } SchedXaction* -add_daily_sx(gchar *name, const GDate *start, const GDate *end, const GDate *last_occur) +add_daily_sx(const gchar *name, const GDate *start, + const GDate *end, const GDate *last_occur) { return add_sx(name, start, end, last_occur, daily_freq(start, 1)); } SchedXaction* -add_once_sx(gchar *name, const GDate *when) +add_once_sx(const gchar *name, const GDate *when) { return add_sx(name, when, NULL, NULL, once_freq(when)); } diff --git a/src/engine/test-core/test-engine-stuff.h b/src/engine/test-core/test-engine-stuff.h index c2a0019648..9a709491e7 100644 --- a/src/engine/test-core/test-engine-stuff.h +++ b/src/engine/test-core/test-engine-stuff.h @@ -99,8 +99,9 @@ void make_random_changes_to_level (QofBook *book, Account *parent); void make_random_changes_to_book (QofBook *book); void make_random_changes_to_session (QofSession *session); -SchedXaction* add_daily_sx(gchar *name, const GDate *start, const GDate *end, const GDate *last_occur); -SchedXaction* add_once_sx(gchar *name, const GDate *when); +SchedXaction* add_daily_sx(const gchar *name, const GDate *start, + const GDate *end, const GDate *last_occur); +SchedXaction* add_once_sx(const gchar *name, const GDate *when); void remove_sx(SchedXaction *sx); #ifdef __cplusplus diff --git a/src/engine/test/Makefile.am b/src/engine/test/Makefile.am index 35e3c43789..d9f7e5545a 100644 --- a/src/engine/test/Makefile.am +++ b/src/engine/test/Makefile.am @@ -68,6 +68,18 @@ GNC_TEST_DEPS = \ --library-dir ${top_builddir}/src/backend/xml \ --library-dir ${top_builddir}/src/backend/sql +test_account_object_SOURCES = test-account-object.cpp +test_commodities_SOURCES = test-commodities.cpp +test_date_SOURCES = test-date.cpp +test_group_vs_book_SOURCES = test-group-vs-book.cpp +test_lots_SOURCES = test-lots.cpp +test_numeric_SOURCES = test-numeric.cpp +test_query_SOURCES = test-query.cpp +test_scm_query_SOURCES = test-scm-query.cpp +test_split_vs_account_SOURCES = test-split-vs-account.cpp +test_transaction_reversal_SOURCES = test-transaction-reversal.cpp +test_transaction_voiding_SOURCES = test-transaction-voiding.cpp + TESTS_ENVIRONMENT = \ GUILE_WARN_DEPRECATED=no \ GUILE="${GUILE}" \ @@ -76,7 +88,6 @@ TESTS_ENVIRONMENT = \ $(shell ${abs_top_srcdir}/src/gnc-test-env.pl --noexports ${GNC_TEST_DEPS}) check_PROGRAMS = ${TEST_GROUP_1} ${TEST_GROUP_2} -AM_DEFAULT_SOURCE_EXT = .cpp TESTS = ${TEST_GROUP_1} test-create-account ${TEST_GROUP_2} diff --git a/src/engine/test/test-account-object.c b/src/engine/test/test-account-object.cpp similarity index 96% rename from src/engine/test/test-account-object.c rename to src/engine/test/test-account-object.cpp index b87bb22033..ccc4289157 100644 --- a/src/engine/test/test-account-object.c +++ b/src/engine/test/test-account-object.cpp @@ -24,7 +24,8 @@ * @brief Minimal test of reading/writing account parameters * @author David Hampton */ - +extern "C" +{ #include "config.h" #include #include @@ -34,6 +35,7 @@ #include "test-stuff.h" #include "test-engine-stuff.h" #include +} static void run_test (void) @@ -89,7 +91,7 @@ main (int argc, char **argv) /* Any tests that cause an error or warning to be printed * automatically fail! */ - g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING ); + g_log_set_always_fatal((GLogLevelFlags)(G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)); /* Set up a reproducible test-case */ srand(0); diff --git a/src/engine/test/test-commodities.c b/src/engine/test/test-commodities.cpp similarity index 91% rename from src/engine/test/test-commodities.c rename to src/engine/test/test-commodities.cpp index 821c06f35a..eaff9234c5 100644 --- a/src/engine/test/test-commodities.c +++ b/src/engine/test/test-commodities.cpp @@ -22,7 +22,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ - +extern "C" +{ #include "config.h" #include @@ -30,6 +31,7 @@ #include "qof.h" #include "test-engine-stuff.h" #include "test-stuff.h" +} static void test_commodity(void) @@ -50,7 +52,7 @@ test_commodity(void) { char *fullname; - const char *namespace; + const char *name_space; char *mnemonic; char *cusip; int fraction; @@ -59,12 +61,12 @@ test_commodity(void) book = qof_book_new (); fullname = get_random_string(); - namespace = get_random_commodity_namespace(); + name_space = get_random_commodity_namespace(); mnemonic = get_random_string(); cusip = get_random_string(); fraction = get_random_int_in_range(0, 10000); - com = gnc_commodity_new(book, fullname, namespace, mnemonic, + com = gnc_commodity_new(book, fullname, name_space, mnemonic, cusip, fraction); do_test( @@ -75,7 +77,7 @@ test_commodity(void) "fullnames equal test"); do_test( - g_strcmp0(namespace, gnc_commodity_get_namespace(com)) == 0, + g_strcmp0(name_space, gnc_commodity_get_namespace(com)) == 0, "namespace equal test"); do_test( @@ -96,10 +98,10 @@ test_commodity(void) g_strcmp0(fullname, gnc_commodity_get_fullname(com)) == 0, "reset fullnames equal test"); - namespace = get_random_commodity_namespace(); - gnc_commodity_set_namespace(com, namespace); + name_space = get_random_commodity_namespace(); + gnc_commodity_set_namespace(com, name_space); do_test( - g_strcmp0(namespace, gnc_commodity_get_namespace(com)) == 0, + g_strcmp0(name_space, gnc_commodity_get_namespace(com)) == 0, "reset namespace equal test"); mnemonic = get_random_string(); @@ -120,7 +122,7 @@ test_commodity(void) gnc_commodity_get_fraction(com) == fraction, "reset fraction code equal test"); - com2 = gnc_commodity_new(book, fullname, namespace, mnemonic, + com2 = gnc_commodity_new(book, fullname, name_space, mnemonic, cusip, fraction); do_test( gnc_commodity_equiv(com, com2), "commodity equiv"); diff --git a/src/engine/test/test-date.c b/src/engine/test/test-date.cpp similarity index 99% rename from src/engine/test/test-date.c rename to src/engine/test/test-date.cpp index 492975a750..fdc7de5c05 100644 --- a/src/engine/test/test-date.c +++ b/src/engine/test/test-date.cpp @@ -1,7 +1,8 @@ /* * -- fix borken timezone test -- linas May 2004 */ - +extern "C" +{ #include "config.h" #include #include @@ -11,7 +12,7 @@ #include "gnc-module.h" #include "test-stuff.h" #include "test-engine-stuff.h" - +} static gboolean check_time (Timespec ts, gboolean always_print) diff --git a/src/engine/test/test-group-vs-book.c b/src/engine/test/test-group-vs-book.cpp similarity index 98% rename from src/engine/test/test-group-vs-book.c rename to src/engine/test/test-group-vs-book.cpp index 8f7aaf4fb3..8ef2a8e4ae 100644 --- a/src/engine/test/test-group-vs-book.c +++ b/src/engine/test/test-group-vs-book.cpp @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ - +extern "C" +{ #include "config.h" #include #include "qof.h" @@ -30,6 +31,7 @@ #include "gnc-engine.h" #include "test-engine-stuff.h" #include "test-stuff.h" +} static gboolean account_tree_has_book (Account *parent, QofBook *book) @@ -45,7 +47,7 @@ account_tree_has_book (Account *parent, QofBook *book) children = gnc_account_get_children(parent); for (node = children; node; node = node->next) { - if (!account_tree_has_book (node->data, book)) + if (!account_tree_has_book (GNC_ACCOUNT(node->data), book)) return FALSE; } g_list_free(children); diff --git a/src/engine/test/test-lots.c b/src/engine/test/test-lots.cpp similarity index 96% rename from src/engine/test/test-lots.c rename to src/engine/test/test-lots.cpp index 8a2482f454..556df24edc 100644 --- a/src/engine/test/test-lots.c +++ b/src/engine/test/test-lots.cpp @@ -24,7 +24,8 @@ * @brief Minimal test to see if automatic lot scrubbing works. * @author Linas Vepstas */ - +extern "C" +{ #include "config.h" #include #include @@ -35,6 +36,7 @@ #include "test-stuff.h" #include "test-engine-stuff.h" #include "Transaction.h" +} static gint transaction_num = 320; static gint max_iterate = 10; @@ -80,7 +82,7 @@ main (int argc, char **argv) /* Any tests that cause an error or warning to be printed * automatically fail! */ - g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING ); + g_log_set_always_fatal((GLogLevelFlags)(G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)); /* Set up a reproducible test-case */ srand(0); /* Iterate the test a number of times */ diff --git a/src/engine/test/test-numeric.c b/src/engine/test/test-numeric.cpp similarity index 99% rename from src/engine/test/test-numeric.c rename to src/engine/test/test-numeric.cpp index 3abcdf1338..7bbb9c429b 100644 --- a/src/engine/test/test-numeric.c +++ b/src/engine/test/test-numeric.cpp @@ -22,7 +22,8 @@ * 02110-1301, USA. */ - +extern "C" +{ #include "config.h" #include #include @@ -30,6 +31,7 @@ #include "test-stuff.h" #include "test-engine-stuff.h" #include "gnc-numeric.h" +} #define NREPS 2000 diff --git a/src/engine/test/test-query.c b/src/engine/test/test-query.cpp similarity index 95% rename from src/engine/test/test-query.c rename to src/engine/test/test-query.cpp index 1780dfaf46..844d7ea753 100644 --- a/src/engine/test/test-query.c +++ b/src/engine/test/test-query.cpp @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ - +extern "C" +{ #include "config.h" #include #include "qof.h" @@ -30,11 +31,12 @@ #include "gnc-engine.h" #include "test-engine-stuff.h" #include "test-stuff.h" +} static int test_trans_query (Transaction *trans, gpointer data) { - QofBook *book = data; + QofBook *book = QOF_BOOK(data); GList *list; QofQuery *q; @@ -89,7 +91,7 @@ main (int argc, char **argv) int i; qof_init(); - g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING ); + g_log_set_always_fatal((GLogLevelFlags)(G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)); xaccLogDisable (); diff --git a/src/engine/test/test-scm-query.c b/src/engine/test/test-scm-query.cpp similarity index 98% rename from src/engine/test/test-scm-query.c rename to src/engine/test/test-scm-query.cpp index 388d1f71ca..229398771c 100644 --- a/src/engine/test/test-scm-query.c +++ b/src/engine/test/test-scm-query.cpp @@ -1,7 +1,9 @@ +#include +extern "C" +{ #include "config.h" #include -#include #include "engine-helpers-guile.h" #include "gnc-module.h" @@ -9,7 +11,7 @@ #include "test-stuff.h" #include "Query.h" #include "TransLog.h" - +} static void test_query (QofQuery *q) diff --git a/src/engine/test/test-split-vs-account.c b/src/engine/test/test-split-vs-account.cpp similarity index 99% rename from src/engine/test/test-split-vs-account.c rename to src/engine/test/test-split-vs-account.cpp index 4c5da6e819..77e92e7664 100644 --- a/src/engine/test/test-split-vs-account.c +++ b/src/engine/test/test-split-vs-account.cpp @@ -21,7 +21,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ - +extern "C" +{ #include "config.h" #include #include "qof.h" @@ -32,6 +33,7 @@ #include "test-engine-stuff.h" #include "test-stuff.h" #include "Transaction.h" +} static void run_test (void) diff --git a/src/engine/test/test-transaction-reversal.c b/src/engine/test/test-transaction-reversal.cpp similarity index 87% rename from src/engine/test/test-transaction-reversal.c rename to src/engine/test/test-transaction-reversal.cpp index 6393bea8ad..3214167506 100644 --- a/src/engine/test/test-transaction-reversal.c +++ b/src/engine/test/test-transaction-reversal.cpp @@ -21,7 +21,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ - +extern "C" +{ #include "config.h" #include #include @@ -31,6 +32,7 @@ #include "TransLog.h" #include "test-engine-stuff.h" #include "test-stuff.h" +} #define print_gnc_numeric(num) fprintf(stderr, "%s\n", gnc_numeric_to_string(num)) @@ -53,7 +55,7 @@ run_test (void) { Account *acc1, *acc2; Transaction *transaction, *new_trans; - gnc_numeric old, new; + gnc_numeric old_num, new_num; QofBook *book; char *msg; int i; @@ -91,17 +93,17 @@ run_test (void) new_trans = xaccTransReverse(transaction); for (i = 0; i < 2; i++) { - old = xaccSplitGetAmount(xaccTransGetSplit(transaction, i)); - new = xaccSplitGetAmount(xaccTransGetSplit(new_trans, i)); - if (gnc_numeric_eq(old, gnc_numeric_neg(new))) + old_num = xaccSplitGetAmount(xaccTransGetSplit(transaction, i)); + new_num = xaccSplitGetAmount(xaccTransGetSplit(new_trans, i)); + if (gnc_numeric_eq(old_num, gnc_numeric_neg(new_num))) { msg = g_strdup_printf("Amount of split %d wrong after reversal\n", i); failure(msg); } - old = xaccSplitGetValue(xaccTransGetSplit(transaction, i)); - new = xaccSplitGetValue(xaccTransGetSplit(new_trans, i)); - if (gnc_numeric_eq(old, gnc_numeric_neg(new))) + old_num = xaccSplitGetValue(xaccTransGetSplit(transaction, i)); + new_num = xaccSplitGetValue(xaccTransGetSplit(new_trans, i)); + if (gnc_numeric_eq(old_num, gnc_numeric_neg(new_num))) { msg = g_strdup_printf("Value of split %d wrong after reversal\n", i); failure(msg); diff --git a/src/engine/test/test-transaction-voiding.c b/src/engine/test/test-transaction-voiding.cpp similarity index 98% rename from src/engine/test/test-transaction-voiding.c rename to src/engine/test/test-transaction-voiding.cpp index 74b4c712e8..285df1ad01 100644 --- a/src/engine/test/test-transaction-voiding.c +++ b/src/engine/test/test-transaction-voiding.cpp @@ -21,7 +21,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ - +extern "C" +{ #include "config.h" #include #include @@ -31,6 +32,7 @@ #include "test-engine-stuff.h" #include "test-stuff.h" #include "Transaction.h" +} #define print_gnc_numeric(num) fprintf(stderr, "%s\n", gnc_numeric_to_string(num)) @@ -59,7 +61,7 @@ run_test (void) Timespec ts; time64 now; - char *reason = "because I can"; + const char *reason = "because I can"; book = qof_book_new();