From d25d24ea1e4972b2ec554b8666f1e681b191726c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 17 May 2010 13:30:23 +0200 Subject: [PATCH] Add script for export filter testing. When using --record, the converter is considered as good and the result will be recorded. When using --test, the result is compared to the recorded version. --- writer/test.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) create mode 100755 writer/test.sh diff --git a/writer/test.sh b/writer/test.sh new file mode 100755 index 0000000..8415c79 --- /dev/null +++ b/writer/test.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +# you need to run 'soffice -headless -accept="socket,port=8100;urp;" -nologo' manually in an other tab + +find_files() { + find $input -type f ! -name "*.sh" -a ! -name "*.$formatToTest" -a ! -name "*.xml" +} + +usage() { + echo "usage: test.sh --record [filename]" + echo " test.sh --test [filename]" + echo + echo "When using --record, the converter is considered as good and the result will be recorded." + echo "When using --test, the result is compared to the recorded version." + exit +} + +jar="$(ls ~/downloads/jodconverter-*/lib/jodconverter-cli-*.jar|head -n 1)" + +formatToTest="rtf" + +if [ "$1" = "--record" ]; then + record=t + action="Record" +elif [ "$1" = "--test" ]; then + test=t + action="Test" +else + usage +fi + +if [ -n "$2" ]; then + input="$2" +else + input="." +fi + +find_files | while read i +do + result="$(echo "$i"|sed "s/\.[^.]\+$/.$formatToTest/")" + savedResult="$(echo "$i"|sed "s/\.[^.]\+$/.good.$formatToTest/")" + echo "* $i -> $result" + java -jar "$jar" -f $formatToTest "$i" + if [ $? != 0 ]; then + echo "ERROR: Failed to convert '$i'!" + exit 1 + else + if [ "$record" ]; then + mv "$result" "$savedResult" + else + if ! diff -u "$savedResult" "$result"; then + echo "ERROR: '$i' differs!" + exit 1 + fi + fi + fi +done +if [ ${PIPESTATUS[1]} = 0 ]; then + echo "$action done ($(find_files |wc -l) tests)." +fi -- 1.7.1