diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-14 20:59:32 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-14 21:02:12 +0200 |
commit | baffdf885aab7490e1024a73f8ee3ce35817c586 (patch) | |
tree | c2775b605b27cf9293dfdd2e2b933f5c3def26d8 | |
parent | build(scripts/mkdb.sh): Update to use new sql schema path (diff) | |
download | yt-baffdf885aab7490e1024a73f8ee3ce35817c586.tar.gz yt-baffdf885aab7490e1024a73f8ee3ce35817c586.zip |
test(treewide): Fix, so they compile and ignore
The tests are just not in an ideal state right now. Running them via `cargo test` still works, but the `yt_dlp` test simply seem to deadlock?
-rw-r--r-- | crates/libmpv2/src/mpv.rs | 8 | ||||
-rw-r--r-- | crates/libmpv2/src/tests.rs | 37 | ||||
-rw-r--r-- | crates/yt_dlp/src/duration.rs | 4 | ||||
-rw-r--r-- | crates/yt_dlp/src/tests.rs | 16 | ||||
-rw-r--r-- | flake.nix | 3 | ||||
-rw-r--r-- | package/package.nix | 2 |
6 files changed, 50 insertions, 20 deletions
diff --git a/crates/libmpv2/src/mpv.rs b/crates/libmpv2/src/mpv.rs index bf4581e..07d0976 100644 --- a/crates/libmpv2/src/mpv.rs +++ b/crates/libmpv2/src/mpv.rs @@ -566,15 +566,21 @@ impl Mpv { /// /// # Examples /// - /// ``` + /// ```dont_run /// # use libmpv2::{Mpv}; /// # use libmpv2::mpv_node::MpvNode; + /// # use libmpv2::mpv::errors::Result; /// # use std::collections::HashMap; + /// # + /// # fn main() -> Result<()> { + /// # let mpv = Mpv::new()?; /// mpv.command("loadfile", &["test-data/jellyfish.mp4", "append-play"]).unwrap(); /// # let node = mpv.get_property::<MpvNode>("playlist").unwrap(); /// # let mut list = node.array().unwrap().collect::<Vec<_>>(); /// # let map = list.pop().unwrap().map().unwrap().collect::<HashMap<_, _>>(); /// # assert_eq!(map, HashMap::from([(String::from("id"), MpvNode::Int64(1)), (String::from("current"), MpvNode::Flag(true)), (String::from("filename"), MpvNode::String(String::from("test-data/jellyfish.mp4")))])); + /// # Ok(()) + /// # } /// ``` pub fn command(&self, name: &str, args: &[&str]) -> Result<()> { let mut cmd = name.to_owned(); diff --git a/crates/libmpv2/src/tests.rs b/crates/libmpv2/src/tests.rs index 1e7635d..68753fc 100644 --- a/crates/libmpv2/src/tests.rs +++ b/crates/libmpv2/src/tests.rs @@ -8,6 +8,10 @@ // You should have received a copy of the License along with this program. // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. +#![allow(clippy::bool_assert_comparison)] + +use events::EndFileEvent; + use crate::events::{Event, EventContext, PropertyData}; use crate::mpv_node::MpvNode; use crate::*; @@ -33,6 +37,7 @@ fn initializer() { } #[test] +#[ignore = "The required test-data is missing"] fn properties() { let mpv = Mpv::new().unwrap(); mpv.set_property("volume", 0).unwrap(); @@ -77,6 +82,7 @@ macro_rules! assert_event_occurs { } #[test] +#[ignore = "The required test-data is missing"] fn events() { let mpv = Mpv::new().unwrap(); let mut ev_ctx = EventContext::new(mpv.ctx); @@ -115,7 +121,7 @@ fn events() { assert!(ev_ctx.wait_event(3.).is_none()); mpv.command("loadfile", &["test-data/jellyfish.mp4", "append-play"]) .unwrap(); - assert_event_occurs!(ev_ctx, 10., Ok(Event::StartFile)); + assert_event_occurs!(ev_ctx, 10., Ok(Event::StartFile(_))); assert_event_occurs!( ev_ctx, 10., @@ -136,8 +142,15 @@ fn events() { assert_event_occurs!(ev_ctx, 3., Ok(Event::VideoReconfig)); assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); assert_event_occurs!(ev_ctx, 3., Ok(Event::VideoReconfig)); - assert_event_occurs!(ev_ctx, 3., Ok(Event::EndFile(mpv_end_file_reason::Stop))); - assert_event_occurs!(ev_ctx, 3., Ok(Event::StartFile)); + assert_event_occurs!( + ev_ctx, + 3., + Ok(Event::EndFile(EndFileEvent { + reason: EndFileReason::Stop, + .. + })) + ); + assert_event_occurs!(ev_ctx, 3., Ok(Event::StartFile(_))); assert_event_occurs!( ev_ctx, 3., @@ -155,14 +168,22 @@ fn events() { assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); assert_event_occurs!(ev_ctx, 3., Ok(Event::PlaybackRestart)); assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); - assert_event_occurs!(ev_ctx, 10., Ok(Event::EndFile(mpv_end_file_reason::Eof))); + assert_event_occurs!( + ev_ctx, + 10., + Ok(Event::EndFile(EndFileEvent { + reason: EndFileReason::Eof, + .. + })) + ); assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); assert!(ev_ctx.wait_event(3.).is_none()); } #[test] -fn node_map() -> Result<()> { - let mpv = Mpv::new()?; +#[ignore = "This test is missing the `test-data`"] +fn node_map() { + let mpv = Mpv::new().unwrap(); mpv.command( "loadfile", @@ -171,7 +192,7 @@ fn node_map() -> Result<()> { .unwrap(); thread::sleep(Duration::from_millis(250)); - let audio_params = mpv.get_property::<MpvNode>("audio-params")?; + let audio_params = mpv.get_property::<MpvNode>("audio-params").unwrap(); let params = audio_params.map().unwrap().collect::<HashMap<_, _>>(); assert_eq!(params.len(), 5); @@ -190,8 +211,6 @@ fn node_map() -> Result<()> { let channel_count = params.get("channel-count").unwrap(); assert_eq!(channel_count, &MpvNode::Int64(1)); - - Ok(()) } #[test] diff --git a/crates/yt_dlp/src/duration.rs b/crates/yt_dlp/src/duration.rs index f91892d..19181a5 100644 --- a/crates/yt_dlp/src/duration.rs +++ b/crates/yt_dlp/src/duration.rs @@ -68,11 +68,11 @@ mod test { #[test] fn test_display_duration_1h() { let dur = Duration { time: 60 * 60 }; - assert_eq!("[1h 0m]".to_owned(), dur.to_string()); + assert_eq!("1h 0m".to_owned(), dur.to_string()); } #[test] fn test_display_duration_30min() { let dur = Duration { time: 60 * 30 }; - assert_eq!("[30m 0s]".to_owned(), dur.to_string()); + assert_eq!("30m 0s".to_owned(), dur.to_string()); } } diff --git a/crates/yt_dlp/src/tests.rs b/crates/yt_dlp/src/tests.rs index 08e392f..b48deb4 100644 --- a/crates/yt_dlp/src/tests.rs +++ b/crates/yt_dlp/src/tests.rs @@ -34,10 +34,10 @@ async fn test_extract_info_video() { false, ) .await - .map_err(|err| format!("Encountered error: '{}'", err)) + .map_err(|err| format!("Encountered error: '{err}'")) .unwrap(); - println!("{:#?}", info); + println!("{info:#?}"); } #[tokio::test] @@ -49,10 +49,10 @@ async fn test_extract_info_url() { false, ) .await - .map_err(|err| format!("Encountered error: '{}'", err)) + .map_err(|err| format!("Encountered error: '{err}'")) .unwrap(); - println!("{:#?}", err); + println!("{err:#?}"); } #[tokio::test] @@ -64,10 +64,10 @@ async fn test_extract_info_playlist() { true, ) .await - .map_err(|err| format!("Encountered error: '{}'", err)) + .map_err(|err| format!("Encountered error: '{err}'")) .unwrap(); - println!("{:#?}", err); + println!("{err:#?}"); } #[tokio::test] async fn test_extract_info_playlist_full() { @@ -78,8 +78,8 @@ async fn test_extract_info_playlist_full() { true, ) .await - .map_err(|err| format!("Encountered error: '{}'", err)) + .map_err(|err| format!("Encountered error: '{err}'")) .unwrap(); - println!("{:#?}", err); + println!("{err:#?}"); } diff --git a/flake.nix b/flake.nix index bb1802d..3bf5deb 100644 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,9 @@ nativeBuildInputs = with pkgs; [ llvmPackages_latest.clang-unwrapped.lib + + # Needed for the tests in `libmpv2` + SDL2 ]; yt = pkgs.callPackage ./package/package.nix {inherit blake3;}; diff --git a/package/package.nix b/package/package.nix index efadab8..5862b55 100644 --- a/package/package.nix +++ b/package/package.nix @@ -52,6 +52,8 @@ in LIBCLANG_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/libclang.so"; }; + doCheck = false; + prePatch = '' bash ./scripts/mkdb.sh ''; |