Skip to content

Commit

Permalink
CI: fully migrate to -C instrument-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
elinorbgr authored and vberger committed Mar 22, 2022
1 parent 889fa5c commit 2c40aec
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 32 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ on:

jobs:
ci-linux:
name: CI (Linux)
name: CI

strategy:
fail-fast: false
matrix:
rust: ['1.49.0', 'stable', 'beta']
rust: ['1.53.0', 'stable', 'beta']

runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'

steps:
- name: Checkout sources
Expand All @@ -33,20 +33,21 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

- name: Coverage
uses: actions-rs/[email protected]
with:
args: --ignore-tests --all-features --exclude-files "doc/*"

- name: Upload to codecov.io
uses: codecov/codecov-action@v2
- name: Run tests
uses: actions-rs/cargo@v1
with:
files: ./cobertura.xml
command: test
args: --all-features

ci-macos:
name: CI (macOS)
name: Coverage

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']

runs-on: macos-latest
runs-on: ${{ matrix.os }}

steps:
- name: Checkout sources
Expand All @@ -56,7 +57,7 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.cargo
key: cargo-nightly
key: cargo-nightly-${{ matrix.os }}

- name: Rust toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -78,15 +79,16 @@ jobs:
args: --all-features
env:
LLVM_PROFILE_FILE: "calloop-%p-%m.profraw"
RUSTFLAGS: "-Zinstrument-coverage"
RUSTFLAGS: "-Cinstrument-coverage --cfg coverage"

- name: Coverage
run: grcov . --binary-path ./target/debug -s . -t lcov --branch --llvm --ignore-not-existing --keep-only "src/sys/*" --excl-br-start "mod tests \{" --excl-start "mod tests \{" --excl-br-line "#\[derive\(" --excl-line "#\[derive\(" -o lcov.info
run: grcov . --binary-path ./target/debug -s . -t lcov --branch --llvm --ignore-not-existing --ignore 'examples/*' --ignore 'tests/*' --ignore '*/.cargo/registry/*' --excl-br-start "mod tests \{" --excl-start "mod tests \{" --excl-br-line "#\[derive\(" --excl-line "#\[derive\(" -o lcov.info

- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
files: ./lcov.info
flags: ${{ matrix.os }}

lint:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ pub struct InsertError<T> {
pub error: Error,
}

#[cfg(not(tarpaulin_include))]
impl<T> Debug for InsertError<T> {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, formatter: &mut Formatter) -> core::result::Result<(), fmt::Error> {
write!(formatter, "{:?}", self.error)
}
}

#[cfg(not(tarpaulin_include))]
impl<T> From<InsertError<T>> for crate::Error {
/// Converts the [`InsertError`] into Calloop's error type, throwing away
/// the contained source.
#[cfg_attr(coverage, no_coverage)]
fn from(e: InsertError<T>) -> crate::Error {
e.error
}
Expand Down
2 changes: 1 addition & 1 deletion src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub struct Async<'l, F: AsRawFd> {
old_flags: OFlag,
}

#[cfg(not(tarpaulin_include))]
impl<'l, F: AsRawFd + std::fmt::Debug> std::fmt::Debug for Async<'l, F> {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Async").field("fd", &self.fd).finish()
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
#![warn(missing_docs, missing_debug_implementations)]
#![allow(clippy::needless_doctest_main)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(coverage, feature(no_coverage))]

mod sys;

Expand Down
8 changes: 4 additions & 4 deletions src/loop_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ pub struct LoopHandle<'l, Data> {
inner: Rc<LoopInner<'l, Data>>,
}

#[cfg(not(tarpaulin_include))]
impl<'l, Data> std::fmt::Debug for LoopHandle<'l, Data> {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("LoopHandle { ... }")
}
}

#[cfg(not(tarpaulin_include))]
impl<'l, Data> Clone for LoopHandle<'l, Data> {
#[cfg_attr(coverage, no_coverage)]
fn clone(&self) -> Self {
LoopHandle {
inner: self.inner.clone(),
Expand Down Expand Up @@ -208,8 +208,8 @@ pub struct EventLoop<'l, Data> {
ping: crate::sources::ping::Ping,
}

#[cfg(not(tarpaulin_include))]
impl<'l, Data> std::fmt::Debug for EventLoop<'l, Data> {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("EventLoop { ... }")
}
Expand Down Expand Up @@ -433,8 +433,8 @@ pub struct LoopSignal {
ping: crate::sources::ping::Ping,
}

#[cfg(not(tarpaulin_include))]
impl std::fmt::Debug for LoopSignal {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("LoopSignal { ... }")
}
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ macro_rules! batch_unregister {
}

#[cfg(test)]
mod test {
mod tests {
use std::time::Duration;

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions src/sources/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub struct Sender<T> {
ping: Ping,
}

#[cfg(not(tarpaulin_include))]
impl<T> Clone for Sender<T> {
#[cfg_attr(coverage, no_coverage)]
fn clone(&self) -> Sender<T> {
Sender {
sender: self.sender.clone(),
Expand Down Expand Up @@ -71,8 +71,8 @@ pub struct SyncSender<T> {
ping: Ping,
}

#[cfg(not(tarpaulin_include))]
impl<T> Clone for SyncSender<T> {
#[cfg_attr(coverage, no_coverage)]
fn clone(&self) -> SyncSender<T> {
SyncSender {
sender: self.sender.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/sources/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ where
}

#[cfg(test)]
mod test {
mod tests {
use std::io::{Read, Write};

use super::Generic;
Expand Down
6 changes: 3 additions & 3 deletions src/sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ where
/// Use `into_source_inner` to get the event source back.
pub struct Dispatcher<'a, S, Data>(Rc<dyn ErasedDispatcher<'a, S, Data> + 'a>);

#[cfg(not(tarpaulin_include))]
impl<'a, S, Data> std::fmt::Debug for Dispatcher<'a, S, Data> {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Dispatcher { ... }")
}
Expand Down Expand Up @@ -484,8 +484,8 @@ pub struct Idle<'i> {
pub(crate) callback: Rc<RefCell<dyn CancellableIdle + 'i>>,
}

#[cfg(not(tarpaulin_include))]
impl<'i> std::fmt::Debug for Idle<'i> {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Idle { ... }")
}
Expand Down Expand Up @@ -524,7 +524,7 @@ where
}

#[cfg(test)]
mod test {
mod tests {
use std::time::Duration;

use crate::{ping::make_ping, EventLoop};
Expand Down
2 changes: 1 addition & 1 deletion src/sources/timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ pub struct TimerHandle<T> {
}

// Manual impl of `Clone` as #[derive(Clone)] adds a `T: Clone` bound
#[cfg(not(tarpaulin_include))]
impl<T> Clone for TimerHandle<T> {
#[cfg_attr(coverage, no_coverage)]
fn clone(&self) -> TimerHandle<T> {
TimerHandle {
inner: self.inner.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/sources/transient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<T: crate::EventSource> crate::EventSource for TransientSource<T> {
}

#[cfg(test)]
mod test {
mod tests {
use super::*;
use crate::{
channel::{channel, Event},
Expand Down
1 change: 1 addition & 0 deletions src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pub struct Poll {
}

impl std::fmt::Debug for Poll {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Poll { ... }")
}
Expand Down

0 comments on commit 2c40aec

Please sign in to comment.