-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_tests.sh
executable file
·47 lines (39 loc) · 1.37 KB
/
test_tests.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
#!/usr/bin/env bash
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # no color
# Function to run Python files in a specified directory
run_python_files() {
local dir_path=$1
# Check if the directory exists
if [ ! -d "$dir_path" ]; then
echo "Error: Directory $dir_path does not exist."
return 1
fi
success=1
# Loop through all Python files in the specified directory
for file in "$dir_path"/*.py
do
echo -e "${RED}Running $file...${NC}"
# no block check is added to files int ./tests
# Ignore stdout and warnings, print errors
python -W ignore "$file" "--no-block" > /dev/null
# Check if the last command was successful
if [ $? -ne 0 ]; then
echo "Error: $file failed to run successfully."
success=0
fi
done
if [ $success -eq 1 ]; then
echo "All Python files in $dir_path ran successfully."
fi
}
echo -e "${BLUE}################## test files in ./tests #####################################${NC}"
run_python_files .
echo ""
echo -e "${BLUE}################## inspect plots in ./examples ###############################${NC}"
run_python_files ../examples
# Studies take a relativly long time to run, check less frequently
echo ""
echo -e "${BLUE}################## inspect plots in ./studies ################################${NC}"
run_python_files ../studies