From 448deebb83191eeb65a283d832caf7f76f0ed960 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Sun, 2 Jan 2011 18:46:01 -0800 Subject: [PATCH] make test: run all tests, make fullcheck: run tests and distcheck --- Makefile.am | 11 ++++ moo/Makefile.am | 3 + moo/medit-app/Makefile.incl | 21 +++++-- moo/medit-app/main.c | 8 +-- moo/medit-app/run-tests-am.sh | 25 --------- moo/medit-app/run-tests-installed.sh | 9 +++ moo/medit-app/run-tests-uninstalled.sh | 4 ++ moo/medit-app/run-tests.h | 2 +- moo/medit-app/run-tests.sh | 77 ++++++++++++++++++++++++++ moo/moolua/moolua-tests.cpp | 5 +- moo/moolua/moolua-tests.h | 2 +- 11 files changed, 129 insertions(+), 38 deletions(-) delete mode 100755 moo/medit-app/run-tests-am.sh create mode 100755 moo/medit-app/run-tests-installed.sh create mode 100755 moo/medit-app/run-tests-uninstalled.sh create mode 100755 moo/medit-app/run-tests.sh diff --git a/Makefile.am b/Makefile.am index 77c1681b..53f7fc34 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,4 +33,15 @@ installer: plat/win32/installer.iss $(MEDIT_INNO_COMPILER) plat/win32/installer.iss endif +test: + $(MAKE) $(AM_MAKEFLAGS) all + $(MAKE) $(AM_MAKEFLAGS) check + $(MAKE) $(AM_MAKEFLAGS) uninstall + $(MAKE) $(AM_MAKEFLAGS) check + $(MAKE) $(AM_MAKEFLAGS) install + IGNORE_COVERAGE=1 $(MAKE) $(AM_MAKEFLAGS) installcheck +fullcheck: + $(MAKE) $(AM_MAKEFLAGS) test + IGNORE_COVERAGE=1 $(MAKE) $(AM_MAKEFLAGS) distcheck + @MOO_PO_SUBDIRS_RULE@ diff --git a/moo/Makefile.am b/moo/Makefile.am index 53182d79..cc5b033d 100644 --- a/moo/Makefile.am +++ b/moo/Makefile.am @@ -41,6 +41,9 @@ include medit-app/Makefile.incl BUILT_SOURCES += $(built_moo_sources) $(built_plugin_sources) CLEANFILES += $(built_moo_sources) $(built_plugin_sources) +test: + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) test + # glade/%-gxml.h: glade/%.glade $(top_srcdir)/tools/glade2c.py # $(MKDIR_P) glade # $(PYTHON) $(top_srcdir)/tools/glade2c.py $< > $@.tmp && mv $@.tmp $@ diff --git a/moo/medit-app/Makefile.incl b/moo/medit-app/Makefile.incl index 5f8ff329..4eec1269 100644 --- a/moo/medit-app/Makefile.incl +++ b/moo/medit-app/Makefile.incl @@ -5,13 +5,22 @@ dist-hook: delete-junk-from-data delete-junk-from-data: rm -rf `find $(distdir)/medit-app/data -name '*~'` -EXTRA_DIST += medit-app/run-tests-am.sh medit-app/print-functions.py -TESTS = medit-app/run-tests-am.sh -TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) PYTHON=$(PYTHON) print_functions=$(srcdir)/medit-app/print-functions.py +EXTRA_DIST += \ + medit-app/run-tests.sh \ + medit-app/print-functions.py \ + medit-app/run-tests-installed.sh \ + medit-app/run-tests-uninstalled.sh -installcheck-local: unit-tests-installed -unit-tests-installed: - medit --ut --ut-installed +TESTS = medit-app/run-tests-uninstalled.sh +TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) bindir=$(bindir) PYTHON=$(PYTHON) print_functions=$(srcdir)/medit-app/print-functions.py + +installcheck-local: run-tests-installed +run-tests-installed: + $(TESTS_ENVIRONMENT) srcdir=$(srcdir) $(srcdir)/medit-app/run-tests-installed.sh + @echo 'PASS: medit-app/run-tests-installed.sh' + @echo '=============' + @echo '1 test passed' + @echo '=============' if MOO_OS_UNIX AM_CFLAGS += -DMOO_UNIT_TEST_DATA_DIR=\"${MOO_TOP_SRCDIR}/moo/medit-app/data\" diff --git a/moo/medit-app/main.c b/moo/medit-app/main.c index ea018a2a..141b6306 100644 --- a/moo/medit-app/main.c +++ b/moo/medit-app/main.c @@ -54,7 +54,7 @@ static struct MeditOpts { gboolean show_version; const char *debug; gboolean ut; - gboolean ut_installed; + gboolean ut_uninstalled; gboolean ut_list; char *ut_dir; char *ut_coverage_file; @@ -163,8 +163,8 @@ static GOptionEntry medit_options[] = { /* help message for command line option --version */ N_("Show version information and exit"), NULL }, { "ut", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &medit_opts.ut, "Run unit tests", NULL }, - { "ut-installed", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &medit_opts.ut_installed, - "Run unit tests in installed medit", NULL }, + { "ut-uninstalled", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &medit_opts.ut_uninstalled, + "Run unit tests in uninstalled medit", NULL }, { "ut-dir", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &medit_opts.ut_dir, "Data dir for unit tests", NULL }, { "ut-coverage", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &medit_opts.ut_coverage_file, @@ -528,7 +528,7 @@ unit_test_func (void) MooTestOptions opts = 0; int status; - if (medit_opts.ut_installed) + if (!medit_opts.ut_uninstalled) opts |= MOO_TEST_INSTALLED; status = unit_tests_main (opts, medit_opts.ut_tests, medit_opts.ut_dir, medit_opts.ut_coverage_file); diff --git a/moo/medit-app/run-tests-am.sh b/moo/medit-app/run-tests-am.sh deleted file mode 100755 index b4a11366..00000000 --- a/moo/medit-app/run-tests-am.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh -echo ./medit --ut --ut-coverage called-functions -./medit --ut --ut-coverage called-functions || exit $? -sort called-functions > called-functions.tmp || exit 1 -mv called-functions.tmp called-functions || exit 1 - -moo_xml=$top_srcdir/api/moo.xml -gtk_xml=$top_srcdir/api/gtk.xml -[ -f $moo_xml ] || { echo "file $moo_xml doesn't exist"; exit 1; } -[ -f $gtk_xml ] || { echo "file $gtk_xml doesn't exist"; exit 1; } - -$PYTHON $print_functions $moo_xml $gtk_xml > all-functions.tmp || exit 1 -sort all-functions.tmp > all-functions.tmp2 || exit 1 -mv all-functions.tmp2 all-functions || exit 1 -rm -f all-functions.tmp all-functions.tmp2 - -comm -3 -2 all-functions called-functions > not-covered-functions - -if [ -z "$IGNORE_COVERAGE" ] && [ -s not-covered-functions ]; then - echo "*** Not all functions are covered, see file not-covered-functions" - exit 1 -else - rm -f all-functions called-functions not-covered-functions - exit 0 -fi diff --git a/moo/medit-app/run-tests-installed.sh b/moo/medit-app/run-tests-installed.sh new file mode 100755 index 00000000..220e03a1 --- /dev/null +++ b/moo/medit-app/run-tests-installed.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +if [ -z $IGNORE_COVERAGE ]; then + coverage_arg=--coverage +else + coverage_arg= +fi + +exec $srcdir/medit-app/run-tests.sh --installed $coverage_arg diff --git a/moo/medit-app/run-tests-uninstalled.sh b/moo/medit-app/run-tests-uninstalled.sh new file mode 100755 index 00000000..3f1f7e13 --- /dev/null +++ b/moo/medit-app/run-tests-uninstalled.sh @@ -0,0 +1,4 @@ +#! /bin/sh + +echo $srcdir/medit-app/run-tests.sh --uninstalled +exec $srcdir/medit-app/run-tests.sh --uninstalled diff --git a/moo/medit-app/run-tests.h b/moo/medit-app/run-tests.h index c9577224..1efa4ae4 100644 --- a/moo/medit-app/run-tests.h +++ b/moo/medit-app/run-tests.h @@ -20,7 +20,7 @@ add_tests (MooTestOptions opts) moo_test_mooutils_win32 (); #endif - moo_test_lua (); + moo_test_lua (opts); #ifdef MOO_ENABLE_PYTHON moo_test_python (); diff --git a/moo/medit-app/run-tests.sh b/moo/medit-app/run-tests.sh new file mode 100755 index 00000000..c83fadd9 --- /dev/null +++ b/moo/medit-app/run-tests.sh @@ -0,0 +1,77 @@ +#! /bin/sh + +coverage=false +uninstalled=false + +for arg; do + case $arg in + --installed) + uninstalled=false + ;; + --uninstalled) + uninstalled=true + ;; + --coverage) + coverage=true + ;; + *) + echo "Unknown option $arg" + exit 1 + ;; + esac +done + +if $uninstalled; then + if ! [ -e ./medit ]; then + echo "file ./medit doesn't exist" + exit 1 + fi + medit_cmd_line="./medit --ut --ut-uninstalled" +else + if [ -z $bindir ]; then + medit=`which medit` + else + medit=$bindir/medit + fi + if ! [ -e $medit ]; then + echo "file $medit doesn't exist" + exit 1 + fi + if [ ./medit -nt $medit ]; then + echo "file ./medit is newer than '$medit', did you forget run make install?" + exit 1 + fi + medit_cmd_line="$medit --ut" +fi + +if $coverage; then + medit_cmd_line="$medit_cmd_line --ut-coverage called-functions" +fi + +echo "$medit_cmd_line" +$medit_cmd_line || exit $? + +if $coverage; then + sort called-functions > called-functions.tmp || exit 1 + mv called-functions.tmp called-functions || exit 1 + + moo_xml=$top_srcdir/api/moo.xml + gtk_xml=$top_srcdir/api/gtk.xml + [ -f $moo_xml ] || { echo "file $moo_xml doesn't exist"; exit 1; } + [ -f $gtk_xml ] || { echo "file $gtk_xml doesn't exist"; exit 1; } + + $PYTHON $print_functions $moo_xml $gtk_xml > all-functions.tmp || exit 1 + sort all-functions.tmp > all-functions.tmp2 || exit 1 + mv all-functions.tmp2 all-functions || exit 1 + rm -f all-functions.tmp all-functions.tmp2 + + comm -3 -2 all-functions called-functions > not-covered-functions + + if [ -z "$IGNORE_COVERAGE" ] && [ -s not-covered-functions ]; then + echo "*** Not all functions are covered, see file not-covered-functions" + exit 1 + else + rm -f all-functions called-functions not-covered-functions + exit 0 + fi +fi diff --git a/moo/moolua/moolua-tests.cpp b/moo/moolua/moolua-tests.cpp index 5168e979..88303bf0 100644 --- a/moo/moolua/moolua-tests.cpp +++ b/moo/moolua/moolua-tests.cpp @@ -112,12 +112,15 @@ moo_lua_test_data_free (gpointer udata) } void -moo_test_lua (void) +moo_test_lua (MooTestOptions opts) { MooLuaTestData *data; MooTestSuite *suite; char **p; + if (!(opts & MOO_TEST_INSTALLED)) + return; + data = moo_lua_test_data_new (); suite = moo_test_suite_new ("MooLua", "Lua scripting tests", NULL, moo_lua_test_data_free, data); diff --git a/moo/moolua/moolua-tests.h b/moo/moolua/moolua-tests.h index c7e6f3bc..21349a5f 100644 --- a/moo/moolua/moolua-tests.h +++ b/moo/moolua/moolua-tests.h @@ -20,7 +20,7 @@ G_BEGIN_DECLS -void moo_test_lua (void); +void moo_test_lua (MooTestOptions opts); G_END_DECLS