summaryrefslogtreecommitdiffstats
path: root/TOOLS/lua/command-test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'TOOLS/lua/command-test.lua')
-rw-r--r--TOOLS/lua/command-test.lua23
1 files changed, 21 insertions, 2 deletions
diff --git a/TOOLS/lua/command-test.lua b/TOOLS/lua/command-test.lua
index 30d8cc05ff..a80edbd3e1 100644
--- a/TOOLS/lua/command-test.lua
+++ b/TOOLS/lua/command-test.lua
@@ -35,11 +35,11 @@ mp.observe_property("vo-configured", "bool", function(_, v)
timer:resume()
print("Slow screenshot command...")
- res, err = mp.command_native({"screenshot"})
+ res = mp.command_native({"screenshot"})
print("done, res: " .. utils.to_string(res))
print("Slow screenshot async command...")
- res, err = mp.command_native_async({"screenshot"}, function(res)
+ res = mp.command_native_async({"screenshot"}, function(res)
print("done (async), res: " .. utils.to_string(res))
timer:kill()
end)
@@ -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(_, val)
+ print("Should be '5': " .. val.stdout)
+ end)
+ -- blocking stdin by default
+ mp.command_native_async({name = "subprocess", args = {"cat"},
+ capture_stdout = true},
+ function(_, val)
+ 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(_, val)
+ print("5s test: " .. val.status)
+ end)
-- This should get killed on script exit.
mp.command_native_async({name = "subprocess", playback_only = false,