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:
@ -8,3 +8,4 @@ PHOGEN_WORD_LIST = files('data/words_alpha.txt.backup')
|
||||
|
||||
subdir('c')
|
||||
subdir('python')
|
||||
subdir('tests')
|
||||
|
||||
12
tests/meson.build
Normal file
12
tests/meson.build
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
_phogen_map_c = PHOGEN_MAP_EXE.full_path()
|
||||
_phogen_map_py = meson.source_root() / '@0@'.format(PHOGEN_MAP_PY[0])
|
||||
_word_list = meson.source_root() / '@0@'.format(PHOGEN_WORD_LIST[0])
|
||||
|
||||
test('test_phogen_map',
|
||||
find_program('test_phogen_map'),
|
||||
env : ['PHOGEN_MAP_C=@0@'.format(_phogen_map_c),
|
||||
'PHOGEN_MAP_PY=@0@'.format(_phogen_map_py),
|
||||
'PHOGEN_WORD_LIST=@0@'.format(_word_list)])
|
||||
|
||||
|
||||
37
tests/test_phogen_map
Executable file
37
tests/test_phogen_map
Executable 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
|
||||
Reference in New Issue
Block a user