summaryrefslogtreecommitdiff
path: root/tests/gi-tester
blob: 78a5c43725cce4e93b9c92a6cfdc618c030fab3c (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
#!/usr/bin/env bash

targetname=$1

# Note the target name for the documentation targets (-C, -Python, -Gjs)
# incorrectly include a relative path to the srcdir, strip that off for usage
# in directory diffs.
targetbase=${targetname##*/}

case $targetname in
*.gir)
    diff -u -U 10 ${srcdir}/${targetname::-4}-expected.gir ${builddir}/${targetname}
    exit $?
    ;;
*.typelib)
    # Do nothing for typelibs, this just ensures they build as part of the tests
    exit 0
    ;;
*-C)
    diff -r -u -w -B -U 10 ${srcdir}/${targetbase}-expected ${builddir}/${targetbase}
    exit $?
    ;;
*-Python)
    diff -r -u -w -B -U 10 ${srcdir}/${targetbase}-expected ${builddir}/${targetbase}
    exit $?
    ;;
*-Gjs)
    diff -r -u -w -B -U 10 ${srcdir}/${targetbase}-expected ${builddir}/${targetbase}
    exit $?
    ;;
*-sections.txt)
    diff -u -w -B -U 10 ${srcdir}/${targetname::-4}-expected.txt ${builddir}/${targetname}
    exit $?
    ;;
*.py)
    if [[ -z "${TESTARGS}" ]]; then
        # Run as regular Python file if TESTARGS is empty
        PYTHONPATH=${top_builddir}:${top_srcdir} ${PYTHON} ${targetname}
        exit $?
    else
        # Run as Python unittest module with TESTARGS concatenated to the basename of target
        targetbasename=`basename "${targetname}" .py`
        PYTHONPATH=${top_builddir}:${top_srcdir} ${PYTHON} -m unittest -v "${targetbasename}.${TESTARGS}"
        exit $?
    fi
    ;;
*)
    echo $"Usage: [TESTARGS=<args>] gi-tester <targetname>"
    exit 1
    ;;
esac