From 89db3a83d8dc4f802f0ca4c6abf8c499349ea81c Mon Sep 17 00:00:00 2001 From: Flammie A Pirinen Date: Wed, 4 Sep 2024 16:36:48 +0200 Subject: [PATCH] [Template merge] move tag_test.sh to core --- m4/giella-macros.m4 | 2 +- src/fst/morphology/test/tag_test.sh | 57 +++++++++-------------------- 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/m4/giella-macros.m4 b/m4/giella-macros.m4 index db8ea70..a439cec 100644 --- a/m4/giella-macros.m4 +++ b/m4/giella-macros.m4 @@ -88,7 +88,7 @@ AC_MSG_RESULT([$GIELLA_CORE]) ############################################################### ### This is the version of the Giella Core that we require. ### ### UPDATE AS NEEDED. -_giella_core_min_version=1.0.2 +_giella_core_min_version=1.0.4 # GIELLA_CORE/GTCORE env. variable, required by the infrastructure to find scripts: AC_ARG_VAR([GIELLA_CORE], [directory for the Giella infra core scripts and other required resources]) diff --git a/src/fst/morphology/test/tag_test.sh b/src/fst/morphology/test/tag_test.sh index 61fd788..c83608a 100755 --- a/src/fst/morphology/test/tag_test.sh +++ b/src/fst/morphology/test/tag_test.sh @@ -1,44 +1,23 @@ #!/bin/bash -# Check if there are tags which are not declared in root.lexc or if -# tags are misspelled. -# -# Exit with 0 if and only if all tests pass. -# -# Run with -v to be a bit more verbose. - -lexctags=$(mktemp -t giella-tag_test.XXXXXXXXXXX) -roottags=$(mktemp -t giella-tag_test.XXXXXXXXXXX) -trap 'rm -f "${lexctags}" "${roottags}"' EXIT - -# Get giella-core from the test environment: -giella_core=$GIELLA_CORE - -# If verbose: -if [[ $1 == "-v" ]]; then - echo "$0: Are there tags not declared in root.lexc or misspelled?" +# ensure that we are ran from make or setup properly +if test -z "$srcdir" ; then + echo "srcdir= not set, this must be run from make or set srcdir=." + exit 2 fi - -# Extract USED tags: -sed -e '1,/LEXICON Root/d' < \ - ../lexicon.lexc | # Extract all lines after LEXICON Root - ${giella_core}/scripts/extract-used-tags.sh | # Extract tags, local mods after this line: - LC_ALL=no_NO.UTF8 sort -u \ - > "${lexctags}" - -# Extract DEFINED tags: -sed -n '/LEXICON Root/q;p' \ - ../lexicon.lexc | # Extract all lines before LEXICON Root - ${giella_core}/scripts/extract-defined-tags.sh | # Extract tags, local mods after this line: - LC_ALL=no_NO.UTF8 sort -u \ - > "${roottags}" - -# Compare the two sets of tags, report and fail if there is a diff: -check=$(LC_ALL=no_NO.UTF8 comm -23 "${lexctags}" "${roottags}") -if [[ -n "${check}" ]]; then - echo "$0: Have a look at these:" - echo "${check}" +if test -z "$GIELLA_CORE" ; then + echo "GIELLA_CORE= must point to giella-core" + exit 2 +fi +relpath="$GIELLA_CORE/scripts/" +testrunner="$relpath/tag_test.sh" +if ! test -x "$testrunner" ; then + echo "missing test runner in $testrunner" + exit 77 +fi +lexc=$srcdir/../lexicon.lexc +if ! test -f $lexc ; then + echo combined $lexc missing or disappeared exit 1 -elif [[ $1 == "-v" ]]; then - echo "$0: No errors found." fi +$testrunner $lexc