Skip to content

Commit

Permalink
[Template merge] move tag_test.sh to core
Browse files Browse the repository at this point in the history
  • Loading branch information
flammie committed Sep 4, 2024
1 parent a94ef64 commit db5a470
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 40 deletions.
2 changes: 1 addition & 1 deletion m4/giella-macros.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
58 changes: 19 additions & 39 deletions src/fst/morphology/test/tag_test.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
#!/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.
# FIXME: exclude grep -v -E '(\+Enter|\+F[1-9])' | # Remove tag like entries found only in EST

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:
grep -v -E '(\+Enter|\+F[1-9])' | # Remove tag like entries found only in EST
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
45 changes: 45 additions & 0 deletions src/fst/morphology/test/tag_test.sh.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/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?"
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:
grep -v -E '(\+Enter|\+F[1-9])' | # Remove tag like entries found only in EST
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}"
exit 1
elif [[ $1 == "-v" ]]; then
echo "$0: No errors found."
fi
65 changes: 65 additions & 0 deletions src/fst/morphology/test/tag_test.sh.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
--- src/fst/morphology/test/tag_test.sh
+++ 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

0 comments on commit db5a470

Please sign in to comment.