diff options
Diffstat (limited to 'TOOLS/lua/command-test.lua')
-rw-r--r-- | TOOLS/lua/command-test.lua | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/TOOLS/lua/command-test.lua b/TOOLS/lua/command-test.lua index dd384818cc..877cacdeb6 100644 --- a/TOOLS/lua/command-test.lua +++ b/TOOLS/lua/command-test.lua @@ -76,6 +76,25 @@ mp.observe_property("vo-configured", "bool", function(_, v) end) + mp.command_native_async({name = "subprocess", args = {"wc", "-c"}, + stdin_data = "hello", capture_stdout = true}, + function(res, val, err) + print("Should be '5': " .. val.stdout) + end) + -- blocking stdin by default + mp.command_native_async({name = "subprocess", args = {"cat"}, + capture_stdout = true}, + function(res, val, err) + print("Should be 0: " .. #val.stdout) + end) + -- stdin + detached + mp.command_native_async({name = "subprocess", + args = {"bash", "-c", "(sleep 5s ; cat)"}, + stdin_data = "this should appear after 5s.\n", + detach = true}, + function(res, val, err) + print("5s test: " .. val.status) + end) -- This should get killed on script exit. mp.command_native_async({name = "subprocess", playback_only = false, @@ -86,10 +105,20 @@ mp.observe_property("vo-configured", "bool", function(_, v) playback_only = false, args = {"sleep", "inf"}}) end) -mp.register_event("shutdown", function() +function freeze_test(playback_only) -- This "freezes" the script, should be killed via timeout. - print("freeze!") - local x = mp.command_native({name = "subprocess", playback_only = false, + counter = counter and counter + 1 or 0 + print("freeze! " .. counter) + local x = mp.command_native({name = "subprocess", + playback_only = playback_only, args = {"sleep", "inf"}}) print("done, killed=" .. utils.to_string(x.killed_by_us)) +end + +mp.register_event("shutdown", function() + freeze_test(false) +end) + +mp.register_event("idle", function() + freeze_test(true) end) |