Skip to content

Commit

Permalink
Exclude tests from coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
arnodb committed Nov 8, 2024
1 parent c066980 commit cf43a08
Show file tree
Hide file tree
Showing 25 changed files with 360 additions and 291 deletions.
3 changes: 3 additions & 0 deletions quirky_binder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ syn = { version = "1", features = ["full", "extra-traits"] }
thiserror = "1"
truc = "0.2"
which = "4"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
6 changes: 4 additions & 2 deletions quirky_binder/src/drawing/graph.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::collections::{btree_map::Entry, BTreeMap};

use truc::record::definition::{DatumId, RecordVariantId};

use super::{
Drawing, DrawingColumn, DrawingEdge, DrawingNode, DrawingPort, DrawingPortAlign,
DrawingPortSize, DrawingPortsColumn,
};
use crate::prelude::*;
use std::collections::{btree_map::Entry, BTreeMap};
use truc::record::definition::{DatumId, RecordVariantId};

const COLORS: [&str; 20] = [
"#e6194B", "#3cb44b", "#ffe119", "#4363d8", "#f58231", "#911eb4", "#42d4f4", "#f032e6",
Expand Down
3 changes: 2 additions & 1 deletion quirky_binder/src/drawing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::prelude::*;
use std::collections::BTreeMap;

use crate::prelude::*;

pub mod graph;

#[derive(Debug)]
Expand Down
3 changes: 2 additions & 1 deletion quirky_binder/src/filter/accumulate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::prelude::*;
use truc::record::type_resolver::TypeResolver;

use crate::prelude::*;

#[derive(Getters)]
pub struct Accumulate {
name: FullyQualifiedName,
Expand Down
6 changes: 3 additions & 3 deletions quirky_binder/src/filter/transform/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use proc_macro2::TokenStream;
use serde::Deserialize;
use truc::record::type_resolver::TypeResolver;

use super::{
SubTransform, SubTransformParams, SubTransformSpec, Transform, TransformParams, TransformSpec,
};
use crate::prelude::*;

use super::{SubTransform, SubTransformParams, SubTransformSpec};
use super::{Transform, TransformParams, TransformSpec};

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct TransformStringParams<'a> {
Expand Down
2 changes: 2 additions & 0 deletions quirky_binder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

#[macro_use]
extern crate derive_more;
#[macro_use]
Expand Down
6 changes: 4 additions & 2 deletions quirky_binder/src/stream.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::prelude::*;
use itertools::Itertools;
use std::{
collections::{BTreeMap, BTreeSet},
ops::Deref,
};

use itertools::Itertools;
use truc::record::definition::{DatumId, RecordVariantId};

use crate::prelude::*;

/// Defines the type of records going through a given stream.
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash, Default, Display, Debug, From)]
pub struct StreamRecordType(FullyQualifiedName);
Expand Down
3 changes: 2 additions & 1 deletion quirky_binder/src/support/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ where
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use super::{fields_cmp, fields_cmp_ab, Directed};
use super::*;

