tests: move to subdir, move to meson

De-clutter the source directories a bit. Ensure tests build with meson, and
remove from autotools in a few places (no need to do things twice).
This commit is contained in:
Dirk-Jan C. Binnema
2021-11-07 11:41:55 +02:00
parent 67b16acbb2
commit 48d3f9cfab
87 changed files with 214 additions and 485 deletions

View File

@ -130,122 +130,6 @@ tokenize_LDADD= \
EXTRA_DIST= \
doxyfile.in
noinst_PROGRAMS+=$(TEST_PROGS)
noinst_LTLIBRARIES+= \
libtestmucommon.la
TEST_PROGS += test-maildir
test_maildir_SOURCES= test-mu-maildir.cc
test_maildir_LDADD= libtestmucommon.la
TEST_PROGS += test-msg-fields
test_msg_fields_SOURCES= test-mu-msg-fields.cc
test_msg_fields_LDADD= libtestmucommon.la
TEST_PROGS += test-msg
test_msg_SOURCES= test-mu-msg.cc
test_msg_LDADD= libtestmucommon.la
TEST_PROGS += test-store
test_store_SOURCES= test-mu-store.cc
test_store_LDADD= libtestmucommon.la
TEST_PROGS += test-query
test_query_SOURCES= test-query.cc
test_query_LDADD= libtestmucommon.la
TEST_PROGS += test-flags
test_flags_SOURCES= test-mu-flags.cc
test_flags_LDADD= libtestmucommon.la
TEST_PROGS+=test-tokenizer
test_tokenizer_SOURCES=test-tokenizer.cc
test_tokenizer_LDADD=libtestmucommon.la
TEST_PROGS+=test-threads
test_threads_SOURCES=mu-query-threads.cc
test_threads_LDADD=libtestmucommon.la
test_threads_CXXFLAGS=$(AM_CXXFLAGS) -DBUILD_TESTS
TEST_PROGS += test-contacts
test_contacts_SOURCES= mu-contacts.cc
test_contacts_CXXFLAGS=$(AM_CXXFLAGS) -DBUILD_TESTS
test_contacts_LDADD= libtestmucommon.la
TEST_PROGS+=test-parser
test_parser_SOURCES=test-parser.cc
test_parser_LDADD=libtestmucommon.la
libtestmucommon_la_SOURCES= \
test-mu-common.cc \
test-mu-common.hh
libtestmucommon_la_LIBADD= \
libmu.la \
utils/libmu-utils.la
# note the question marks; make does not like files with ':', so we
# use the (also supported) version with '!' instead. We could escape
# the : with \: but automake does not recognize that....
# test messages, the '.ignore' message should be ignored
# when indexing
EXTRA_DIST+= \
testdir/tmp/1220863087.12663.ignore \
testdir/new/1220863087.12663_9.mindcrime \
testdir/new/1220863087.12663_25.mindcrime \
testdir/new/1220863087.12663_21.mindcrime \
testdir/new/1220863087.12663_23.mindcrime \
testdir/cur/1220863087.12663_5.mindcrime!2,S \
testdir/cur/1220863087.12663_7.mindcrime!2,RS \
testdir/cur/1220863087.12663_15.mindcrime!2,PS \
testdir/cur/1220863087.12663_19.mindcrime!2,S \
testdir/cur/1220863042.12663_1.mindcrime!2,S \
testdir/cur/1220863060.12663_3.mindcrime!2,S \
testdir/cur/1283599333.1840_11.cthulhu!2, \
testdir/cur/1305664394.2171_402.cthulhu!2, \
testdir/cur/1252168370_3.14675.cthulhu!2,S \
testdir/cur/encrypted!2,S \
testdir/cur/multimime!2,FS \
testdir/cur/signed!2,S \
testdir/cur/signed-encrypted!2,S \
testdir/cur/special!2,Sabc \
testdir/cur/multirecip!2,S \
testdir2/bar/cur/mail1 \
testdir2/bar/cur/mail2 \
testdir2/bar/cur/mail3 \
testdir2/bar/cur/mail4 \
testdir2/bar/cur/mail5 \
testdir2/bar/cur/181736.eml \
testdir2/bar/cur/mail6 \
testdir2/bar/tmp/.noindex \
testdir2/bar/new/.noindex \
testdir2/Foo/cur/mail5 \
testdir2/Foo/cur/arto.eml \
testdir2/Foo/cur/fraiche.eml \
testdir2/Foo/tmp/.noindex \
testdir2/Foo/new/.noindex \
testdir2/wom_bat/cur/atomic \
testdir2/wom_bat/cur/rfc822.1 \
testdir2/wom_bat/cur/rfc822.2 \
testdir4/1220863087.12663_19.mindcrime!2,S \
testdir4/1220863042.12663_1.mindcrime!2,S \
testdir4/1283599333.1840_11.cthulhu!2, \
testdir4/1305664394.2171_402.cthulhu!2, \
testdir4/1252168370_3.14675.cthulhu!2,S \
testdir4/mail1 \
testdir4/mail5 \
testdir4/181736.eml \
testdir4/encrypted!2,S \
testdir4/multimime!2,FS \
testdir4/signed!2,S \
testdir4/signed-bad!2,S \
testdir4/signed-encrypted!2,S \
testdir4/special!2,Sabc
TESTS=$(TEST_PROGS)
CLEANFILES=*.log *.trs *core* *vgdump* *.gcda *.gcno
include $(top_srcdir)/aminclude_static.am

