-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.sh
45 lines (36 loc) · 1.12 KB
/
test.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
#!/bin/bash
# Initialize variables to store passed and failed test cases
passed_cases=""
failed_cases="None"
# Function to run pytest and process the output
# Function to run pytest and process the output
run_test() {
# Run pytest with verbose and no capture, redirect stderr to stdout
pytest_output=$(python3 -m pytest -vv "$1" 2>&1)
# Print pytest output
echo "$pytest_output"
# Check if pytest output contains "skipped"
if grep -q "skipped" <<< "$pytest_output"; then
echo "Test case $1 was skipped"
return 0 # Exit with success code
fi
# Check if pytest output contains "failed"
if grep -q "failed" <<< "$pytest_output"; then
# Handle failed test case
echo "Test case $1 failed"
failed_cases+=" $1"
return 1
fi
# Handle successful test case
echo "Test case $1 passed"
passed_cases+=" $1"
return 0
}
# Main loop to run tests for each test case
for test_case in "$@"; do
run_test "$test_case"
done
# Display summary of test results
echo "Summary:"
echo "Passed test cases:${passed_cases}"
echo "Failed test cases:${failed_cases}"