From 4838b356022c3b10dbc05acca12e015e4f64bf0d Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Sun, 27 Dec 2020 21:08:04 +0200 Subject: [PATCH] Tests: new test file for command line options This is intended for testing command line options such as -k 2, --punct and so on. --- .gitignore | 1 + Makefile.am | 3 ++- tests/cmd_options.test | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 tests/cmd_options.test diff --git a/.gitignore b/.gitignore index 1920d279..6d4383e4 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,7 @@ tests/*.check !tests/klatt.test !tests/mbrola.test !tests/dictionary.test +!tests/cmd_options.test espeak-ng.pc diff --git a/Makefile.am b/Makefile.am index 61739c2d..e41a2e20 100644 --- a/Makefile.am +++ b/Makefile.am @@ -271,7 +271,8 @@ check: tests/encoding.check \ tests/non-executable-files-with-executable-bit.check \ tests/klatt.check \ tests/mbrola.check \ - tests/bom.check + tests/bom.check \ + tests/cmd_options.check ##### fuzzer: diff --git a/tests/cmd_options.test b/tests/cmd_options.test new file mode 100755 index 00000000..869a96ca --- /dev/null +++ b/tests/cmd_options.test @@ -0,0 +1,40 @@ +#!/bin/sh + +test_commandlineoptions() { + TEST_LANG=$1 + MESSAGE=$2 + OPTIONS=$3 + EXPECTED=$4 + TEST_TEXT=$5 + TEST_BROKEN=${6:-false} + + if [ "x$MESSAGE" = x- ] ; then + echo "testing ${TEST_LANG}" + else + echo "testing ${TEST_LANG} ($MESSAGE)" + fi + ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \ + src/espeak-ng ${OPTIONS} -xq -v ${TEST_LANG} "${TEST_TEXT}" > actual.txt + echo "${EXPECTED}" > expected.txt + if [ x$TEST_BROKEN = xbroken ] ; then + diff expected.txt actual.txt || (echo "... ignoring error (broken)" && true) + else + diff expected.txt actual.txt || exit 1 + fi +} + +##### Script coverage + +# missing tests: -k 10, -a, -d, -g, -p, -s, -w, -b, -z, -pho, -phonout, --punct, --split, --tie, -load + +# tested in other tests: --ipa, -x, -X, -v, -m, -f, -q, --compile, --compile-debug, --compile-mbrola, --compile-intonations, --compile-phonemes + +test_commandlineoptions en "Capitals (sound)" "-k 1" "_#X1T'aI _#X1'Es Iz a# _#X1t'Es _#X1t'i: fO@ _#X1k'apIt@Lz" "ThiS is a TesT for Capitals" +test_commandlineoptions en "Capitals (word)" "-k 2" "k,ap@-t@L T'aI k,ap@-t@L 'Es Iz a# k,ap@-t@L t'Es k,ap@-t@L t'i: fO@ k,ap@-t@L k'apIt@Lz" "ThiS is a TesT for Capitals" +test_commandlineoptions en "Separator" "--sep=q" "hq@qlq'oU wq'3:qlqd" "hello world" +test_commandlineoptions en "Linelength" "-l 15" "wi:; 'A@ +wi:; A@ t'EstIN +wi:; A@ t'EstIN l'aInlENT wi:; A@ t'EstIN l'aInlENT l'aIk D'Is" "We are +We are testing +We are testing linelength +We are testing linelength like this"