View File

@ -87,79 +87,15 @@ lib_mu_dep = declare_dependency(
include_directories:
include_directories(['.', '..', xapian_incs]))
#
# tests
#
lib_test_mu_common_inc_dep = declare_dependency(
include_directories: include_directories(['.', '..']))
# test helpers
lib_test_mu_common=static_library('mu-test-common', [
'test-mu-common.cc',
'test-mu-common.hh'],
'tests/test-mu-common.cc',
'tests/test-mu-common.hh'],
dependencies: [ glib_dep, thread_dep,
lib_test_mu_common_inc_dep])
config_h_dep])
lib_test_mu_common_dep=declare_dependency(
link_with: lib_test_mu_common,
include_directories: include_directories(['.']))
include_directories: include_directories(['tests']))
testmaildir=join_paths(meson.current_source_dir(),'.')
test('test_maildir',
executable('test-maildir',
'test-mu-maildir.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_msg_fields',
executable('test-msg-fields',
'test-mu-msg-fields.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_msg',
executable('test-msg',
'test-mu-msg.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep],
cpp_args:['-DMU_TESTMAILDIR2="'+ join_paths(testmaildir, 'testdir2') + '"',
'-DMU_TESTMAILDIR4="'+ join_paths(testmaildir, 'testdir4') + '"' ]))
test('test_store',
executable('test-store',
'test-mu-store.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep],
cpp_args:['-DMU_TESTMAILDIR="'+ join_paths(testmaildir, 'testdir') + '"',
'-DMU_TESTMAILDIR2="'+ join_paths(testmaildir, 'testdir2') + '"',
'-DMU_TESTMAILDIR4="'+ join_paths(testmaildir, 'testdir4') + '"']))
test('test_query',
executable('test-query',
'test-query.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep],
cpp_args:['-DMU_TESTMAILDIR="'+ join_paths(testmaildir, 'testdir') + '"']))
test('test_flags',
executable('test-flags',
'test-mu-flags.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_tokenizer',
executable('test-tokenizer',
'test-tokenizer.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_threads',
executable('test-threads',
'mu-query-threads.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_contacts',
executable('test-contacts',
'mu-contacts.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_parser',
executable('test-parser',
'test-parser.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
# actual tests
subdir('tests')

View File

@ -1,78 +0,0 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/*
** Copyright (C) 2008-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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 3, 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, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG_H*/
#include <glib.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <locale.h>
#include "test-mu-common.h"
#include "mu-date.h"
static void
test_mu_date_interpret_begin(void)
{
time_t now;
now = time(NULL);
g_assert_cmpstr(mu_date_interpret_s("now", TRUE), ==, mu_date_str_s("%Y%m%d%H%M%S", now));
g_assert_cmpstr(mu_date_interpret_s("today", TRUE), ==, mu_date_str_s("%Y%m%d000000", now));
}
static void
test_mu_date_interpret_end(void)
{
time_t now;
now = time(NULL);
g_assert_cmpstr(mu_date_interpret_s("now", FALSE), ==, mu_date_str_s("%Y%m%d%H%M%S", now));
g_assert_cmpstr(mu_date_interpret_s("today", FALSE),
==,
mu_date_str_s("%Y%m%d235959", now));
}
int
main(int argc, char* argv[])
{
g_test_init(&argc, &argv, NULL);
g_test_add_func("/mu-str/mu_date_parse_hdwmy", test_mu_date_parse_hdwmy);
g_test_add_func("/mu-str/mu_date_complete_begin", test_mu_date_complete_begin);
g_test_add_func("/mu-str/mu_date_complete_end", test_mu_date_complete_end);
g_test_add_func("/mu-str/mu_date_interpret_begin", test_mu_date_interpret_begin);
g_test_add_func("/mu-str/mu_date_interpret_end", test_mu_date_interpret_end);
g_log_set_handler(NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole,
NULL);
return g_test_run();
}

73
lib/tests/meson.build Normal file
View File

@ -0,0 +1,73 @@
## Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## 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 3 of the License, 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, write to the Free Software Foundation,
## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# tests
#
test('test_maildir',
executable('test-maildir',
'test-mu-maildir.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_msg_fields',
executable('test-msg-fields',
'test-mu-msg-fields.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_msg',
executable('test-msg',
'test-mu-msg.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_store',
executable('test-store',
'test-mu-store.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_query',
executable('test-query',
'test-query.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_flags',
executable('test-flags',
'test-mu-flags.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_tokenizer',
executable('test-tokenizer',
'test-tokenizer.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_threads',
executable('test-threads',
'../mu-query-threads.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_contacts',
executable('test-contacts',
'../mu-contacts.cc',
install: false,
cpp_args: ['-DBUILD_TESTS'],
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
test('test_parser',
executable('test-parser',
'test-parser.cc',
install: false,
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))

View File

@ -79,52 +79,4 @@ libmu_utils_la_LIBADD= \
$(READLINE_LIBS) \
$(CODE_COVERAGE_LIBS)
noinst_PROGRAMS= \
$(TEST_PROGS)
TEST_PROGS+= \
test-mu-util
test_mu_util_SOURCES= \
test-mu-util.c
test_mu_util_LDADD= \
libmu-utils.la
TEST_PROGS+= \
test-mu-utils
test_mu_utils_SOURCES= \
test-utils.cc
test_mu_utils_LDADD= \
libmu-utils.la
TEST_PROGS+= \
test-mu-str
test_mu_str_SOURCES= \
test-mu-str.c
test_mu_str_LDADD= \
libmu-utils.la
TEST_PROGS+= \
test-sexp
test_sexp_SOURCES= \
test-sexp.cc
test_sexp_LDADD= \
libmu-utils.la
TEST_PROGS+= \
test-command-parser
test_command_parser_SOURCES= \
test-command-parser.cc
test_command_parser_LDADD= \
libmu-utils.la
TEST_PROGS+= \
test-option
test_option_SOURCES= \
test-option.cc
test_option_LDADD= \
libmu-utils.la
TESTS=$(TEST_PROGS)
include $(top_srcdir)/aminclude_static.am

View File

@ -53,41 +53,4 @@ lib_mu_utils_dep = declare_dependency(
include_directories: include_directories(['.', '..'])
)
################################################################################
# tests
#
testmaildir=join_paths(meson.current_source_dir(),'..')
test('test_command_parser',
executable('test-command-parser',
'test-command-parser.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep]))
test('test_mu_str',
executable('test-mu-str',
'test-mu-str.c',
install: false,
dependencies: [glib_dep, config_h_dep,lib_mu_utils_dep]))
test('test_mu_util',
executable('test-mu-util',
'test-mu-util.c',
install: false,
dependencies: [glib_dep,config_h_dep, lib_mu_utils_dep],
c_args: ['-DMU_TESTMAILDIR="' + join_paths(testmaildir, 'testdir') + '"',
'-DMU_TESTMAILDIR2="' + join_paths(testmaildir, 'testdir2') + '"']))
test('test_option',
executable('test-option',
'test-option.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep]))
test('test_mu_utils',
executable('test-mu-utils',
'test-utils.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep]))
test('test_sexp',
executable('test-sexp',
'test-sexp.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep] ))
subdir('tests')

View File

@ -0,0 +1,50 @@
## Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## 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 3 of the License, 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, write to the Free Software Foundation,
## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
################################################################################
# tests
#
test('test_command_parser',
executable('test-command-parser',
'test-command-parser.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep]))
test('test_mu_str',
executable('test-mu-str',
'test-mu-str.c',
install: false,
dependencies: [glib_dep, config_h_dep,lib_mu_utils_dep]))
test('test_mu_util',
executable('test-mu-util',
'test-mu-util.c',
install: false,
dependencies: [glib_dep,config_h_dep, lib_mu_utils_dep]))
test('test_option',
executable('test-option',
'test-option.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep]))
test('test_mu_utils',
executable('test-mu-utils',
'test-utils.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep]))
test('test_sexp',
executable('test-sexp',
'test-sexp.cc',
install: false,
dependencies: [glib_dep, lib_mu_utils_dep] ))