meson: Add unit test framework

This commit also adds the first unit test. The unit test compares the
phonetic map generated by the Python and by the C implementation and
fails if the generated maps are different.
This commit is contained in:
2021-09-22 19:22:37 +02:00
parent 638f1771a8
commit 3852c4efc9
3 changed files with 50 additions and 0 deletions

37
tests/test_phogen_map Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh -ex
#
# Test Case:
#
# Use the Python and C implementations to produce the various tables. Compare
# if the generated files are identical for both.
#
# Environment:
#
# PHOGEN_MAP_C - should point to the C executable
# PHOGEN_MAP_PY - should point to the Python executable
# PHOGEN_WORD_LIST - word list
function on_exit()
{
rm -v /tmp/phogen_*_$$.h
rm -v /tmp/phogen_*_$$.json
rm -v /tmp/phogen_*_$$.py
}
trap on_exit EXIT
$PHOGEN_MAP_C \
--input "$PHOGEN_WORD_LIST" \
--clang "/tmp/phogen_c_$$.h" \
--python "/tmp/phogen_c_$$.py" \
--json "/tmp/phogen_c_$$.json"
$PHOGEN_MAP_PY \
--input "$PHOGEN_WORD_LIST" \
--clang "/tmp/phogen_py_$$.h" \
--python "/tmp/phogen_py_$$.py" \
--json "/tmp/phogen_py_$$.json"
cmp /tmp/phogen_c_$$.h /tmp/phogen_py_$$.h
cmp /tmp/phogen_c_$$.py /tmp/phogen_py_$$.py
cmp /tmp/phogen_c_$$.json /tmp/phogen_py_$$.json