summaryrefslogtreecommitdiff
path: root/run-test.sh.in
blob: cee60c34b9443932998d153ea377b411c951f0eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

dump_files()
{
    for file in $(ls "$1"); do
        filepath="$1/$file"
        fileext=$(echo "$filepath" | sed -e 's/.*\.//g')
        if test $fileext != "xls"; then
            continue
        fi
        dumppath=$(echo "$filepath" | sed -e 's/\.xls$/\.log/g')
        @PYTHON@ "$XLS_DUMP_PATH" --dump-mode=canonical-xml "$filepath" > "$dumppath"
    done
}

source @ROOTDIR@/setenv.sh

# First, import and export each xls document.
rm -rf "$CTRL_XLS_OUT_DIR"
export LD_LIBRARY_PATH=@OOO_INSTALL_PATH@/program:@OOO_INSTALL_PATH@/ure/lib
mkdir "$CTRL_XLS_OUT_DIR" 2>/dev/null || /bin/true
cd @OOO_INSTALL_PATH@/ure/lib
@EXECDIR@/run-soffice || exit 1

# Dump the contents of before and after documents.
rm $CTRL_XLS_IN_DIR/*.log
dump_files "$CTRL_XLS_IN_DIR"  || exit 1
dump_files "$CTRL_XLS_OUT_DIR" || exit 1

# Now, compare the dumps to see if anything differs.
mkdir "$LOG_DIFF_DIR" 2>/dev/null || /bin/true
everdifferent="no"
for file in $(ls "$CTRL_XLS_IN_DIR"); do
    fileext=$(echo "$file" | sed -e 's/.*\.//g')
    if test $fileext != "log"; then
        continue
    fi
    inpath="$CTRL_XLS_IN_DIR/$file"
    outpath="$CTRL_XLS_OUT_DIR/$file"
    diffoutpath="$LOG_DIFF_DIR/$file"
    filesdiffer="no"
    /usr/bin/diff -u "$inpath" "$outpath" > "$diffoutpath" || filesdiffer="yes"
    if test "$filesdiffer" == "yes"; then
        xlsfile=$(echo "$file" | sed -e 's/\.log$/\.xls/g')
        echo "$xlsfile differs."
        everdifferent="yes"
    else
        rm "$diffoutpath"
    fi
done

if test "$everdifferent" == "yes"; then
    echo "Content of one or more files differ.  Check the full diff output(s) in $LOG_DIFF_DIR for more details."
else
    echo "All documents have passed the test!"
fi