File: run_common_test.in

package info (click to toggle)
yaws 2.0.8%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,084 kB
  • sloc: erlang: 42,190; sh: 2,543; javascript: 1,459; ansic: 890; makefile: 878; lisp: 79; python: 34; xml: 12; php: 1
file content (127 lines) | stat: -rwxr-xr-x 3,480 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash

CT_RUN=@CT_RUN@
COVER_TO_HTML=@abs_builddir@/cover_to_html.sh
LABEL=@PACKAGE_NAME@
LOG_DIR=@abs_builddir@/logs
LOG_FILE=${LOG_DIR}/${LABEL}.log
CUR_DIR=@abs_builddir@
EBIN_DIR=@abs_top_builddir@/ebin
INC_DIR=@abs_top_builddir@/include
COVERSPEC=@abs_builddir@/@PACKAGE_NAME@.coverspec

LABEL_BRANCH=$(test -d @abs_top_srcdir@/.git && git rev-parse --abbrev-ref HEAD || echo "master")
LABEL_VSN=$(test -d @abs_top_srcdir@/.git && git log -1 --pretty=%h --abbrev=8 || echo "@YAWS_VSN@")

ALL_SUITES=$1
SUITES=$2
GRPS=$3
CASES=$4

if (test x"$SUITES" = xall) || (test x"$SUITES" = x); then
    SUITES=$ALL_SUITES
    GRPS=
    CASES=
fi

nb_suites=$(echo $SUITES | wc -w)
if (test x"$GRPS" = xall) || (test x"$GRPS" = x) ||  (test $nb_suites -gt 1); then
    GRPS=
fi

nb_groups=$(echo $GRPS | wc -w)
if (test x"$CASES" = xall) || (test $nb_suites -gt 1) ||  (test $nb_groups -gt 1); then
    CASES=
fi

suites_groups_and_cases=
if (test x"$SUITES" != x); then
    suites_groups_and_cases="-suite $SUITES"
fi
if (test x"$GRPS" != x); then
    suites_groups_and_cases="$suites_groups_and_cases -group $GRPS"
fi
if (test x"$CASES" != x); then
    suites_groups_and_cases="$suites_groups_and_cases -case $CASES"
fi

cover_opt=
if test x"$USE_COVER" = xyes; then
    cover_opt="-cover $COVERSPEC"
fi

debugger_opt=
if test x"$USE_DEBUGGER" = xyes; then
    debugger_opt="-step [config]"
fi

traces_opt=
if test x"$TRACES" != x; then
    traces_opt="{traces, $TRACES}"
fi

COLORS=$(tput colors 2> /dev/null)
if (test $? = 0) && (test $COLORS -gt 2); then
    red=''
    green=''
    bold=''
    std=''
else
    red= green= bold= std=
fi

export RED_COLOR=$red
export GREEN_COLOR=$green
export STD_COLOR=$std
export BOLD_COLOR=$bold

$CT_RUN -label ${LABEL}-${LABEL_BRANCH}-${LABEL_VSN}            \
        -logdir $LOG_DIR -dir $CUR_DIR $cover_opt               \
        $suites_groups_and_cases -no_auto_compile               \
        -ct_hooks testsuite ["$traces_opt"] $debugger_opt       \
        -pa $EBIN_DIR -pa $CUR_DIR -include $INC_DIR > $LOG_FILE
estatus=$?
case $estatus in
    0) col=$green res=PASS;;
    *) col=$red   res=FAIL;;
esac


if test x"$USE_COVER" = xyes; then
    echo
    echo "${bold}Coverage analysis${std}..."
    $COVER_TO_HTML
fi


TEST_PATH=$(grep "^CWD set to: " ${LOG_FILE} | sed -e 's/^.*"\(.*\)".*$/\1/')
echo "============================================================================${std}"
echo " see ${LOG_FILE} for details${std}"
echo
echo " common_test result: ${TEST_PATH}/index.html${std}"
if test x"$USE_COVER" = xyes; then
    echo " coverage result:    ${LOG_DIR}/cover.html${std}"
fi
echo "============================================================================${std}"
echo

case $estatus in
    0)
        # Success
        ;;
    *)
        init_failures=$(grep -c "_SUITE:init_per_suite_failed failed" ${LOG_FILE})
        ts_failures=$(grep -c "RESULT: Failed" ${LOG_FILE})
        failures=$((init_failures+ts_failures))
        if test $failures == 0; then
            # No failure: This means there are skipped testcases
            estatus=0
        else
            # Only show the log file if failures are found.
            echo "============================ [ yaws.log] ==================================="
            cat ${LOG_FILE}
            echo "============================================================================"
        fi
        ;;
esac
exit $estatus