-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.sh
executable file
·54 lines (47 loc) · 1.52 KB
/
runner.sh
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
#!/usr/bin/env bash
set -e
# Restrictions:
# - Will not work with BSD "awk" (i.e. on macOS) due to "awk: invalid -v option".
#
# Usage:
# - Run all tests.
# bash runner.sh "./tests/travis"
#
# - Run non-bash tests.
# TRAVIS_COMMIT_MESSAGE="[skip bash]" bash runner.sh "./tests/travis"
#
# - List available tests.
# bash runner.sh "./tests/travis" --list
#
# - List non-bash tests.
# TRAVIS_COMMIT_MESSAGE="[skip bash]" bash runner.sh "./tests/travis" --list
cd "$1"
declare -A TESTS=()
declare -r OPTION="$2"
# Iterate all over subdirectories.
for INTERPRETER in [a-z]*/; do
EXTENSION="$INTERPRETER/.extension"
# Assume tests are in a directory that has the ".extension" file.
if [ -f "$EXTENSION" ]; then
TESTS["${INTERPRETER%%/}"]="$(head -n1 "$EXTENSION")"
fi
done
# Parse the commit message that looks like "#120: [skip bash/init][ skip python] Commit name".
# The resulting string will be: "|skipbash/init|skippython|"
if [ -v TRAVIS_COMMIT_MESSAGE ]; then
PARAMS="|$(awk -vRS="]" -vFS="[" '{print $2}' <<< "$TRAVIS_COMMIT_MESSAGE" | head -n -1 | tr '\n' '|' | tr -d '[:space:]')"
fi
for INTERPRETER in "${!TESTS[@]}"; do
if [[ ! "$PARAMS" =~ \|skip$INTERPRETER\| ]]; then
for TEST in "$INTERPRETER"/[a-z]*."${TESTS[$INTERPRETER]}"; do
if [[ ! "$PARAMS" =~ \|skip$TEST\| ]]; then
if [ "--list" == "$OPTION" ]; then
echo "- $TEST"
else
echo "[$(date +%Y-%m-%dT%H:%M:%S%z)] -- $TEST"
${INTERPRETER} "$TEST"
fi
fi
done
fi
done