From e9e48fbf4003d4ff7672b66bd4427d9488c34792 Mon Sep 17 00:00:00 2001 From: Ali Somay Date: Sun, 17 Apr 2022 11:58:05 +0200 Subject: [PATCH] Use our own fork of libpd until the bug-fix merges --- .gitignore | 1 + src/convenience.rs | 2 + tests/general.rs | 70 +++++++++++----------- tests/gui.rs | 1 + tests/send_and_receive_after_touch.rs | 1 - tests/send_and_receive_bang.rs | 13 ++-- tests/send_and_receive_control_change.rs | 1 + tests/send_and_receive_double.rs | 1 + tests/send_and_receive_float.rs | 11 ++-- tests/send_and_receive_list.rs | 1 + tests/send_and_receive_midi_byte.rs | 1 + tests/send_and_receive_note_on.rs | 1 + tests/send_and_receive_pitch_bend.rs | 1 + tests/send_and_receive_poly_after_touch.rs | 1 + tests/send_and_receive_program_change.rs | 1 + tests/send_and_receive_sys_realtime.rs | 1 + tests/send_and_receive_sysex.rs | 1 + tests/send_and_receive_typed_message.rs | 1 + 18 files changed, 59 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index c640ca5..5dbd99a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target Cargo.lock .vscode +src/main.rs diff --git a/src/convenience.rs b/src/convenience.rs index 4dff2f4..e808987 100644 --- a/src/convenience.rs +++ b/src/convenience.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use crate::error::{InitializationError, LibpdError}; use crate::send::{ add_float_to_started_message, finish_message_as_typed_message_and_send_to, start_message, diff --git a/tests/general.rs b/tests/general.rs index 9ae16e2..338bece 100644 --- a/tests/general.rs +++ b/tests/general.rs @@ -8,57 +8,57 @@ use libpd_rs::{ #[test] fn all_main_functionality() { - let x = init(); - assert!(x.is_ok()); - let x = init(); - assert!(x.is_err()); + let result = init(); + assert!(result.is_ok()); + let result = init(); + assert!(result.is_err()); - let x = initialize_audio(0, 2, 44100); - assert!(x.is_ok()); - let x = initialize_audio(0, 1, 44100); - assert!(x.is_ok()); + let result = initialize_audio(0, 2, 44100); + assert!(result.is_ok()); + let result = initialize_audio(0, 1, 44100); + assert!(result.is_ok()); - let x = open_patch("tests/patches/no_existent.pd"); - assert!(x.is_err()); - let x = open_patch("/bad_path"); - assert!(x.is_err()); - let x = open_patch("tests/patches/simple.pd"); - assert!(x.is_ok()); + let result = open_patch("tests/patches/no_eresultistent.pd"); + assert!(result.is_err()); + let result = open_patch("/bad_path"); + assert!(result.is_err()); + let result = open_patch("tests/patches/simple.pd"); + assert!(result.is_ok()); - let x = close_patch(x.unwrap()); - assert!(x.is_ok()); + let result = close_patch(result.unwrap()); + assert!(result.is_ok()); let handle: PatchFileHandle = (std::ptr::null_mut() as *mut std::ffi::c_void).into(); - let x = close_patch(handle); - assert!(x.is_err()); + let result = close_patch(handle); + assert!(result.is_err()); - let x = add_to_search_paths("tests/patches"); - assert!(x.is_ok()); - let x = add_to_search_paths("/bad_path"); - assert!(x.is_err()); + let result = add_to_search_paths("tests/patches"); + assert!(result.is_ok()); + let result = add_to_search_paths("/bad_path"); + assert!(result.is_err()); clear_search_paths(); release_internal_queues(); let patch_handle = open_patch("tests/patches/simple.pd").unwrap(); - let x = get_dollar_zero(&patch_handle); - assert!(x.is_ok()); - assert_ne!(x.unwrap(), 0); + let result = get_dollar_zero(&patch_handle); + assert!(result.is_ok()); + assert_ne!(result.unwrap(), 0); let handle: PatchFileHandle = (std::ptr::null_mut() as *mut std::ffi::c_void).into(); - let x = get_dollar_zero(&handle); - assert!(x.is_err()); + let result = get_dollar_zero(&handle); + assert!(result.is_err()); - let x = block_size(); - assert_eq!(x, 64); + let result = block_size(); + assert_eq!(result, 64); - let x = verbose_print_state_active(); - assert!(!x); + let result = verbose_print_state_active(); + assert!(!result); verbose_print_state(true); - let x = verbose_print_state_active(); - assert!(x); + let result = verbose_print_state_active(); + assert!(result); verbose_print_state(false); - let x = verbose_print_state_active(); - assert!(!x); + let result = verbose_print_state_active(); + assert!(!result); } diff --git a/tests/gui.rs b/tests/gui.rs index c9a8049..666fb05 100644 --- a/tests/gui.rs +++ b/tests/gui.rs @@ -1,4 +1,5 @@ #![allow(clippy::restriction)] +#![allow(unused)] use libpd_rs::gui::{poll_gui, start_gui, stop_gui}; use std::{env, path::PathBuf}; diff --git a/tests/send_and_receive_after_touch.rs b/tests/send_and_receive_after_touch.rs index 37b18f2..b2e9182 100644 --- a/tests/send_and_receive_after_touch.rs +++ b/tests/send_and_receive_after_touch.rs @@ -12,7 +12,6 @@ use libpd_rs::{ }; #[test] -#[ignore] fn send_and_receive_after_touch() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_bang.rs b/tests/send_and_receive_bang.rs index b3cca20..d7c4767 100644 --- a/tests/send_and_receive_bang.rs +++ b/tests/send_and_receive_bang.rs @@ -11,20 +11,18 @@ use libpd_rs::{ send::send_bang_to, }; +#[test] fn send_and_receive_bang() { let sample_rate = 44100; let output_channels = 2; let bangs: Arc>> = Arc::new(Mutex::new(vec![])); - let a = init().unwrap(); - dbg!(a); - let b = initialize_audio(0, output_channels, sample_rate).unwrap(); - dbg!(b); + let _ = init().unwrap(); + let _ = initialize_audio(0, output_channels, sample_rate).unwrap(); dsp_on().unwrap(); let patch_handle = open_patch("tests/patches/echo.pd").unwrap(); - dbg!(&patch_handle); let bangs_to_fill = bangs.clone(); on_bang(move |source| { @@ -32,7 +30,6 @@ fn send_and_receive_bang() { bangs_to_fill.lock().unwrap().push("bang"); }); let receiver_handle = start_listening_from("bang_from_pd").unwrap(); - dbg!(&receiver_handle); // Mimic audio callback buffers. let input_buffer = [0.0f32; 512]; @@ -51,7 +48,6 @@ fn send_and_receive_bang() { )); receive_messages_from_pd(); - dbg!("Runs?"); let ticks = output_buffer.len() as i32 / (block_size() * output_channels); process_float(ticks, &input_buffer, &mut output_buffer); match rx.try_recv() { @@ -66,13 +62,12 @@ fn send_and_receive_bang() { send_bang_to("bang_from_rust").unwrap(); } - std::thread::sleep(std::time::Duration::from_millis(2000)); + std::thread::sleep(std::time::Duration::from_millis(50)); // Stop pd. tx.send(()).unwrap(); handle.join().unwrap(); - dbg!(bangs.lock().unwrap()); assert_eq!(bangs.lock().unwrap().len(), 5); // Stop listening and close handle. diff --git a/tests/send_and_receive_control_change.rs b/tests/send_and_receive_control_change.rs index 3c1c167..278f9ef 100644 --- a/tests/send_and_receive_control_change.rs +++ b/tests/send_and_receive_control_change.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_control_change, }; +#[test] fn send_and_receive_control_change() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_double.rs b/tests/send_and_receive_double.rs index 95eb6e0..cac2bd4 100644 --- a/tests/send_and_receive_double.rs +++ b/tests/send_and_receive_double.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_double_to, }; +#[test] fn send_and_receive_double() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_float.rs b/tests/send_and_receive_float.rs index b02f83c..e5500d0 100644 --- a/tests/send_and_receive_float.rs +++ b/tests/send_and_receive_float.rs @@ -17,12 +17,6 @@ fn send_and_receive_float() { let output_channels = 2; let floats: Arc>> = Arc::new(Mutex::new(vec![])); - let floats_to_fill = floats.clone(); - on_float(move |source, value| { - dbg!("RECEIVES?"); - assert_eq!(source, "float_from_pd"); - floats_to_fill.lock().unwrap().push(value); - }); let _ = init().unwrap(); let _ = initialize_audio(0, output_channels, sample_rate).unwrap(); @@ -30,6 +24,11 @@ fn send_and_receive_float() { let patch_handle = open_patch("tests/patches/echo.pd").unwrap(); + let floats_to_fill = floats.clone(); + on_float(move |source, value| { + assert_eq!(source, "float_from_pd"); + floats_to_fill.lock().unwrap().push(value); + }); let receiver_handle = start_listening_from("float_from_pd").unwrap(); // Mimic audio callback buffers. diff --git a/tests/send_and_receive_list.rs b/tests/send_and_receive_list.rs index fd4bcd0..555186b 100644 --- a/tests/send_and_receive_list.rs +++ b/tests/send_and_receive_list.rs @@ -15,6 +15,7 @@ use libpd_rs::{ types::Atom, }; +#[test] fn send_and_receive_list() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_midi_byte.rs b/tests/send_and_receive_midi_byte.rs index 13b0dbc..5a0e059 100644 --- a/tests/send_and_receive_midi_byte.rs +++ b/tests/send_and_receive_midi_byte.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_midi_byte, }; +#[test] fn send_and_receive_midi_byte() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_note_on.rs b/tests/send_and_receive_note_on.rs index 31f735c..970f664 100644 --- a/tests/send_and_receive_note_on.rs +++ b/tests/send_and_receive_note_on.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_note_on, }; +#[test] fn send_and_receive_note_on() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_pitch_bend.rs b/tests/send_and_receive_pitch_bend.rs index 865f1b8..bddebd6 100644 --- a/tests/send_and_receive_pitch_bend.rs +++ b/tests/send_and_receive_pitch_bend.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_pitch_bend, }; +#[test] fn send_and_receive_pitch_bend() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_poly_after_touch.rs b/tests/send_and_receive_poly_after_touch.rs index f42a254..2f874a2 100644 --- a/tests/send_and_receive_poly_after_touch.rs +++ b/tests/send_and_receive_poly_after_touch.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_poly_after_touch, }; +#[test] fn send_and_receive_poly_after_touch() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_program_change.rs b/tests/send_and_receive_program_change.rs index 5a6061f..1bfacd4 100644 --- a/tests/send_and_receive_program_change.rs +++ b/tests/send_and_receive_program_change.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_program_change, }; +#[test] fn send_and_receive_program_change() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_sys_realtime.rs b/tests/send_and_receive_sys_realtime.rs index 37a59be..311bb83 100644 --- a/tests/send_and_receive_sys_realtime.rs +++ b/tests/send_and_receive_sys_realtime.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_sys_realtime, }; +#[test] fn send_and_receive_sys_realtime() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_sysex.rs b/tests/send_and_receive_sysex.rs index 75d13f5..acd4eb4 100644 --- a/tests/send_and_receive_sysex.rs +++ b/tests/send_and_receive_sysex.rs @@ -11,6 +11,7 @@ use libpd_rs::{ send::send_sysex, }; +#[test] fn send_and_receive_sysex() { let sample_rate = 44100; let output_channels = 2; diff --git a/tests/send_and_receive_typed_message.rs b/tests/send_and_receive_typed_message.rs index e5efd0e..62d188a 100644 --- a/tests/send_and_receive_typed_message.rs +++ b/tests/send_and_receive_typed_message.rs @@ -12,6 +12,7 @@ use libpd_rs::{ verbose_print_state, }; +#[test] fn send_and_receive_typed_message() { let sample_rate = 44100; let output_channels = 2;