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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
// TDD: Bonus Detector Tests
// Tests Bonus Points Detection (+10 maximum)
// All tests should FAIL until BonusDetector is implemented
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod bonus_detector_tests {
use crate::tests::repo_score::test_utils::*;
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_property_tests_detected() {
// ARRANGE
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Create property test indicators
std::fs::create_dir_all(repo_path.join(".github/workflows")).unwrap();
std::fs::write(
repo_path.join(".github/workflows/property-tests.yml"),
"name: Property Tests\non: [push]\njobs:\n test:\n steps:\n - run: cargo test --test proptest",
)
.unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// assert!(bonus.property_tests.detected);
// assert_eq!(bonus.property_tests.points, 3.0);
// assert!(bonus.property_tests.evidence.contains(&".github/workflows/property-tests.yml".to_string()));
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_fuzzing_detected() {
// ARRANGE
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Create fuzzing directory and targets
std::fs::create_dir_all(repo_path.join("fuzz/fuzz_targets")).unwrap();
std::fs::write(
repo_path.join("fuzz/Cargo.toml"),
"[package]\nname = \"fuzz\"\n",
)
.unwrap();
std::fs::write(
repo_path.join("fuzz/fuzz_targets/target1.rs"),
"// Fuzz target\n",
)
.unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// assert!(bonus.fuzzing.detected);
// assert_eq!(bonus.fuzzing.points, 2.0);
// assert!(bonus.fuzzing.evidence.iter().any(|e| e.contains("fuzz")));
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_mutation_testing_detected() {
// ARRANGE
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Create mutants.toml configuration
let mutants_config = r#"
[[mutants]]
name = "main"
path = "src"
[config]
timeout_multiplier = 5.0
"#;
std::fs::write(repo_path.join("mutants.toml"), mutants_config).unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// assert!(bonus.mutation_testing.detected);
// assert_eq!(bonus.mutation_testing.points, 2.0);
// assert!(bonus.mutation_testing.evidence.contains(&"mutants.toml".to_string()));
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_living_docs_detected() {
// ARRANGE
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Create mdBook structure
std::fs::create_dir_all(repo_path.join("docs/book/src")).unwrap();
std::fs::write(
repo_path.join("docs/book/book.toml"),
"[book]\ntitle = \"Test Book\"\n",
)
.unwrap();
std::fs::write(
repo_path.join("docs/book/src/SUMMARY.md"),
"# Summary\n\n- [Chapter 1](./chapter_1.md)\n",
)
.unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// assert!(bonus.living_docs.detected);
// assert_eq!(bonus.living_docs.points, 3.0);
// assert!(bonus.living_docs.evidence.iter().any(|e| e.contains("book.toml")));
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_all_detected_maximum_points() {
// ARRANGE
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Create ALL bonus indicators
// Property tests
std::fs::create_dir_all(repo_path.join(".github/workflows")).unwrap();
std::fs::write(
repo_path.join(".github/workflows/property-tests.yml"),
"name: Property Tests",
)
.unwrap();
// Fuzzing
std::fs::create_dir_all(repo_path.join("fuzz/fuzz_targets")).unwrap();
std::fs::write(repo_path.join("fuzz/Cargo.toml"), "[package]").unwrap();
// Mutation testing
std::fs::write(repo_path.join("mutants.toml"), "[[mutants]]").unwrap();
// Living docs
std::fs::create_dir_all(repo_path.join("docs/book")).unwrap();
std::fs::write(repo_path.join("docs/book/book.toml"), "[book]").unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// All bonuses detected = 10 points total
// assert_eq!(bonus.total(), 10.0);
// assert!(bonus.property_tests.detected);
// assert!(bonus.fuzzing.detected);
// assert!(bonus.mutation_testing.detected);
// assert!(bonus.living_docs.detected);
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_none_detected() {
// ARRANGE
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Minimal repo with no bonus features
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// assert_eq!(bonus.total(), 0.0);
// assert!(!bonus.property_tests.detected);
// assert!(!bonus.fuzzing.detected);
// assert!(!bonus.mutation_testing.detected);
// assert!(!bonus.living_docs.detected);
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_partial_detection() {
// ARRANGE
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Only property tests and living docs
std::fs::create_dir_all(repo_path.join(".github/workflows")).unwrap();
std::fs::write(
repo_path.join(".github/workflows/property-tests.yml"),
"property tests",
)
.unwrap();
std::fs::create_dir_all(repo_path.join("docs/book")).unwrap();
std::fs::write(repo_path.join("docs/book/book.toml"), "[book]").unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// 3 + 3 = 6 points
// assert_eq!(bonus.total(), 6.0);
// assert!(bonus.property_tests.detected);
// assert!(bonus.living_docs.detected);
// assert!(!bonus.fuzzing.detected);
// assert!(!bonus.mutation_testing.detected);
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_cargo_mutants_alternative() {
// Test that cargo-mutants (alternative to mutants.toml) is also detected
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Create .cargo-mutants.toml instead
std::fs::write(
repo_path.join(".cargo-mutants.toml"),
"timeout_multiplier = 5.0",
)
.unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// assert!(bonus.mutation_testing.detected);
// assert_eq!(bonus.mutation_testing.points, 2.0);
panic!("BonusDetector not implemented yet");
}
#[tokio::test]
#[ignore] // RED: Will fail until BonusDetector is implemented
async fn test_bonus_jupyter_book_alternative() {
// Test that Jupyter Book is also recognized as living docs
let temp_dir = create_temp_repo();
let repo_path = temp_dir.path();
init_git_repo(repo_path);
// Create Jupyter Book structure
std::fs::create_dir_all(repo_path.join("docs")).unwrap();
std::fs::write(
repo_path.join("docs/_config.yml"),
"title: Test Book\n",
)
.unwrap();
std::fs::write(
repo_path.join("docs/_toc.yml"),
"format: jb-book\n",
)
.unwrap();
// use crate::services::repo_score::bonus::BonusDetector;
// let detector = BonusDetector::new();
// let bonus = detector.detect_all(repo_path).await.unwrap();
// ASSERT
// assert!(bonus.living_docs.detected);
// assert!(bonus.living_docs.evidence.iter().any(|e| e.contains("_config.yml")));
panic!("BonusDetector not implemented yet");
}
}