Skip to content

Commit 5ed1347

Browse files
authored
CI: make tarpaulin ignore test code (#79)
* tarpaulin does not recognize async_std::test or tokio::test, so we'll ignore them manually * CI: fix weird caching issue * new attempt at tarpaulin ignoring tests * tarpaulin ist dumm
1 parent f176db5 commit 5ed1347

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

.github/workflows/rust.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,27 @@ jobs:
103103
- uses: actions/cache@v2
104104
with:
105105
path: |
106-
~/.cargo/bin
106+
~/.cargo/bin/cargo-tarpaulin
107107
~/.cargo/git
108108
~/.cargo/registry
109109
target
110110
key: ${{ runner.os }}-cargo-${{ steps.rust-version.outputs.VERSION }}-tarpaulin-${{ steps.tarpaulin-version.outputs.VERSION }} }}
111111

112112
- name: Install Tarpaulin
113113
run: |
114-
ls -lh ~/.cargo || true
115-
ls -lh ~/.cargo/bin || true
116-
cargo install cargo-tarpaulin --version ${{ steps.tarpaulin-version.outputs.VERSION }}
114+
ls -lh ~/.cargo/bin
115+
test -e ~/.cargo/bin/cargo-tarpaulin || cargo install cargo-tarpaulin --version ${{ steps.tarpaulin-version.outputs.VERSION }}
117116
118117
- name: Run Tarpaulin coverage tests
119118
run: |
120119
cargo tarpaulin -v \
121-
--target-dir target/tarpaulin \
122-
--workspace \
123-
--all-features \
124-
--exclude-files 'derive/*' \
125-
--exclude-files 'target/*' \
126-
--ignore-panics --ignore-tests \
127-
--out Html --out Json
120+
--target-dir target/tarpaulin \
121+
--workspace \
122+
--all-features \
123+
--exclude-files 'derive/*' \
124+
--exclude-files 'target/*' \
125+
--ignore-panics --ignore-tests \
126+
--out Html --out Json
128127
env:
129128
RUST_BACKTRACE: 1
130129
RUST_LOG: info

influxdb/tests/derive_integration_tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn test_build_query() {
4444
///
4545
/// This integration tests that writing data and retrieving the data again is working
4646
#[async_std::test]
47+
#[cfg(not(tarpaulin_include))]
4748
async fn test_derive_simple_write() {
4849
const TEST_NAME: &str = "test_derive_simple_write";
4950

@@ -73,6 +74,7 @@ async fn test_derive_simple_write() {
7374
#[cfg(feature = "derive")]
7475
#[cfg(feature = "use-serde")]
7576
#[async_std::test]
77+
#[cfg(not(tarpaulin_include))]
7678
async fn test_write_and_read_option() {
7779
const TEST_NAME: &str = "test_write_and_read_option";
7880

influxdb/tests/integration_tests.rs

+13
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use influxdb::{Client, Error, Query, Timestamp};
1313
///
1414
/// This test case tests whether the InfluxDB server can be connected to and gathers info about it - tested with async_std
1515
#[async_std::test]
16+
#[cfg(not(tarpaulin_include))]
1617
async fn test_ping_influx_db_async_std() {
1718
let client = create_client("notusedhere");
1819
let result = client.ping().await;
@@ -29,6 +30,7 @@ async fn test_ping_influx_db_async_std() {
2930
///
3031
/// This test case tests whether the InfluxDB server can be connected to and gathers info about it * tested with tokio
3132
#[tokio::test]
33+
#[cfg(not(tarpaulin_include))]
3234
async fn test_ping_influx_db_tokio() {
3335
let client = create_client("notusedhere");
3436
let result = client.ping().await;
@@ -45,6 +47,7 @@ async fn test_ping_influx_db_tokio() {
4547
///
4648
/// This test case tests connection error
4749
#[async_std::test]
50+
#[cfg(not(tarpaulin_include))]
4851
async fn test_connection_error() {
4952
let test_name = "test_connection_error";
5053
let client =
@@ -65,6 +68,7 @@ async fn test_connection_error() {
6568
///
6669
/// This test case tests the Authentication
6770
#[async_std::test]
71+
#[cfg(not(tarpaulin_include))]
6872
async fn test_authed_write_and_read() {
6973
const TEST_NAME: &str = "test_authed_write_and_read";
7074

@@ -112,6 +116,7 @@ async fn test_authed_write_and_read() {
112116
///
113117
/// This test case tests the Authentication
114118
#[async_std::test]
119+
#[cfg(not(tarpaulin_include))]
115120
async fn test_wrong_authed_write_and_read() {
116121
const TEST_NAME: &str = "test_wrong_authed_write_and_read";
117122

@@ -181,6 +186,7 @@ async fn test_wrong_authed_write_and_read() {
181186
///
182187
/// This test case tests the Authentication
183188
#[async_std::test]
189+
#[cfg(not(tarpaulin_include))]
184190
async fn test_non_authed_write_and_read() {
185191
const TEST_NAME: &str = "test_non_authed_write_and_read";
186192

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

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

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

@@ -380,6 +389,7 @@ async fn test_json_query() {
380389
// deserialize_next_tagged into a tags struct
381390
#[async_std::test]
382391
#[cfg(feature = "use-serde")]
392+
#[cfg(not(tarpaulin_include))]
383393
async fn test_json_query_tagged() {
384394
use serde::Deserialize;
385395

@@ -444,6 +454,7 @@ async fn test_json_query_tagged() {
444454
/// (tested with tokio)
445455
#[tokio::test]
446456
#[cfg(feature = "use-serde")]
457+
#[cfg(not(tarpaulin_include))]
447458
async fn test_json_query_vec() {
448459
use serde::Deserialize;
449460

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

@@ -570,6 +582,7 @@ async fn test_serde_multi_query() {
570582
/// This integration test tests whether using the wrong query method fails building the query
571583
#[async_std::test]
572584
#[cfg(feature = "use-serde")]
585+
#[cfg(not(tarpaulin_include))]
573586
async fn test_wrong_query_errors() {
574587
let client = create_client("test_name");
575588
let result = client

influxdb/tests/utilities.rs

+6
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ use influxdb::{Client, Error, Query};
33
use std::panic::{AssertUnwindSafe, UnwindSafe};
44

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

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

16+
#[cfg(not(tarpaulin_include))]
1417
pub fn create_client<T>(db_name: T) -> Client
1518
where
1619
T: Into<String>,
1720
{
1821
Client::new("http://localhost:8086", db_name)
1922
}
2023

24+
#[cfg(not(tarpaulin_include))]
2125
pub async fn create_db<T>(name: T) -> Result<String, Error>
2226
where
2327
T: Into<String>,
@@ -29,6 +33,7 @@ where
2933
.await
3034
}
3135

36+
#[cfg(not(tarpaulin_include))]
3237
pub async fn delete_db<T>(name: T) -> Result<String, Error>
3338
where
3439
T: Into<String>,
@@ -40,6 +45,7 @@ where
4045
.await
4146
}
4247

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

0 commit comments

Comments
 (0)