From 3160f642dbed35b4af8e4d9314c60e4a037884c8 Mon Sep 17 00:00:00 2001 From: Simon Feltman Date: Fri, 20 Dec 2013 03:38:37 -0800 Subject: tests: Use Automake test harness for scanner diff tests Add gi-tester script for dispatching various scanner diff tests based on their target suffix. Hook the dispatcher script into the Automake test harness which is passed the diff test target name. Remove usage of check-local which is always run regardless of whether or not the TESTS variable is set from the command line. This allows for both the ability to use the harnesses XFAIL_TESTS variable for expected failures as well as testing of targets individually, for example: cd tests/scanner make check TESTS=GtkFrob-1.0.gir make check TESTS=Regress-1.0-Python Add Headeronly-1.0-expected.gir for validating the results of the header only gir creation test. https://bugzilla.gnome.org/show_bug.cgi?id=720713 --- tests/Makefile.am | 4 +++- tests/gi-tester | 39 +++++++++++++++++++++++++++++++ tests/scanner/Headeronly-1.0-expected.gir | 21 +++++++++++++++++ tests/scanner/Makefile.am | 29 +++++++---------------- 4 files changed, 72 insertions(+), 21 deletions(-) create mode 100755 tests/gi-tester create mode 100644 tests/scanner/Headeronly-1.0-expected.gir diff --git a/tests/Makefile.am b/tests/Makefile.am index 56fc4796..26fe83bb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,7 +21,9 @@ check_LTLIBRARIES = libeverything-1.0.la libgimarshallingtests-1.0.la libeverything_1_0_la_SOURCES = everything.c libgimarshallingtests_1_0_la_SOURCES = gimarshallingtests.c -EXTRA_DIST += gimarshallingtests.h +EXTRA_DIST += \ + gimarshallingtests.h \ + gi-tester BUILT_SOURCES += everything.c everything.h diff --git a/tests/gi-tester b/tests/gi-tester new file mode 100755 index 00000000..496b947b --- /dev/null +++ b/tests/gi-tester @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +targetname=$1 + +# Note the target name for the documentation targets (-C, -Python, -Gjs) +# incorrectly include a relative path to the srcdir, strip that off for usage +# in directory diffs. +targetbase=${targetname##*/} + +case $targetname in +*.gir) + diff -u -U 10 ${srcdir}/${targetname::-4}-expected.gir ${builddir}/${targetname} + exit $? + ;; +*.typelib) + # Do nothing for typelibs, this just ensures they build as part of the tests + exit 0 + ;; +*-C) + diff -r -u -w -B -U 10 ${srcdir}/${targetbase}-expected ${builddir}/${targetbase} + exit $? + ;; +*-Python) + diff -r -u -w -B -U 10 ${srcdir}/${targetbase}-expected ${builddir}/${targetbase} + exit $? + ;; +*-Gjs) + diff -r -u -w -B -U 10 ${srcdir}/${targetbase}-expected ${builddir}/${targetbase} + exit $? + ;; +*-sections.txt) + diff -u -w -B -U 10 ${srcdir}/${targetname::-4}-expected.txt ${builddir}/${targetname} + exit $? + ;; +*) + echo $"Usage: gi-tester " + exit 1 + ;; +esac diff --git a/tests/scanner/Headeronly-1.0-expected.gir b/tests/scanner/Headeronly-1.0-expected.gir new file mode 100644 index 00000000..179d9816 --- /dev/null +++ b/tests/scanner/Headeronly-1.0-expected.gir @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am index a1c0ecfa..bf7afc92 100644 --- a/tests/scanner/Makefile.am +++ b/tests/scanner/Makefile.am @@ -67,7 +67,7 @@ endif # .gir --[scanner]-> .typelib GIRS = TYPELIBS = $(GIRS:.gir=.typelib) -CHECKGIRS = $(GIRS:.gir=.gir.check) +CHECKGIRS = $(GIRS) EXPECTEDGIRS = $(GIRS:.gir=-expected.gir) INTROSPECTION_GIRS = $(GIRS) CLEANFILES = $(TYPELIBS) $(GIRS) @@ -141,20 +141,19 @@ Bar_1_0_gir_SCANNERFLAGS = --accept-unprefixed GIRS += Bar-1.0.gir endif -EXTRA_DIST += headeronly.h +EXTRA_DIST += \ + headeronly.h \ + Headeronly-1.0-expected.gir CLEANFILES += Headeronly-1.0.gir Headeronly-1.0.gir: headeronly.h $(AM_V_GEN) $(INTROSPECTION_SCANNER) $(INTROSPECTION_SCANNER_ARGS) --warn-all --warn-error --reparse-validate --namespace=Headeronly --nsversion=1.0 --header-only --output=$@ $< -%.gir.check: %.gir - @diff -u -U 10 $(srcdir)/$*-expected.gir $*.gir && echo " TEST $*.gir" - if BUILD_DOCTOOL DOCGIRS = Regress-1.0.gir -CHECKDOCS = $(DOCGIRS:.gir=-C.page.check) $(DOCGIRS:.gir=-Python.page.check) $(DOCGIRS:.gir=-Gjs.page.check) $(DOCGIRS:.gir=-sections.txt.page.check) +CHECKDOCS = $(DOCGIRS:.gir=-C) $(DOCGIRS:.gir=-Python) $(DOCGIRS:.gir=-Gjs) $(DOCGIRS:.gir=-sections.txt) MALLARD_DIRS = $(DOCGIRS:.gir=-C) $(DOCGIRS:.gir=-Python) $(DOCGIRS:.gir=-Gjs) -MALLARD_CLEAN = $(DOCGIRS:.gir=-C)/* $(DOCGIRS:.gir=-Python)/* $(DOCGIRS:.gir=-Gjs)/* +MALLARD_CLEAN = $(DOCGIRS:.gir=-C)/* $(DOCGIRS:.gir=-Python)/* $(DOCGIRS:.gir=-Gjs)/* $(DOCGIRS:.gir=-sections.txt) EXPECTED_MALLARD_DIRS = $(MALLARD_DIRS:=-expected) CLEANFILES += $(MALLARD_CLEAN) @@ -173,23 +172,13 @@ CLEANFILES += $(MALLARD_CLEAN) %-sections.txt: %.gir $(AM_V_GEN)$(INTROSPECTION_DOCTOOL) $(INTROSPECTION_DOCTOOL_ARGS) --write-sections-file $*.gir -o $@ -%-C.page.check: %-C - @diff -r -u -w -B -U 10 $(srcdir)/$*-C-expected $(builddir)/$*-C && echo " TEST $*-C" - -%-Python.page.check: %-Python - @diff -r -u -w -B -U 10 $(srcdir)/$*-Python-expected $(builddir)/$*-Python && echo " TEST $*-Python" - -%-Gjs.page.check: %-Gjs - @diff -r -u -w -B -U 10 $(srcdir)/$*-Gjs-expected $(builddir)/$*-Gjs && echo " TEST $*-Gjs" - -%-sections.txt.page.check: %-sections.txt - @diff -u -w -B -U 10 $(srcdir)/$*-sections-expected.txt $*-sections.txt && echo " TEST $*-C" - else CHECKDOCS = endif -check-local: Headeronly-1.0.gir $(CHECKGIRS) $(CHECKDOCS) $(TYPELIBS) +TESTS = Headeronly-1.0.gir $(CHECKGIRS) $(CHECKDOCS) $(TYPELIBS) +TESTS_ENVIRONMENT = srcdir=$(srcdir) top_srcdir=$(top_srcdir) builddir=$(builddir) top_builddir=$(top_builddir) \ + $(top_srcdir)/tests/gi-tester EXTRA_DIST += \ annotationparser/README \ -- cgit v1.2.1