[vala/staging] testrunner: Allow checking generated C sources



commit 7c4a957606f5a5b2afc8078228f228c8f87ccce5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun May 23 17:48:49 2021 +0200

    testrunner: Allow checking generated C sources

 build-aux/testrunner.sh   | 18 ++++++++++++++++++
 tests/Makefile.am         |  2 ++
 valadoc/tests/Makefile.am |  1 +
 3 files changed, 21 insertions(+)
---
diff --git a/build-aux/testrunner.sh b/build-aux/testrunner.sh
index a756d0025..967a06238 100755
--- a/build-aux/testrunner.sh
+++ b/build-aux/testrunner.sh
@@ -43,6 +43,7 @@ VALAC=$abs_top_builddir/compiler/valac$EXEEXT
 VALAFLAGS="$VALAFLAGS \
        --vapidir $vapidir \
        --enable-checking \
+       --disable-version-header \
        --disable-warnings \
        --save-temps \
        --cc $CC \
@@ -156,8 +157,20 @@ function sourceend() {
                PACKAGEFLAGS=$([ -z "$PACKAGES" ] || echo $PACKAGES | xargs -n 1 echo -n " --pkg")
                echo "$VALAC $VALAFLAGS $PACKAGEFLAGS -o $ns$EXEEXT $SOURCEFILE" >> prepare
                if [ $DBUSTEST -eq 1 ]; then
+                       echo "UPDATE_EXPECTED=$UPDATE_EXPECTED" >> prepare
                        if [ $ISSERVER -eq 1 ]; then
+                               echo "if [ -n \"$UPDATE_EXPECTED\" ]; then" >> prepare
+                               echo "  cp -p ${SOURCEFILE%.*}.c 
$abs_srcdir/${testfile%.*}_server.c-expected" >> prepare
+                               echo "elif [ -f $abs_srcdir/${testfile%.*}_server.c-expected ]; then" >> 
prepare
+                               echo "  diff -wu $abs_srcdir/${testfile%.*}_server.c-expected 
${SOURCEFILE%.*}.c || exit 1" >> prepare
+                               echo "fi" >> prepare
                                echo "./$ns$EXEEXT" >> check
+                       else
+                               echo "if [ -n \"$UPDATE_EXPECTED\" ]; then" >> prepare
+                               echo "  cp -p ${SOURCEFILE%.*}.c 
$abs_srcdir/${testfile%.*}_client.c-expected" >> prepare
+                               echo "elif [ -f $abs_srcdir/${testfile%.*}_client.c-expected ]; then" >> 
prepare
+                               echo "  diff -wu $abs_srcdir/${testfile%.*}_client.c-expected 
${SOURCEFILE%.*}.c || exit 1" >> prepare
+                               echo "fi" >> prepare
                        fi
                else
                        echo "./$ns$EXEEXT" >> check
@@ -183,6 +196,11 @@ case "$testfile" in
        cat "$abs_srcdir/$testfile" > ./$SOURCEFILE
        PACKAGEFLAGS=$([ -z "$PACKAGES" ] || echo $PACKAGES | xargs -n 1 echo -n " --pkg")
        $VALAC $VALAFLAGS $PACKAGEFLAGS -o $testpath$EXEEXT $SOURCEFILE
+       if [ -n "$UPDATE_EXPECTED" ]; then
+               cp -p ${SOURCEFILE%.*}.c $abs_srcdir/${testfile%.*}.c-expected
+       elif [ -f $abs_srcdir/${testfile%.*}.c-expected ]; then
+               diff -wu $abs_srcdir/${testfile%.*}.c-expected ${SOURCEFILE%.*}.c || exit 1
+       fi
        ./$testpath$EXEEXT
        ;;
 *.test)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cb96b0d06..503c60119 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -26,6 +26,7 @@ GS_LOG_COMPILER = $(TEST_RUNNER)
 TEST_LOG_COMPILER = $(TEST_RUNNER)
 
 AM_TESTS_ENVIRONMENT = \
+       export UPDATE_EXPECTED=$(UPDATE_EXPECTED); \
        export EXEEXT=$(EXEEXT); \
        export CFLAGS='$(CFLAGS)'; \
        export CPPFLAGS='$(CPPFLAGS)'; \
@@ -1285,4 +1286,5 @@ EXTRA_DIST = \
        version/tests-extra-environment.sh \
        $(TESTS) \
        $(LINUX_TESTS) \
+       $(wildcard $(srcdir)/*/*.c-expected) \
        $(NULL)
diff --git a/valadoc/tests/Makefile.am b/valadoc/tests/Makefile.am
index 62edb7b7c..b6e6104c9 100644
--- a/valadoc/tests/Makefile.am
+++ b/valadoc/tests/Makefile.am
@@ -4,6 +4,7 @@ NULL =
 
 LOG_COMPILER = $(abs_top_srcdir)/build-aux/testrunner.sh
 AM_TESTS_ENVIRONMENT = \
+       export UPDATE_EXPECTED=$(UPDATE_EXPECTED); \
        export EXEEXT=$(EXEEXT); \
        export CFLAGS='$(CFLAGS)'; \
        export CPPFLAGS='$(CPPFLAGS)'; \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]