-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_python_test.bash
More file actions
executable file
·102 lines (90 loc) · 2.21 KB
/
run_python_test.bash
File metadata and controls
executable file
·102 lines (90 loc) · 2.21 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
#===============================================================================
#
# FILE: run_python_tests.sh
#
# USAGE: run_python_tests.sh
#
# DESCRIPTION: This script runs Pylint and flake8 tests on all Python files
# in the current directory and its subdirectories.
#
# OPTIONS:
# -h, --help Display this help message
# -v, --version Display script version
#
# REQUIREMENTS: pylint, flake8
#
# BUGS:
#
# NOTES:
#
# AUTHOR:
# Mario Luz (ml), mario.mssl[at]gmail.com
#
# COMPANY:
#
# VERSION: 1.2
# CREATED: 2024-11-18 17:00:00
# REVISION:2024-11-22 11:00:00
#===============================================================================
# Set script version
SCRIPT_VERSION="1.2"
# Display help message
show_help() {
cat << EOF
Usage: $0 [OPTIONS]
This script runs Pylint and flake8 tests on all Python files.
OPTIONS:
-h, --help Display this help message
-v, --version Display script version
Examples:
$0
$0 -h
$0 --version
EOF
}
# Display script version
show_version() {
echo "$0 version $SCRIPT_VERSION"
}
# Get the commit message from the command line argument or prompt for one
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
show_help
exit 0
;;
-v|--version)
show_version
exit 0
;;
*)
echo "Invalid option: $1"
show_help
exit 1
;;
esac
done
# Check if pylint is installed
if ! command -v pylint &> /dev/null; then
echo "Pylint is not installed. Install it with 'pip install pylint'."
exit 1
fi
# Check if flake8 is installed
if ! command -v flake8 &> /dev/null; then
echo "Flake8 is not installed. Install it with 'pip install flake8'."
exit 1
fi
export PYTHONPATH="${PYTHONPATH}:$(dirname $(pwd))"
# Execute pylint and flake8 on all .py files
echo "Running tests..."
for file in $(find . -name "*.py"); do
echo "Testing file: $file"
echo "********************************************************************"
# Execute pylint on all .py files
echo "Running Pylint..."
pylint --rcfile=.pylintrc --init-hook="import sys; sys.path.append('.')" "$file"
# Execute flake8 on all .py files
echo "Running Flake8..."
flake8 --config=.flake8 "$file"
done