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
/*
* Mitts Build — Rust-first build and package tooling with shared artifact cache
* Copyright (c) 2026 Alexander Panasenko
*
* Contact: alex@prod.codes
* Author: https://prod.codes/about/
* Project: https://github.com/alex09x/mitts
* SPDX-License-Identifier: MIT OR Apache-2.0
*/
use clap::Args;
use std::path::PathBuf;
#[derive(Args, Debug, Clone, Default)]
pub struct CoverageArgs {
/// Path to Cargo.toml
#[arg(long)]
pub manifest_path: Option<PathBuf>,
/// Limit concurrent native build units (same as MITTS_JOBS; the flag wins)
#[arg(short = 'j', long, value_name = "N", value_parser = clap::value_parser!(u64).range(1..))]
pub jobs: Option<u64>,
/// Package to measure coverage for
#[arg(skip)]
pub package: Option<String>,
/// Packages to measure (repeat for multiple packages)
#[arg(short = 'p', long = "package", action = clap::ArgAction::Append)]
pub packages: Vec<String>,
/// Build and run tests in release mode
#[arg(short, long)]
pub release: bool,
/// Only print high-level coverage summary table
#[arg(long)]
pub summary_only: bool,
/// Generate HTML coverage report
#[arg(long)]
pub html: bool,
/// Generate LCOV coverage report (lcov.info)
#[arg(long)]
pub lcov: bool,
/// Generate JSON coverage report
#[arg(long)]
pub json: bool,
/// Generate plain text coverage report
#[arg(long)]
pub text: bool,
/// Output directory for HTML or LCOV reports
#[arg(long)]
pub output_dir: Option<PathBuf>,
/// Write a JSON, LCOV or text report to this file instead of stdout (or lcov.info)
#[arg(long, value_name = "FILE")]
pub output_path: Option<PathBuf>,
/// Automatically open the generated HTML report
#[arg(long)]
pub open: bool,
/// Minimum line coverage percentage (fails if below threshold)
#[arg(long)]
pub fail_under_lines: Option<f64>,
/// Exclude matching source filenames from reports and the coverage threshold
#[arg(long)]
pub ignore_filename_regex: Option<String>,
/// Filter tests by name or substring
#[arg(value_name = "TESTNAME")]
pub filter: Option<String>,
/// Build all targets in the workspace
#[arg(long, visible_alias = "all")]
pub workspace: bool,
/// Exclude packages from being tested
#[arg(long, value_name = "SPEC", action = clap::ArgAction::Append)]
pub exclude: Vec<String>,
/// Build all targets (bins, tests, benches)
#[arg(long)]
pub all_targets: bool,
/// Directory for all generated artifacts
#[arg(long)]
pub target_dir: Option<PathBuf>,
/// Space or comma separated list of features to activate
#[arg(short = 'F', long, value_delimiter = ',', num_args = 1..)]
pub features: Vec<String>,
/// Do not activate the `default` feature
#[arg(long)]
pub no_default_features: bool,
/// Activate all available features
#[arg(long)]
pub all_features: bool,
/// Do not read from or write to the shared action cache
#[arg(long)]
pub no_cache: bool,
/// Directory for the shared artifact and action cache
#[arg(long)]
pub cache_dir: Option<PathBuf>,
/// Select target triple for cross-compilation
#[arg(long)]
pub target: Option<String>,
/// Require an existing compatible Cargo.lock; do not resolve or write one.
#[arg(long)]
pub locked: bool,
/// Do not use the network to resolve dependencies; use only local sources.
#[arg(long)]
pub offline: bool,
/// Require a compatible Cargo.lock and use only locally available sources.
#[arg(long)]
pub frozen: bool,
/// Compile, but don't run tests or collect profiles
#[arg(long)]
pub no_run: bool,
/// Run all tests regardless of failure (default is fail-fast)
#[arg(long)]
pub no_fail_fast: bool,
/// Test the named integration target (repeatable; combines with --bin)
#[arg(long = "test", action = clap::ArgAction::Append)]
pub test: Vec<String>,
/// Test all integration test targets
#[arg(long)]
pub tests: bool,
/// Test the named binary target (repeatable; combines with --test)
#[arg(long = "bin", action = clap::ArgAction::Append)]
pub bin: Vec<String>,
/// Test all binary targets
#[arg(long)]
pub bins: bool,
/// Test only this package's library unit tests
#[arg(long)]
pub lib: bool,
/// Test only this package's library documentation
#[arg(long)]
pub doc: bool,
/// Run tests without capturing output (equivalent to -- --nocapture)
#[arg(long)]
pub nocapture: bool,
/// Require exact test-name matches; pass before `--`, with filters after it
#[arg(long)]
pub exact: bool,
/// Run only ignored tests (equivalent to -- --ignored)
#[arg(long)]
pub ignored: bool,
/// Run every test in its own process, many at a time, as `mitts test -c` does
///
/// Without a number the pool is all the cores; `-c=N` runs N processes at once.
/// Each process writes its own profile file, so the report is the same as for a serial run.
#[arg(short = 'c', long, value_name = "N", num_args = 0..=1, require_equals = true, default_missing_value = "0")]
pub concurrency: Option<usize>,
/// Use verbose output
#[arg(short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
/// Override a configuration value (not yet supported)
#[arg(long, action = clap::ArgAction::Append)]
pub config: Vec<String>,
/// Arguments passed to test binaries after `--` (for example, test-name filters)
#[arg(last = true)]
pub test_args: Vec<String>,
}
impl CoverageArgs {
/// True when stdout carries only the JSON report, so a consumer can parse it: no banner,
/// stage lines or output of the instrumented tests may reach it (they go to stderr).
pub fn json_report_on_stdout(&self) -> bool {
self.json && !self.html && !self.lcov && self.output_path.is_none()
}
}