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
#![cfg_attr(coverage_nightly, coverage(off))]
//! Distributed mutation testing execution
//!
//! Provides parallel mutant execution with work queue distribution,
//! progress tracking, and result aggregation for production-scale
//! mutation testing workloads.
use super::language::LanguageAdapter;
use super::types::*;
use anyhow::Result;
use parking_lot::RwLock;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use tokio::sync::{mpsc, Semaphore};
/// Distributed mutation executor configuration
#[derive(Debug, Clone)]
pub struct DistributedConfig {
/// Number of parallel workers
pub worker_count: usize,
/// Maximum concurrent executions
pub max_concurrent: usize,
/// Work queue buffer size
pub queue_size: usize,
/// Enable progress tracking
pub track_progress: bool,
}
impl Default for DistributedConfig {
fn default() -> Self {
let cpus = num_cpus::get();
Self {
worker_count: cpus,
max_concurrent: cpus * 2,
queue_size: 1000,
track_progress: true,
}
}
}
/// Progress tracking for mutation execution
#[derive(Debug, Clone)]
pub struct MutationProgress {
/// Total mutants to execute
pub total: usize,
/// Mutants completed
pub completed: usize,
/// Mutants currently executing
pub in_progress: usize,
/// Killed mutants
pub killed: usize,
/// Survived mutants
pub survived: usize,
/// Failed/errored mutants
pub failed: usize,
}
impl MutationProgress {
fn new(total: usize) -> Self {
Self {
total,
completed: 0,
in_progress: 0,
killed: 0,
survived: 0,
failed: 0,
}
}
/// Calculate completion percentage
pub fn percentage(&self) -> f64 {
if self.total == 0 {
return 100.0;
}
(self.completed as f64 / self.total as f64) * 100.0
}
/// Calculate mutation score (killed / total non-equivalent)
pub fn mutation_score(&self) -> f64 {
let total_tested = self.killed + self.survived;
if total_tested == 0 {
return 0.0;
}
(self.killed as f64 / total_tested as f64) * 100.0
}
}
/// Distributed mutation executor
pub struct DistributedExecutor {
/// Language adapter for test execution
adapter: Arc<dyn LanguageAdapter>,
/// Configuration for distributed execution
config: DistributedConfig,
/// Progress tracking for mutation execution
progress: Arc<RwLock<MutationProgress>>,
/// Worker monitoring system
worker_monitor: Option<Arc<super::worker_monitor::WorkerMonitor>>,
}
// Executor construction, parallel execution, worker pool, and mutant execution
include!("distributed_executor.rs");
// Unit tests for DistributedConfig, MutationProgress, and DistributedExecutor
include!("distributed_tests.rs");