From f3f77353f2ada6221dee06905ecfb0bc0448f814 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Mon, 27 May 2024 23:05:39 +0200 Subject: [PATCH] TOOLS/command-test.lua: fix lint warnings --- .luacheckrc | 1 - TOOLS/lua/command-test.lua | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 7616a69c81..043c683994 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -110,7 +110,6 @@ max_line_length = 100 -- TODO: Remove everything below this line local todo = { "player/lua/osc.lua", - "TOOLS/lua/command-test.lua", "TOOLS/lua/cycle-deinterlace-pullup.lua", "TOOLS/lua/nan-test.lua", "TOOLS/lua/observe-all.lua", diff --git a/TOOLS/lua/command-test.lua b/TOOLS/lua/command-test.lua index a80edbd3e1..1f485cdf7f 100644 --- a/TOOLS/lua/command-test.lua +++ b/TOOLS/lua/command-test.lua @@ -2,7 +2,7 @@ local utils = require("mp.utils") -function join(sep, arr, count) +local function join(sep, arr, count) local r = "" if count == nil then count = #arr @@ -31,19 +31,19 @@ mp.observe_property("vo-configured", "bool", function(_, v) mp.set_property("screenshot-format", "png") mp.set_property("screenshot-png-compression", "9") - timer = mp.add_periodic_timer(0.1, function() print("I'm alive") end) + local timer = mp.add_periodic_timer(0.1, function() print("I'm alive") end) timer:resume() print("Slow screenshot command...") - res = mp.command_native({"screenshot"}) - print("done, res: " .. utils.to_string(res)) + local result = mp.command_native({"screenshot"}) + print("done, res: " .. utils.to_string(result)) print("Slow screenshot async command...") - res = mp.command_native_async({"screenshot"}, function(res) + result = mp.command_native_async({"screenshot"}, function(res) print("done (async), res: " .. utils.to_string(res)) timer:kill() end) - print("done (sending), res: " .. utils.to_string(res)) + print("done (sending), res: " .. utils.to_string(result)) print("Broken screenshot async command...") mp.command_native_async({"screenshot-to-file", "/nonexistent/bogus.png"}, @@ -51,7 +51,11 @@ mp.observe_property("vo-configured", "bool", function(_, v) print("done err scr.: " .. join(" ", {res, val, err})) end) - mp.command_native_async({name = "subprocess", args = {"sh", "-c", "echo hi && sleep 10s"}, capture_stdout = true}, + mp.command_native_async({ + name = "subprocess", + args = {"sh", "-c", "echo hi && sleep 10s"}, + capture_stdout = true + }, function(res, val, err) print("done subprocess: " .. join(" ", {res, val, err})) end) @@ -105,7 +109,8 @@ mp.observe_property("vo-configured", "bool", function(_, v) playback_only = false, args = {"sleep", "inf"}}) end) -function freeze_test(playback_only) +local counter +local function freeze_test(playback_only) -- This "freezes" the script, should be killed via timeout. counter = counter and counter + 1 or 0 print("freeze! " .. counter)