-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·68 lines (53 loc) · 1.75 KB
/
run_tests.sh
File metadata and controls
executable file
·68 lines (53 loc) · 1.75 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
#!/bin/bash
# AltTester Python Test Runner Script
# This script sets up the environment and runs the Python tests
echo "AltTester Python Test Runner"
echo "============================"
# Check if Python is installed
if ! command -v python3 &> /dev/null; then
echo "Error: Python3 is not installed or not in PATH"
exit 1
fi
# Check Python version
python_version=$(python3 --version 2>&1 | grep -o '[0-9]\+\.[0-9]\+')
required_version="3.8"
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then
echo "Error: Python 3.8 or higher is required. Found: $python_version"
exit 1
fi
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
echo "Activating virtual environment..."
source venv/bin/activate
# Install dependencies
echo "Installing dependencies..."
pip install -r requirements.txt
# Create necessary directories
mkdir -p reports
mkdir -p screenshots-and-logs
# Set environment variables if .env file exists
if [ -f ".env" ]; then
echo "Loading environment variables from .env file..."
export $(cat .env | grep -v '^#' | xargs)
fi
# Run the tests
echo "Running tests..."
python -m pytest "$@"
# Capture exit code
exit_code=$?
# Deactivate virtual environment
deactivate
# create allure report
if command -v allure &> /dev/null; then
echo "Generating Allure report..."
allure generate reports/allure-results --clean -o reports/Allure --single-file
echo "Allure report generated at reports/Allure/index.html"
else
echo "Allure command not found. Skipping report generation."
fi
echo "Test execution completed with exit code: $exit_code"
exit $exit_code