Welcome to mirror list, hosted at ThFree Co, Russian Federation.

run-step.sh « ci « scripts - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4ea5fbc4c3a3e3593a5fc7c84782901ea32fe587 (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
57
58
59
60
#!/bin/bash -e
TIMEOUTCMD=`dirname "${BASH_SOURCE[0]}"`/babysitter
if ! ${TIMEOUTCMD} -h >/dev/null 2>&1; then
    TIMEOUTCMD=timeout  # fall back to timeout if babysitter doesn't work (e.g. python not installed or wrong version)
fi

export MONO_BABYSITTER_LOG_FILE=babysitter_report.json_lines

helptext ()
{
    echo "run-step.sh {--label=LABEL} {--skip|--timeout=TIMEOUT [--fatal]} command to run with arguments"
}

for i in "$@"
do
case $i in
    --help)
    helptext
    exit 0
    ;;
    --label=*)
    LABEL="${i#*=}"
    shift # past argument=value
    ;;
    --timeout=*)
    TIMEOUT="${i#*=}"
    shift # past argument=value
    ;;
    --fatal)
    FATAL="true"
    shift # past argument
    ;;
    --skip)
    SKIP="true"
    shift # past argument
    ;;
    *)
            # unknown option, assume just part of cmdline
    ;;
esac
done
if [ -n "${SKIP}" ] && [ -z "${LABEL}" ]
    then helptext
    exit 1
fi
if [ -n "${SKIP}" ]
    then echo -e "*** start: ${LABEL}\n*** end(0): ${LABEL}: \e[45mSkipped\e[0m"
    exit 0
fi
if [ -z "${LABEL}" ] || [ -z "${TIMEOUT}" ]
    then helptext
    exit 1
fi
STARTTIME=`date +%s`
echo "*** start: ${LABEL}"
if [ -n "${FATAL}" ]; then
    ${TIMEOUTCMD} --signal=ABRT --kill-after=60s ${TIMEOUT} "$@" && echo -e "*** end($(echo $(date +%s) - ${STARTTIME} | bc)): ${LABEL}: \e[42mPassed\e[0m" || (echo -e "*** end($(echo $(date +%s) - ${STARTTIME} | bc)): ${LABEL}: \e[41mFailed\e[0m" && exit 1)
else
    ${TIMEOUTCMD} --signal=ABRT --kill-after=60s ${TIMEOUT} "$@" && echo -e "*** end($(echo $(date +%s) - ${STARTTIME} | bc)): ${LABEL}: \e[42mPassed\e[0m" || echo -e "*** end($(echo $(date +%s) - ${STARTTIME} | bc)): ${LABEL}: \e[43mUnstable\e[0m"
fi