Skip to content

CI: make tarpaulin ignore test code #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,27 @@ jobs:
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin
~/.cargo/bin/cargo-tarpaulin
~/.cargo/git
~/.cargo/registry
target
key: ${{ runner.os }}-cargo-${{ steps.rust-version.outputs.VERSION }}-tarpaulin-${{ steps.tarpaulin-version.outputs.VERSION }} }}

- name: Install Tarpaulin
run: |
ls -lh ~/.cargo || true
ls -lh ~/.cargo/bin || true
cargo install cargo-tarpaulin --version ${{ steps.tarpaulin-version.outputs.VERSION }}
ls -lh ~/.cargo/bin
test -e ~/.cargo/bin/cargo-tarpaulin || cargo install cargo-tarpaulin --version ${{ steps.tarpaulin-version.outputs.VERSION }}

- name: Run Tarpaulin coverage tests
run: |
cargo tarpaulin -v \
--target-dir target/tarpaulin \
--workspace \
--all-features \
--exclude-files 'derive/*' \
--exclude-files 'target/*' \
--ignore-panics --ignore-tests \
--out Html --out Json
--target-dir target/tarpaulin \
--workspace \
--all-features \
--exclude-files 'derive/*' \
--exclude-files 'target/*' \
--ignore-panics --ignore-tests \
--out Html --out Json
env:
RUST_BACKTRACE: 1
RUST_LOG: info
Expand Down
2 changes: 2 additions & 0 deletions influxdb/tests/derive_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fn test_build_query() {
///
/// This integration tests that writing data and retrieving the data again is working
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_derive_simple_write() {
const TEST_NAME: &str = "test_derive_simple_write";

Expand Down Expand Up @@ -73,6 +74,7 @@ async fn test_derive_simple_write() {
#[cfg(feature = "derive")]
#[cfg(feature = "use-serde")]
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_write_and_read_option() {
const TEST_NAME: &str = "test_write_and_read_option";

Expand Down
13 changes: 13 additions & 0 deletions influxdb/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use influxdb::{Client, Error, Query, Timestamp};
///
/// This test case tests whether the InfluxDB server can be connected to and gathers info about it - tested with async_std
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_ping_influx_db_async_std() {
let client = create_client("notusedhere");
let result = client.ping().await;
Expand All @@ -29,6 +30,7 @@ async fn test_ping_influx_db_async_std() {
///
/// This test case tests whether the InfluxDB server can be connected to and gathers info about it * tested with tokio
#[tokio::test]
#[cfg(not(tarpaulin_include))]
async fn test_ping_influx_db_tokio() {
let client = create_client("notusedhere");
let result = client.ping().await;
Expand All @@ -45,6 +47,7 @@ async fn test_ping_influx_db_tokio() {
///
/// This test case tests connection error
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_connection_error() {
let test_name = "test_connection_error";
let client =
Expand All @@ -65,6 +68,7 @@ async fn test_connection_error() {
///
/// This test case tests the Authentication
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_authed_write_and_read() {
const TEST_NAME: &str = "test_authed_write_and_read";

Expand Down Expand Up @@ -112,6 +116,7 @@ async fn test_authed_write_and_read() {
///
/// This test case tests the Authentication
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_wrong_authed_write_and_read() {
const TEST_NAME: &str = "test_wrong_authed_write_and_read";

Expand Down Expand Up @@ -181,6 +186,7 @@ async fn test_wrong_authed_write_and_read() {
///
/// This test case tests the Authentication
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_non_authed_write_and_read() {
const TEST_NAME: &str = "test_non_authed_write_and_read";

Expand Down Expand Up @@ -235,6 +241,7 @@ async fn test_non_authed_write_and_read() {
///
/// This integration tests that writing data and retrieving the data again is working
#[async_std::test]
#[cfg(not(tarpaulin_include))]
async fn test_write_and_read_field() {
const TEST_NAME: &str = "test_write_field";

Expand Down Expand Up @@ -268,6 +275,7 @@ async fn test_write_and_read_field() {
/// This integration tests that writing data and retrieving the data again is working
#[async_std::test]
#[cfg(feature = "use-serde")]
#[cfg(not(tarpaulin_include))]
async fn test_write_and_read_option() {
use serde::Deserialize;

Expand Down Expand Up @@ -329,6 +337,7 @@ async fn test_write_and_read_option() {
/// is equal to the data which was written to the database
#[async_std::test]
#[cfg(feature = "use-serde")]
#[cfg(not(tarpaulin_include))]
async fn test_json_query() {
use serde::Deserialize;

Expand Down Expand Up @@ -380,6 +389,7 @@ async fn test_json_query() {
// deserialize_next_tagged into a tags struct
#[async_std::test]
#[cfg(feature = "use-serde")]
#[cfg(not(tarpaulin_include))]
async fn test_json_query_tagged() {
use serde::Deserialize;

Expand Down Expand Up @@ -444,6 +454,7 @@ async fn test_json_query_tagged() {
/// (tested with tokio)
#[tokio::test]
#[cfg(feature = "use-serde")]
#[cfg(not(tarpaulin_include))]
async fn test_json_query_vec() {
use serde::Deserialize;

Expand Down Expand Up @@ -494,6 +505,7 @@ async fn test_json_query_vec() {
/// This integration test tests whether using the wrong query method fails building the query
#[async_std::test]
#[cfg(feature = "use-serde")]
#[cfg(not(tarpaulin_include))]
async fn test_serde_multi_query() {
use serde::Deserialize;

Expand Down Expand Up @@ -570,6 +582,7 @@ async fn test_serde_multi_query() {
/// This integration test tests whether using the wrong query method fails building the query
#[async_std::test]
#[cfg(feature = "use-serde")]
#[cfg(not(tarpaulin_include))]
async fn test_wrong_query_errors() {
let client = create_client("test_name");
let result = client
Expand Down
6 changes: 6 additions & 0 deletions influxdb/tests/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ use influxdb::{Client, Error, Query};
use std::panic::{AssertUnwindSafe, UnwindSafe};

#[allow(dead_code)]
#[cfg(not(tarpaulin_include))]
pub fn assert_result_err<A: std::fmt::Debug, B: std::fmt::Debug>(result: &Result<A, B>) {
result.as_ref().expect_err("assert_result_err failed");
}

#[cfg(not(tarpaulin_include))]
pub fn assert_result_ok<A: std::fmt::Debug, B: std::fmt::Debug>(result: &Result<A, B>) {
result.as_ref().expect("assert_result_ok failed");
}

#[cfg(not(tarpaulin_include))]
pub fn create_client<T>(db_name: T) -> Client
where
T: Into<String>,
{
Client::new("http://localhost:8086", db_name)
}

#[cfg(not(tarpaulin_include))]
pub async fn create_db<T>(name: T) -> Result<String, Error>
where
T: Into<String>,
Expand All @@ -29,6 +33,7 @@ where
.await
}

#[cfg(not(tarpaulin_include))]
pub async fn delete_db<T>(name: T) -> Result<String, Error>
where
T: Into<String>,
Expand All @@ -40,6 +45,7 @@ where
.await
}

#[cfg(not(tarpaulin_include))]
pub async fn run_test<F, T, Fut1, Fut2>(test_fn: F, teardown: T)
where
F: FnOnce() -> Fut1 + UnwindSafe,
Expand Down