|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 |
| -# Check if there are tags which are not declared in root.lexc or if |
4 |
| -# tags are misspelled. |
5 |
| -# |
6 |
| -# Exit with 0 if and only if all tests pass. |
7 |
| -# |
8 |
| -# Run with -v to be a bit more verbose. |
9 |
| - |
10 |
| -lexctags=$(mktemp -t giella-tag_test.XXXXXXXXXXX) |
11 |
| -roottags=$(mktemp -t giella-tag_test.XXXXXXXXXXX) |
12 |
| -trap 'rm -f "${lexctags}" "${roottags}"' EXIT |
13 |
| - |
14 |
| -# Get giella-core from the test environment: |
15 |
| -giella_core=$GIELLA_CORE |
16 |
| - |
17 |
| -# If verbose: |
18 |
| -if [[ $1 == "-v" ]]; then |
19 |
| - echo "$0: Are there tags not declared in root.lexc or misspelled?" |
| 3 | +# ensure that we are ran from make or setup properly |
| 4 | +if test -z "$srcdir" ; then |
| 5 | + echo "srcdir= not set, this must be run from make or set srcdir=." |
| 6 | + exit 2 |
20 | 7 | fi
|
21 |
| - |
22 |
| -# Extract USED tags: |
23 |
| -sed -e '1,/LEXICON Root/d' < \ |
24 |
| - ../lexicon.lexc | # Extract all lines after LEXICON Root |
25 |
| - ${giella_core}/scripts/extract-used-tags.sh | # Extract tags, local mods after this line: |
26 |
| - LC_ALL=no_NO.UTF8 sort -u \ |
27 |
| - > "${lexctags}" |
28 |
| - |
29 |
| -# Extract DEFINED tags: |
30 |
| -sed -n '/LEXICON Root/q;p' \ |
31 |
| - ../lexicon.lexc | # Extract all lines before LEXICON Root |
32 |
| - ${giella_core}/scripts/extract-defined-tags.sh | # Extract tags, local mods after this line: |
33 |
| - LC_ALL=no_NO.UTF8 sort -u \ |
34 |
| - > "${roottags}" |
35 |
| - |
36 |
| -# Compare the two sets of tags, report and fail if there is a diff: |
37 |
| -check=$(LC_ALL=no_NO.UTF8 comm -23 "${lexctags}" "${roottags}") |
38 |
| -if [[ -n "${check}" ]]; then |
39 |
| - echo "$0: Have a look at these:" |
40 |
| - echo "${check}" |
| 8 | +if test -z "$GIELLA_CORE" ; then |
| 9 | + echo "GIELLA_CORE= must point to giella-core" |
| 10 | + exit 2 |
| 11 | +fi |
| 12 | +relpath="$GIELLA_CORE/scripts/" |
| 13 | +testrunner="$relpath/tag_test.sh" |
| 14 | +if ! test -x "$testrunner" ; then |
| 15 | + echo "missing test runner in $testrunner" |
| 16 | + exit 77 |
| 17 | +fi |
| 18 | +lexc=$srcdir/../lexicon.lexc |
| 19 | +if ! test -f $lexc ; then |
| 20 | + echo combined $lexc missing or disappeared |
41 | 21 | exit 1
|
42 |
| -elif [[ $1 == "-v" ]]; then |
43 |
| - echo "$0: No errors found." |
44 | 22 | fi
|
| 23 | +$testrunner $lexc |
0 commit comments