-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy path.testAPI.sh
More file actions
53 lines (42 loc) · 1.61 KB
/
Copy path.testAPI.sh
File metadata and controls
53 lines (42 loc) · 1.61 KB
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
#!/usr/bin/env bash
if [ -z "$WM_PROJECT" ]; then
echo "OpenFOAM environment not found, forgot to source the OpenFOAM bashrc?"
exit 1
fi
echo "Running API tests"
# Make the primal run fast for every discovered Python run script.
find . -type f -name 'run*.py' -exec sed -i '/"primalMinResTol":/c\ "primalMinResTol": 0.9,' {} \;
# Discover case directories that contain both the exact preprocessing script
# and at least one Python run script in the same folder.
mapfile -d '' case_dirs < <(
find . -type f -name 'preProcessing.sh' -print0 | while IFS= read -r -d '' preprocessing_script; do
case_dir=$(dirname "$preprocessing_script")
if find "$case_dir" -maxdepth 1 -type f -name 'run*.py' | grep -q .; then
printf '%s\0' "$case_dir"
fi
done | sort -zu
)
if [ ${#case_dirs[@]} -eq 0 ]; then
echo "No test cases found."
exit 0
fi
for case_dir in "${case_dirs[@]}"; do
echo "Discovered case: ${case_dir#./}"
# Collect all Python run scripts that live beside preProcessing.sh.
mapfile -t run_scripts < <(find "$case_dir" -maxdepth 1 -type f -name 'run*.py' | sort)
if [ ${#run_scripts[@]} -eq 0 ]; then
echo "Skipping ${case_dir#./}: no run scripts found."
continue
fi
(
cd "$case_dir" || exit 1
echo "Running preProcessing.sh in ${case_dir#./}"
./preProcessing.sh || exit 1
# Run every discovered Python driver after preprocessing completes.
for run_script in "${run_scripts[@]}"; do
script_name=$(basename "$run_script")
echo "Running ${case_dir#./}/${script_name}"
python "$script_name" -task=run_model || exit 1
done
) || exit 1
done