From 3f762f8ad270083ddbf06ed14720068c30a5dcde Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Tue, 18 May 2021 14:43:43 -0400 Subject: [PATCH] fix, add test --- src/PortAudio.jl | 19 ++++++++++--------- test/runtests.jl | 10 +++++++++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/PortAudio.jl b/src/PortAudio.jl index c70029c..af76fe4 100644 --- a/src/PortAudio.jl +++ b/src/PortAudio.jl @@ -1,6 +1,6 @@ module PortAudio -using libportaudio_jll: libportaudio_jll +using libportaudio_jll: libportaudio using SampledSignals using Suppressor: @capture_err @@ -15,6 +15,15 @@ export PortAudioStream include("libportaudio.jl") +macro stderr_as_debug(expression) + quote + local result + debug_message = @capture_err result = $(esc(expression)) + @debug "$debug_message" + result + end +end + # This size is in frames # data is passed to and from portaudio in chunks with this many frames, because @@ -367,14 +376,6 @@ function discard_input(source::PortAudioSource) end end -macro stderr_as_debug(expression) - quote - debug_message = @capture_err result = $(esc(expression)) - @debug debug_message - result - end -end - function __init__() if Sys.islinux() envkey = "ALSA_CONFIG_DIR" diff --git a/test/runtests.jl b/test/runtests.jl index 6aede83..ed760f8 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,10 +1,18 @@ #!/usr/bin/env julia +using Logging: Debug using PortAudio -using PortAudio: Pa_GetDefaultInputDevice, Pa_GetDefaultOutputDevice, Pa_GetDeviceInfo, Pa_GetHostApiInfo, PortAudioDevice +using PortAudio: Pa_GetDefaultInputDevice, Pa_GetDefaultOutputDevice, Pa_GetDeviceInfo, Pa_GetHostApiInfo, PortAudioDevice, @stderr_as_debug using Test using SampledSignals +@testset "Debug messages" begin + @test_logs (:debug, "hi") min_level = Debug @test_nowarn @stderr_as_debug begin + print(stderr, "hi") + true + end +end + @testset "PortAudio Tests" begin @testset "Reports version" begin io = IOBuffer()