Test Scripts In The New Infra
Testing in the new infra relies on the testing infrastructure provided by
- write a shell script, perl script, or other executable, and return correct
exit values - add that executable to the TESTS variable in the Makefile.am file in
the dir where the executable is located - run the command make check - this will also rebuild any targets not
up-to-date
Existing shell scripts for testing
Presently (January 2014) there are quite a few shell scripts for testing the
-
generate-noun-lemmas.sh - will check that the lemma can generate itself
-
run-gt-desc-yaml-testcases.sh - will run all yaml tests written for the descriptive analyser/generator
-
run-gt-norm-anayaml-testcases.sh - will run yaml test for analysis only against the normative analyser
-
run-gt-norm-genyaml-testcases.sh - will run yaml test for generation only against the normative generator
-
run-gt-norm-yaml-testcases.sh - will run all yaml tests written for the normative analyser/generator
- run-lexc-testcases.sh - will run tests written as part of the lexc source files
Many languages have an extensive set of so called YAML tests,
What to add to Makefile.am
All shell scripts or other test scripts that should be run should be listed in
TESTS= # Only test spellers if we build spellers: if WANT_SPELLERS TESTS+=test-zhfst-file.sh endif # WANT_SPELLERS
That is, the TESTS variable is empty by default (i.e. no tests will be run),
During development it is common that some tests fail. In such cases the
When the development has progressed to the point where the test actually PASSes,
If you have tests that test that something does fail (e.g. when given bad
Naming conventions for yaml tests
Some parts of the naming conventions are described on
- the name of the shell script is completely free form, but should for clarity
reflect the fst being tested; - the fst specifier in the yaml file name (see the docu linked to above)
must be specified in the shell script. - the location of the yaml testing shell script is crucial - it must be
located in a directory within test/ parallell to the directory where the fst being tested is located. That is, if the fst file(s) you want to test is located in $GTLANG/tools/mt/apertium/, then the shell script for running the yaml tests must be located in $GTLANG/test/tools/mt/apertium/. The yaml files themselves can be in another directory, in which case that directory must be specified in the shell script. The default is that the yaml files are in the same dir as the shell script for running the yaml tests.
Adding yaml tests for a new fst class
To add a new shell script to test a new type of fst('s), it is easiest to just
Details on how to write new testing shell scripts
As mentioned above, any shell script or other script (perl, python) - even a
- 0 - the test succeeded
- 77 - the test was skipped for some reason (test data not found, some other
precondition not met) - 99 - a hard failure (such as segmentation fault, etc - not very useful to us)
- any other value - the test failed
If you need to reference data files, you have access to the variable $srcdir
Test scripts can be as simple or complicated as you want, as long as it
- correct exit value (see above)
- all path and file references are relative to the local dir, specified using
$srcdir
Here is an example of a very simpe test script (a shell script):
#!/bin/sh
TOOLDIR=$srcdir/../../tools/src
for i in "" .sfst .ofst .foma; do
if ((test -z "$i") || $TOOLDIR/hfst-format --list-formats | grep $i > /dev/null); then
if test -f cat2dog$i ; then
if ! $TOOLDIR/hfst-invert cat2dog$i > test ; then
exit 1
fi
if ! $TOOLDIR/hfst-compare -s test dog2cat$i ; then
exit 1
fi
rm test;
fi
fi
done
The script (taken from the Hfst3 distro) loops over the fst suffixes, and for
This script can easily be adapted and extended for our purposes, to e.g. test

