mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-17 05:28:03 +00:00
Refactor test scripts into scripts/ directory and improve CI
- Move run_tests_no_ot.sh and run_tests_with_ot.sh to scripts/ directory - Create scripts/run_tests_with_coverage.py for coverage measurement - Update CI to use scripts from scripts/ directory - Eliminate code duplication between shell scripts and CI configuration - Use Python script with coverage run for proper coverage measurement
This commit is contained in:
50
scripts/run_tests_with_coverage.py
Executable file
50
scripts/run_tests_with_coverage.py
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Run tests with OpenTelemetry enabled and coverage measurement.
|
||||
This script is designed to be used with 'coverage run' command.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def main():
|
||||
# Enable OpenTelemetry
|
||||
os.environ['ENABLE_OPENTELEMETRY'] = 'true'
|
||||
os.environ['OTEL_ENABLED'] = 'true'
|
||||
os.environ['OTEL_SERVICE_NAME'] = 'ivatar-test'
|
||||
os.environ['OTEL_ENVIRONMENT'] = 'test'
|
||||
|
||||
print("Running tests with OpenTelemetry enabled...")
|
||||
print("==========================================")
|
||||
|
||||
# Test modules to run (including OpenTelemetry-specific tests)
|
||||
test_modules = [
|
||||
'ivatar.ivataraccount.test_auth',
|
||||
'ivatar.ivataraccount.test_views',
|
||||
'ivatar.ivataraccount.test_views_bluesky',
|
||||
'ivatar.test_auxiliary',
|
||||
'ivatar.test_file_security',
|
||||
'ivatar.test_opentelemetry',
|
||||
'ivatar.test_static_pages',
|
||||
'ivatar.test_utils',
|
||||
'ivatar.test_views',
|
||||
'ivatar.test_views_stats',
|
||||
'ivatar.tools.test_views',
|
||||
'ivatar.test_wsgi',
|
||||
]
|
||||
|
||||
# Run Django tests
|
||||
cmd = ['python3', 'manage.py', 'test'] + test_modules + ['-v2']
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, check=True)
|
||||
print("")
|
||||
print("Tests completed successfully (OpenTelemetry enabled)")
|
||||
return result.returncode
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Tests failed with exit code {e.returncode}")
|
||||
return e.returncode
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user