-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun_tests_in_isolation
executable file
·47 lines (38 loc) · 1.11 KB
/
run_tests_in_isolation
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
#!/usr/bin/env bash
# This file is a symlink from 'tmux-test' plugin.
# You probably don't want to edit it.
# This script should be run within an isolated enviroment (Vagrant, travis).
# Depending on what the tests do, it might NOT be safe to run this script
# directly on the development machine.
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
EXIT_VALUE=0 # running a test suite is successful by default
all_test_files() {
ls -1 "$CURRENT_DIR" | # test files are in the current dir
\grep -i "^test" | # test file names start with "test"
xargs # file names in a single line
}
set_exit_val_to_false() {
EXIT_VALUE=1
}
run_tests() {
local test_file tests_files
if [ "$#" -gt 0 ]; then
test_files="${@//tests\//}" # remove 'tests/' directory prefix
else
test_files="$(all_test_files)"
fi
for test_file in $test_files; do
echo "Running test: $test_file"
"${CURRENT_DIR}/${test_file}"
# handling exit value
local test_exit_value="$?"
if [ "$test_exit_value" -ne 0 ]; then
set_exit_val_to_false
fi
done
}
main() {
run_tests "$@"
exit "$EXIT_VALUE"
}
main "$@"