Skip to content

Commit f76ff46

Browse files
committedApr 16, 2024··
test: ensure via testing all test*.py files call get_env_vars() with test=True
Signed-off-by: Zack Koppert <zkoppert@github.com>
1 parent 0856d7d commit f76ff46

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
 

‎.github/scripts/env_vars_check.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Find all test_*.py files
4+
files=$(find . -name "test_*.py")
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
NC='\033[0m' # No Color
8+
9+
# Loop through each file
10+
for file in $files; do
11+
# Search for instances of get_env_vars() with no arguments
12+
result=$(grep -n "get_env_vars()" "$file")
13+
14+
# If any instances are found, print the file name and line number
15+
if [ -n "$result" ]; then
16+
echo "Found in $file:"
17+
echo "$result"
18+
echo -e "${RED}ERROR: get_env_vars() should always set test=True in test*.py files.${NC}"
19+
exit 1
20+
fi
21+
done
22+
echo -e " ${GREEN}PASS:${NC} All test*.py files call get_env_vars() with test=True."

‎Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.PHONY: test
22
test:
33
pytest -v --cov=. --cov-config=.coveragerc --cov-fail-under=80 --cov-report term-missing
4+
.github/scripts/env_vars_check.sh
45

56
.PHONY: clean
67
clean:

0 commit comments

Comments
 (0)
Please sign in to comment.