-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-feature-matrix.py
executable file
·60 lines (52 loc) · 1.79 KB
/
test-feature-matrix.py
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
#!/usr/bin/env python3
# Define feature list
import json
import os
import sys
# Load features from Cargo.toml
def load_features():
features = []
with open("gotcha/Cargo.toml", "r") as f:
cargo_toml = f.read()
# Extract features from [features] section
in_features = False
for line in cargo_toml.split('\n'):
if line.startswith('[features]'):
in_features = True
continue
elif line.startswith('['):
in_features = False
elif in_features and '=' in line:
feature = line.split('=')[0].strip()
if feature != 'default':
features.append(feature)
return features
def generate_combinations(features):
n = len(features)
combinations = []
# Generate all combinations
for i in range(1, 1 << n):
combo = []
for j in range(n):
if (i & (1 << j)) != 0:
combo.append(features[j])
combinations.append(" ".join(combo))
return combinations
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "echo":
features = load_features()
combinations = generate_combinations(load_features())
print(f"features={json.dumps(combinations)}")
else:
# Get combinations
combinations = generate_combinations(load_features())
# Print combination matrix
print("Feature Combinations:")
for combo in combinations:
command = f"cargo test --package gotcha --no-default-features --features \"{combo}\""
print(command)
result = os.system(command)
if result != 0:
print(f"Test failed for features: {combo}")
sys.exit(-1)
break