Skip to content

Commit

Permalink
Regression test for #4159
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Oct 12, 2024
1 parent 05ae805 commit 96843d5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/core/sources/debug_sources.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,28 @@ let _ =
~descr:
"A source that errors during its initialization phase, used for testing \
and debugging." ~flags:[`Experimental] ~return_t [] (fun _ ->
(new fail_init :> Source.source))
new fail_init)

class is_ready s =
object (self)
inherit Source.operator ~name:"is_ready" [s]
method seek_source = (self :> Source.source)
method fallible = true
method private can_generate_frame = true
method self_sync = (`Static, None)
method remaining = 0
method abort_track = ()
method generate_frame = if s#is_ready then s#get_frame else self#empty_frame
end

let _ =
let return_t = Lang.frame_t (Lang.univ_t ()) Frame.Fields.empty in
Lang.add_operator ~base:Modules.debug "is_ready" ~category:`Input
~descr:
"A source that always produces an empty frame when the underlying source \
is not ready, used for testing and debugging."
~flags:[`Experimental] ~return_t
[("", Lang.source_t return_t, None, None)]
(fun p ->
let s = Lang.to_source (List.assoc "" p) in
new is_ready s)
5 changes: 5 additions & 0 deletions tests/regression/GH4159.liq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
s = debug.is_ready(sine(duration=0.2))

s = source.dynamic(track_sensitive=false, {s})

output.dummy(fallible=true, on_stop=test.pass, s)
16 changes: 16 additions & 0 deletions tests/regression/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,22 @@
(:run_test ../run_test.exe))
(action (run %{run_test} GH4144.liq liquidsoap %{test_liq} GH4144.liq)))

(rule
(alias citest)
(package liquidsoap)
(deps
GH4159.liq
../media/all_media_files
../../src/bin/liquidsoap.exe
../streams/file1.png
../streams/file1.mp3
./theora-test.mp4
(package liquidsoap)
(source_tree ../../src/libs)
(:test_liq ../test.liq)
(:run_test ../run_test.exe))
(action (run %{run_test} GH4159.liq liquidsoap %{test_liq} GH4159.liq)))

(rule
(alias citest)
(package liquidsoap)
Expand Down

0 comments on commit 96843d5

Please sign in to comment.