Repository navigation
Expand file tree
/
Copy pathrun_all_analyses.py
More file actions
executable file
·123 lines (101 loc) · 3.59 KB
/
Copy pathrun_all_analyses.py
File metadata and controls
executable file
·123 lines (101 loc) · 3.59 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
#!/usr/bin/env python3
"""
Complete Analysis Pipeline Runner
Runs all analysis scripts in sequence:
1. Dataset overview (dataset-data.py)
2. RQ1: Pipeline-level flakiness
3. RQ2: Time series spike detection
4. RQ3: Test case-level distribution
5. RQ4: Flaky type overlap
6. RQ5: Environment-specific patterns
Usage:
python run_all_analyses.py
The script will stop immediately if any analysis fails.
"""
import sys
import os
from pathlib import Path
import subprocess
import time
from datetime import datetime
# Setup paths
REPO_ROOT = Path(__file__).parent.resolve()
SRC_DIR = REPO_ROOT / "src"
# Ensure src is in Python path
sys.path.insert(0, str(SRC_DIR))
os.environ['PYTHONPATH'] = str(SRC_DIR)
# Analysis scripts to run (in order)
ANALYSIS_SCRIPTS = [
("Dataset Overview", "dataset-data"),
("RQ1: Pipeline-level Flakiness", "RQ1"),
("RQ2: Time Series Spike Detection", "RQ2"),
("RQ3: Test Case Distribution", "RQ3"),
("RQ4: Flaky Type Overlap", "RQ4"),
("RQ5: Environment-specific Patterns", "RQ5"),
]
def run_analysis(name, script):
"""Run a single analysis script. Raises exception on failure."""
print(f"\n{'='*80}")
print(f"Running: {name}")
print(f"{'='*80}\n")
start_time = time.time()
# Change to src directory
original_dir = os.getcwd()
os.chdir(SRC_DIR)
try:
# Run using python -m to ensure imports work
subprocess.run(
[sys.executable, "-m", f"analysis.{script}"],
check=True # Raises CalledProcessError on failure
)
elapsed = time.time() - start_time
print(f"\n✓ {name} completed in {elapsed:.1f}s")
return elapsed
finally:
os.chdir(original_dir)
def main():
"""Run all analyses. Stop on first failure."""
print("="*80)
print("FLAKY TESTS IN CI - COMPLETE ANALYSIS PIPELINE")
print("="*80)
print(f"\nRepository: {REPO_ROOT}")
print(f"Started: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print(f"Running {len(ANALYSIS_SCRIPTS)} analysis scripts...\n")
overall_start = time.time()
completed = 0
try:
for name, script in ANALYSIS_SCRIPTS:
run_analysis(name, script)
completed += 1
except subprocess.CalledProcessError as e:
# Analysis failed - stop immediately
overall_elapsed = time.time() - overall_start
print(f"\n{'='*80}")
print("ANALYSIS PIPELINE FAILED")
print(f"{'='*80}")
print(f"Failed at: {name}")
print(f"Completed: {completed}/{len(ANALYSIS_SCRIPTS)} analyses")
print(f"Total time: {overall_elapsed/60:.1f} minutes")
print(f"\nExit code: {e.returncode}")
sys.exit(1)
except KeyboardInterrupt:
overall_elapsed = time.time() - overall_start
print(f"\n{'='*80}")
print("ANALYSIS PIPELINE INTERRUPTED")
print(f"{'='*80}")
print(f"Completed: {completed}/{len(ANALYSIS_SCRIPTS)} analyses")
print(f"Total time: {overall_elapsed/60:.1f} minutes")
sys.exit(130) # Standard exit code for SIGINT
# Success - all analyses completed
overall_elapsed = time.time() - overall_start
print(f"\n{'='*80}")
print("ANALYSIS PIPELINE COMPLETE")
print(f"{'='*80}")
print(f"Completed: {len(ANALYSIS_SCRIPTS)}/{len(ANALYSIS_SCRIPTS)} analyses")
print(f"Total time: {overall_elapsed/60:.1f} minutes")
print(f"Finished: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print(f"\n✓ All analyses completed successfully!")
print(f"\nGenerated figures: {REPO_ROOT / 'generated_figures'}")
sys.exit(0)
if __name__ == "__main__":
main()