Skip to content

Commit 3406457

Browse files
committed
Make code coverage more accurate
1 parent 12c4b52 commit 3406457

13 files changed

+19
-3
lines changed

.github/workflows/validate.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
rustup override set ${RUST_MSRV}-x86_64-unknown-linux-gnu
5252
cargo build --locked
5353
tests:
54-
name: Run tests on MSRV
54+
name: Run tests on nightly
5555
runs-on: ubuntu-latest
5656
env:
5757
CARGO_LLVM_COV_VERSION: 0.6.16
@@ -67,8 +67,8 @@ jobs:
6767
tar -xvzf /tmp/cargo-llvm-cov.tar.gz -C ${HOME}/.cargo/bin
6868
- name: Test
6969
run: |
70-
rustup toolchain install ${RUST_MSRV}-x86_64-unknown-linux-gnu
71-
rustup override set ${RUST_MSRV}-x86_64-unknown-linux-gnu
70+
rustup toolchain install nightly-x86_64-unknown-linux-gnu
71+
rustup override set nightly-x86_64-unknown-linux-gnu
7272
cargo llvm-cov --verbose --codecov --locked --output-path codecov.json
7373
- name: Upload coverage reports to Codecov
7474
uses: codecov/codecov-action@v5

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ regex = "1.11.1"
6868
tokio-tungstenite = "0.26.2"
6969
tower = "0.5.2"
7070
vt100-ctt = "0.16.0"
71+
72+
[lints.rust]
73+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }

src/addressing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ impl<R: Resolver> AddressDelegator<R> {
363363
}
364364

365365
#[cfg(test)]
366+
#[cfg_attr(coverage_nightly, coverage(off))]
366367
mod address_delegator_tests {
367368
use std::{collections::HashSet, net::SocketAddr};
368369

src/certificates.rs

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ impl ResolvesServerCert for CertificateResolver {
227227
}
228228

229229
#[cfg(test)]
230+
#[cfg_attr(coverage_nightly, coverage(off))]
230231
mod certificate_resolver_tests {
231232
use std::sync::{Arc, RwLock};
232233

src/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ fn validate_txt_record_prefix(value: &str) -> Result<String, String> {
326326
}
327327

328328
#[cfg(test)]
329+
#[cfg_attr(coverage_nightly, coverage(off))]
329330
mod application_config_tests {
330331
use std::str::FromStr;
331332

src/connections.rs

+1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ impl ConnectionGetByHttpHost<Arc<SshTunnelHandler>> for Arc<HttpAliasingConnecti
264264
}
265265
}
266266

267+
#[cfg_attr(coverage_nightly, coverage(off))]
267268
#[cfg(test)]
268269
mod connection_map_tests {
269270
use std::sync::Arc;

src/fingerprints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ impl FingerprintsValidator {
241241
}
242242

243243
#[cfg(test)]
244+
#[cfg_attr(coverage_nightly, coverage(off))]
244245
mod fingerprints_validator_tests {
245246
use russh::keys::{parse_public_key_base64, HashAlg};
246247

src/http.rs

+1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ where
388388
}
389389

390390
#[cfg(test)]
391+
#[cfg_attr(coverage_nightly, coverage(off))]
391392
mod proxy_handler_tests {
392393
use bytes::Bytes;
393394
use futures_util::{SinkExt, StreamExt};

src/ip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl IpFilter {
6666
}
6767

6868
#[cfg(test)]
69+
#[cfg_attr(coverage_nightly, coverage(off))]
6970
mod ip_filter_tests {
7071
use std::{net::IpAddr, str::FromStr};
7172

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
2+
13
//!
24
#![doc = include_str!("../README.md")]
35
//!

src/login.rs

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ impl<C: Configurer> ApiLogin<C> {
195195
}
196196

197197
#[cfg(test)]
198+
#[cfg_attr(coverage_nightly, coverage(off))]
198199
mod api_login_tests {
199200
use std::{
200201
net::{IpAddr, Ipv4Addr, SocketAddr},

src/quota.rs

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl QuotaHandler for Arc<QuotaMap> {
129129
}
130130

131131
#[cfg(test)]
132+
#[cfg_attr(coverage_nightly, coverage(off))]
132133
mod quota_map_tests {
133134
use std::sync::Arc;
134135

src/telemetry.rs

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ impl Counter {
8888
}
8989

9090
#[cfg(test)]
91+
#[cfg_attr(coverage_nightly, coverage(off))]
9192
mod counter_tests {
9293
use std::{thread::sleep, time::Duration};
9394

@@ -245,6 +246,7 @@ impl Telemetry {
245246
}
246247

247248
#[cfg(test)]
249+
#[cfg_attr(coverage_nightly, coverage(off))]
248250
mod telemetry_tests {
249251
use std::sync::Arc;
250252

0 commit comments

Comments
 (0)