#[test]
fn test_fields_cmp_1() {
Expand Down
3 changes: 2 additions & 1 deletion quirky_binder/src/support/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ where
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use super::{fields_eq, fields_eq_ab};
use super::*;

#[test]
fn test_fields_eq_1() {
Expand Down
3 changes: 3 additions & 0 deletions quirky_binder_lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ antinom = { git = "https://github.com/arnodb/antinom.git" }
assert_matches = "1"
rand_chacha = { version = "0.3" }
rstest = "0.18.2"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
2 changes: 2 additions & 0 deletions quirky_binder_lang/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

#[cfg(test)]
#[macro_use]
extern crate assert_matches;
Expand Down
3 changes: 2 additions & 1 deletion quirky_binder_lang/src/parser/crafted_impl/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ pub fn lexer(input: &str) -> Lexer<impl Iterator<Item = Token>> {
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use logos::{Logos, Span};
use rstest::rstest;

use super::Token;
use super::*;

#[rstest]
#[case(r#"'\''"#, vec![(Ok(Token::QuotedChar(r#"'\''"#)), 0..4)])]
Expand Down
1 change: 1 addition & 0 deletions quirky_binder_lang/src/parser/crafted_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ where
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use rstest::rstest;

Expand Down
1 change: 1 addition & 0 deletions quirky_binder_lang/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,5 @@ fn assemble_inputs<'a>(
pub mod fuzzer;

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod fuzz_tests;
1 change: 1 addition & 0 deletions quirky_binder_lang/src/parser/nom_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ where
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use rstest::rstest;

Expand Down
3 changes: 3 additions & 0 deletions quirky_binder_support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ assert_matches = "1"
rand = "0.8"
rand_chacha = { version = "0.3" }
rstest = "0.18.2"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
44 changes: 25 additions & 19 deletions quirky_binder_support/src/data/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,30 @@ impl BufferReader {
}
}

#[test]
fn test_memory() {
let mut buffer = Buffer::with_max_size_in_memory(1024 * 1024);
buffer.push("universe").unwrap();
buffer.push(42).unwrap();
let mut reader = buffer.end_writing().unwrap();
assert_eq!(reader.read::<String>().unwrap(), "universe");
assert_eq!(reader.read::<i32>().unwrap(), 42);
reader.end_reading().unwrap();
}
#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use super::*;

#[test]
fn test_memory() {
let mut buffer = Buffer::with_max_size_in_memory(1024 * 1024);
buffer.push("universe").unwrap();
buffer.push(42).unwrap();
let mut reader = buffer.end_writing().unwrap();
assert_eq!(reader.read::<String>().unwrap(), "universe");
assert_eq!(reader.read::<i32>().unwrap(), 42);
reader.end_reading().unwrap();
}

#[test]
fn test_rolled() {
let mut buffer = Buffer::with_max_size_in_memory(1);
buffer.push("universe").unwrap();
buffer.push(42).unwrap();
let mut reader = buffer.end_writing().unwrap();
assert_eq!(reader.read::<String>().unwrap(), "universe");
assert_eq!(reader.read::<i32>().unwrap(), 42);
reader.end_reading().unwrap();
#[test]
fn test_rolled() {
let mut buffer = Buffer::with_max_size_in_memory(1);
buffer.push("universe").unwrap();
buffer.push(42).unwrap();
let mut reader = buffer.end_writing().unwrap();
assert_eq!(reader.read::<String>().unwrap(), "universe");
assert_eq!(reader.read::<i32>().unwrap(), 42);
reader.end_reading().unwrap();
}
}
64 changes: 35 additions & 29 deletions quirky_binder_support/src/iterator/accumulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,42 @@ impl State {
}
}

#[test]
fn should_accumulate_stream() {
#[derive(Debug)]
enum Error {
Bincode(bincode::Error),
}
#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use super::*;

impl From<bincode::Error> for Error {
fn from(err: bincode::Error) -> Self {
Self::Bincode(err)
#[test]
fn should_accumulate_stream() {
#[derive(Debug)]
enum Error {
Bincode(bincode::Error),
}

impl From<bincode::Error> for Error {
fn from(err: bincode::Error) -> Self {
Self::Bincode(err)
}
}
}

let mut stream = Accumulate::new(fallible_iterator::convert(
[
"ZZZ".to_owned(),
"".to_owned(),
"a".to_owned(),
"z".to_owned(),
"A".to_owned(),
]
.into_iter()
.map(Ok::<_, Error>),
));
assert_matches!(stream.next(), Ok(Some(v)) if v == "ZZZ");
assert_matches!(stream.next(), Ok(Some(v)) if v == "");
assert_matches!(stream.next(), Ok(Some(v)) if v == "a");
assert_matches!(stream.next(), Ok(Some(v)) if v == "z");
assert_matches!(stream.next(), Ok(Some(v)) if v == "A");
// End of stream
assert_matches!(stream.next(), Ok(None));
assert_matches!(stream.next(), Ok(None));
let mut stream = Accumulate::new(fallible_iterator::convert(
[
"ZZZ".to_owned(),
"".to_owned(),
"a".to_owned(),
"z".to_owned(),
"A".to_owned(),
]
.into_iter()
.map(Ok::<_, Error>),
));
assert_matches!(stream.next(), Ok(Some(v)) if v == "ZZZ");
assert_matches!(stream.next(), Ok(Some(v)) if v == "");
assert_matches!(stream.next(), Ok(Some(v)) if v == "a");
assert_matches!(stream.next(), Ok(Some(v)) if v == "z");
assert_matches!(stream.next(), Ok(Some(v)) if v == "A");
// End of stream
assert_matches!(stream.next(), Ok(None));
assert_matches!(stream.next(), Ok(None));
}
}
38 changes: 22 additions & 16 deletions quirky_binder_support/src/iterator/dedup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,26 @@ where
}
}

#[test]
fn should_dedup_stream() {
let mut stream = Dedup::new(
fallible_iterator::convert(
[("a", 12), ("a", 12), ("a", 42), ("b", 42)]
.into_iter()
.map(Ok::<_, ()>),
),
|a, b| (&a.0).eq(&b.0) && a.1.eq(&b.1),
);
assert_matches!(stream.next(), Ok(Some((v, 12))) if v == "a");
assert_matches!(stream.next(), Ok(Some((v, 42))) if v == "a");
assert_matches!(stream.next(), Ok(Some((v, 42))) if v == "b");
// End of stream
assert_matches!(stream.next(), Ok(None));
assert_matches!(stream.next(), Ok(None));
#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use super::*;

#[test]
fn should_dedup_stream() {
let mut stream = Dedup::new(
fallible_iterator::convert(
[("a", 12), ("a", 12), ("a", 42), ("b", 42)]
.into_iter()
.map(Ok::<_, ()>),
),
|a, b| (&a.0).eq(&b.0) && a.1.eq(&b.1),
);
assert_matches!(stream.next(), Ok(Some((v, 12))) if v == "a");
assert_matches!(stream.next(), Ok(Some((v, 42))) if v == "a");
assert_matches!(stream.next(), Ok(Some((v, 42))) if v == "b");
// End of stream
assert_matches!(stream.next(), Ok(None));
assert_matches!(stream.next(), Ok(None));
}
}
Loading

0 comments on commit cf43a08

Please sign in to comment.