File: test_command_line.sh

package info (click to toggle)
python-trubar 0.3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 716 kB
  • sloc: python: 2,968; sh: 375; makefile: 3; javascript: 1
file content (67 lines) | stat: -rwxr-xr-x 1,106 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
function print_run() {
    echo "> " $1
    if [ -z $2 ]
    then
        ${1}
    else
        ${1} > $2 2>&1
    fi
}

sysdiff=`which diff`
function diff() {
    oldstate="$(set +o)"
    set +e
    eval $sysdiff "$@" > /dev/null
    if [ $? -ne 0 ]
    then
        echo diff $@
        eval $sysdiff "$@"
        exit 1
    fi
    eval "$oldstate"
}

function check_exit_code() {
  # Test that exit code is nonzero (if $2 is omitted) or zero (if $2 is -ne)
  # $1 is error message; see default below :)
    if [ $? ${2:--eq} 0 ]
    then
        echo ${1:-"Non-zero exit code expected"}
        exit 1
    fi
}

cd shell_tests
for d in ${1:-*}/
do
    if [ ! -f $d/test.sh ]; then continue; fi

    cd $d
    rm -rf tmp
    mkdir tmp
    ( set -e
      . test.sh
    )
    if [ $? -ne 0 ]
    then
         echo ""
         echo "*** FAIL!"
         test ! -z "$FAILED" && FAILED="$FAILED, "
         FAILED=$FAILED${d%/}
    else
         rm -rf tmp
    fi
    cd ..
    echo ""
    echo ""
done
cd ..

if [ ! -z "$FAILED" ]
then
    echo "Failed tests: $FAILED"
    exit 1
else
    echo "Success."
fi