From e8b164fc567883e625981f27bda975bc704cda66 Mon Sep 17 00:00:00 2001 From: Dzenan Jupic <56133904+DzenanJupic@users.noreply.github.com> Date: Wed, 9 Jun 2021 05:27:00 +0200 Subject: [PATCH] added logging to tests --- .github/workflows/test.yml | 4 +++- .github/workflows/test_download.yml | 5 +++-- Cargo.toml | 2 ++ tests/download.rs | 8 ++++---- tests/video_attributes.rs | 14 +++++++------- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4ae6607..4953a6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,8 @@ on: env: CARGO_TERM_COLOR: always + RUST_BACKTRACE: full + RUST_LOG: debug jobs: build_and_test: @@ -38,4 +40,4 @@ jobs: toolchain: ${{ matrix.toolchain }} default: true - name: Run tests - run: cargo test --workspace --all-features + run: cargo test --workspace --all-features -- --nocapture diff --git a/.github/workflows/test_download.yml b/.github/workflows/test_download.yml index 08d4d47..ce20f8b 100644 --- a/.github/workflows/test_download.yml +++ b/.github/workflows/test_download.yml @@ -8,6 +8,7 @@ on: env: CARGO_TERM_COLOR: always RUST_BACKTRACE: full + RUST_LOG: debug jobs: build_and_test: @@ -29,6 +30,6 @@ jobs: toolchain: ${{ matrix.toolchain }} default: true - name: Run test `download_to` - run: cargo test -p rustube --all-features --test download download_to -- --exact --ignored + run: cargo test -p rustube --all-features --test download download_to -- --exact --ignored --nocapture - name: Run test `download_age_restricted_to_dir` - run: cargo test -p rustube --all-features --test download download_age_restricted_to_dir -- --exact --ignored + run: cargo test -p rustube --all-features --test download download_age_restricted_to_dir -- --exact --ignored --nocapture diff --git a/Cargo.toml b/Cargo.toml index 9e34e80..dc9310c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,8 @@ url = { version = "2.2.1" } [dev-dependencies] rand = "0.8.1" +test-env-log = "0.2.7" +env_logger = "0.8.3" tokio = { version = "1.0.1", features = ["full"] } tokio-test = "0.4.0" diff --git a/tests/download.rs b/tests/download.rs index a2de431..482d240 100644 --- a/tests/download.rs +++ b/tests/download.rs @@ -8,7 +8,7 @@ use rustube::VideoFetcher; #[macro_use] mod common; -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn download() { let id = random_id(PRE_SIGNED); @@ -24,7 +24,7 @@ async fn download() { correct_path!(path, expected_path); } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn download_age_restricted_to_dir() { let id = random_id(AGE_RESTRICTED); @@ -60,7 +60,7 @@ fn blocking_download_to_dir() { correct_path!(path, expected_path); } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn download_to_dir() { let id = random_id(PRE_SIGNED); @@ -76,7 +76,7 @@ async fn download_to_dir() { correct_path!(path, expected_path); } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn download_to() { let id = random_id(PRE_SIGNED); diff --git a/tests/video_attributes.rs b/tests/video_attributes.rs index 2d17dbf..9c996c9 100644 --- a/tests/video_attributes.rs +++ b/tests/video_attributes.rs @@ -7,7 +7,7 @@ use rustube::video_info::player_response::playability_status::PlayabilityStatus; #[macro_use] mod common; -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn video_has_signature_cipher() { let id = random_id(SIGNATURE_CIPHER); @@ -16,7 +16,7 @@ async fn video_has_signature_cipher() { assert!(random_entry(video.streams()).signature_cipher.s.is_some()); } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn video_is_pre_signed() { let id = random_id(PRE_SIGNED); @@ -25,7 +25,7 @@ async fn video_is_pre_signed() { assert!(random_entry(video.streams()).signature_cipher.s.is_none()); } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn video_is_age_restricted() { let id = random_id(AGE_RESTRICTED); @@ -34,7 +34,7 @@ async fn video_is_age_restricted() { assert!(video.is_age_restricted()); } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn video_is_private_video() { let id = random_id(PRIVATE); @@ -57,7 +57,7 @@ async fn video_is_private_video() { } } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn video_is_region_blocked() { let id = random_id(REGION_BLOCKED); @@ -80,7 +80,7 @@ async fn video_is_region_blocked() { } } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn video_has_missing_recording() { let id = random_id(MISSING_RECORDING); @@ -103,7 +103,7 @@ async fn video_has_missing_recording() { } } -#[tokio::test] +#[test_env_log::test(tokio::test)] #[ignore] async fn video_is_live_stream() { let id = random_id(LIVE_STREAM);