-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlib.sh
48 lines (42 loc) · 1.25 KB
/
lib.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
#!/bin/sh
PARALLEL="${PARALLEL:-1}"
# Interpret xarg return codes
xargsRetCode2Msg() {
if [ "$#" -ne 1 ] ; then
echo "xargsRetCode2Msg must be called with exactly one argument!" 1>&2
fi
if [ "$es" -eq 127 -o "$es" -eq 126 ] ; then
echo "Couldn't find executable shell. Something is v e r y wrong."
elif [ "$es" -eq 125 ] ; then
echo "One or more tests were interrupted!"
elif [ "$es" -eq 0 ] ; then
echo "All tests passed!"
else
echo "One or more tests failed. See messages above!"
fi
}
#Get a directory path with guaranteed trailing slash
getDir()
(
dirr="${1:-./}"
dirr="${dirr%/}/"
echo "$dirr"
)
# Test if file is executable (and exists)
# Exit with error 1 otherwise
assertExe() {
if [ ! -x "$1" ] ; then
echo "There's no '$(basename $1)' in the given location or it is not executable!"
echo " ($(dirname $1))"
exit 1
fi
}
# Test if run-all variant is used correctly, exit with error 1 otherwise
# Args: <utility name> <all other args, passed via "$@"> ...
assertUsage() {
if [ "$#" -gt 3 ] || [ "$#" -lt 2 ] ; then
echo "Too many or too few arguments!"
echo 'run-all.sh <executable> [<root dir of tests>]'
exit 1
fi
}