-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
168 lines (139 loc) Β· 6.86 KB
/
run_tests.py
File metadata and controls
168 lines (139 loc) Β· 6.86 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env python3
"""
Test runner for MDF Zipper test suite.
This script provides convenient ways to run different categories of tests.
"""
import sys
import subprocess
import argparse
from pathlib import Path
def run_command(cmd, description):
"""Run a command and handle the result."""
print(f"\nπ {description}")
print("=" * 60)
try:
result = subprocess.run(cmd, shell=True, check=True, text=True,
capture_output=False)
print(f"β
{description} completed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"β {description} failed with exit code {e.returncode}")
return False
def main():
parser = argparse.ArgumentParser(
description="Run MDF Zipper tests with various options",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
%(prog)s --all # Run all tests
%(prog)s --critical-safety # Run critical safety tests for high-value datasets (RECOMMENDED)
%(prog)s --integrity # Run only data integrity tests
%(prog)s --stress # Run stress tests
%(prog)s --unix-linux # Run UNIX/Linux specific tests
%(prog)s --quick # Run quick tests (exclude slow ones)
%(prog)s --coverage # Run with coverage report
%(prog)s --parallel # Run tests in parallel
"""
)
parser.add_argument('--all', action='store_true',
help='Run all tests')
parser.add_argument('--critical-safety', action='store_true',
help='Run critical safety tests for high-value datasets (RECOMMENDED)')
parser.add_argument('--integrity', action='store_true',
help='Run only data integrity tests')
parser.add_argument('--stress', action='store_true',
help='Run stress tests')
parser.add_argument('--edge-cases', action='store_true',
help='Run edge case tests')
parser.add_argument('--performance', action='store_true',
help='Run performance tests')
parser.add_argument('--unix-linux', action='store_true',
help='Run UNIX/Linux platform-specific tests')
parser.add_argument('--quick', action='store_true',
help='Run quick tests (exclude slow ones)')
parser.add_argument('--coverage', action='store_true',
help='Run with coverage report')
parser.add_argument('--parallel', action='store_true',
help='Run tests in parallel')
parser.add_argument('--verbose', '-v', action='store_true',
help='Verbose output')
args = parser.parse_args()
if not any([args.all, args.critical_safety, args.integrity, args.stress,
args.edge_cases, args.performance, args.unix_linux, args.quick]):
# Default to running critical safety tests (most important for high-value datasets)
args.critical_safety = True
# Build pytest command
cmd_parts = ['python', '-m', 'pytest']
# Add verbosity
if args.verbose:
cmd_parts.append('-vv')
# Add coverage if requested
if args.coverage:
cmd_parts.extend(['--cov=mdf_zipper', '--cov-report=html', '--cov-report=term'])
# Add parallel execution if requested
if args.parallel:
cmd_parts.extend(['-n', 'auto'])
success = True
if args.all:
cmd = ' '.join(cmd_parts + ['.'])
success &= run_command(cmd, "Running all tests")
if args.critical_safety:
cmd = ' '.join(cmd_parts + ['test_critical_safety.py', '-v'])
success &= run_command(cmd, "Running CRITICAL SAFETY tests for high-value datasets")
if args.integrity:
cmd = ' '.join(cmd_parts + ['test_mdf_zipper.py::TestDataIntegrity', '-v'])
success &= run_command(cmd, "Running data integrity tests")
if args.stress:
cmd = ' '.join(cmd_parts + ['test_stress_and_edge_cases.py::TestStressScenarios', '-v'])
success &= run_command(cmd, "Running stress tests")
if args.edge_cases:
cmd = ' '.join(cmd_parts + ['test_stress_and_edge_cases.py::TestEdgeCases', '-v'])
success &= run_command(cmd, "Running edge case tests")
if args.performance:
cmd = ' '.join(cmd_parts + ['test_mdf_zipper.py::TestPerformance', '-v'])
success &= run_command(cmd, "Running performance tests")
if args.unix_linux:
if sys.platform == "win32":
print("\nβ οΈ UNIX/Linux specific tests skipped on Windows platform")
else:
cmd = ' '.join(cmd_parts + ['test_unix_linux_specific.py', '-v'])
success &= run_command(cmd, "Running UNIX/Linux platform-specific tests")
if args.quick:
cmd = ' '.join(cmd_parts + ['-m', '"not slow"', '.'])
success &= run_command(cmd, "Running quick tests")
print("\n" + "=" * 60)
if success:
print("π All requested tests completed successfully!")
print("\nπ‘ Test Summary:")
print(" β
Data integrity verified")
print(" β
Original files never modified")
print(" β
Original files never moved")
print(" β
Archives created correctly")
print(" β
All safety checks passed")
if args.critical_safety:
print("\nπ CRITICAL SAFETY VERIFICATION:")
print(" β
No data movement or corruption under ANY circumstances")
print(" β
Atomic archive creation")
print(" β
Power failure protection")
print(" β
Memory exhaustion protection")
print(" β
Storage device failure protection")
print(" β
ZIP corruption detection")
print(" β
High-value dataset protection validated")
if args.unix_linux and sys.platform != "win32":
print("\nπ§ UNIX/LINUX PLATFORM VERIFICATION:")
print(" β
File permission handling")
print(" β
Special file types (FIFOs, device files, hard links)")
print(" β
Signal handling (SIGTERM, SIGHUP)")
print(" β
Filesystem features (case sensitivity, extended attributes)")
print(" β
Network filesystem simulation")
print(" β
Resource limits and constraints")
print(" β
UNIX-specific edge cases")
else:
print("β Some tests failed. Please review the output above.")
if args.critical_safety:
print("\nβ οΈ CRITICAL: Safety tests failed - DO NOT USE on high-value datasets until issues are resolved!")
if args.unix_linux:
print("\nβ οΈ WARNING: Platform-specific tests failed - Review UNIX/Linux compatibility!")
sys.exit(1)
if __name__ == "__main__":
main()