[FarGroup/FarManager] master: LuaMacro: refactor macro-tests (1570c78c9)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
May 25, 2026, 12:46:00 PM (3 days ago) May 25
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/1570c78c99be8cd2c3bff3ea2f2ff46cce3250b9

>---------------------------------------------------------------

commit 1570c78c99be8cd2c3bff3ea2f2ff46cce3250b9
Author: Shmuel Zeigerman <solo...@gmail.com>
Date: Mon May 25 19:37:01 2026 +0300

LuaMacro: refactor macro-tests


>---------------------------------------------------------------

1570c78c99be8cd2c3bff3ea2f2ff46cce3250b9
plugins/luamacro/_globalinfo.lua | 2 +-
plugins/luamacro/changelog | 4 ++++
plugins/luamacro/luafar/lf_version.h | 2 +-
plugins/luamacro/luamacro.lua | 3 ++-
plugins/luamacro/macrotest.lua | 19 ++++++++++++++-----
5 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/plugins/luamacro/_globalinfo.lua b/plugins/luamacro/_globalinfo.lua
index 4801e872b..65217a0c8 100644
--- a/plugins/luamacro/_globalinfo.lua
+++ b/plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
- Version = { 3, 0, 0, 926 },
+ Version = { 3, 0, 0, 927 },
MinFarVersion = { 3, 0, 0, 6678 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
diff --git a/plugins/luamacro/changelog b/plugins/luamacro/changelog
index bf9c04ddd..876b4596b 100644
--- a/plugins/luamacro/changelog
+++ b/plugins/luamacro/changelog
@@ -1,3 +1,7 @@
+shmuel 2026-05-25 19:13:12+03:00 - build 927
+
+1. Refactor macro-tests.
+
shmuel 2026-05-08 15:23:15+03:00 - build 926

1. LuaFAR: refactoring.
diff --git a/plugins/luamacro/luafar/lf_version.h b/plugins/luamacro/luafar/lf_version.h
index 87f009a5f..a71d5b859 100644
--- a/plugins/luamacro/luafar/lf_version.h
+++ b/plugins/luamacro/luafar/lf_version.h
@@ -1,3 +1,3 @@
#include <farversion.hpp>

-#define PLUGIN_BUILD 926
+#define PLUGIN_BUILD 927
diff --git a/plugins/luamacro/luamacro.lua b/plugins/luamacro/luamacro.lua
index 8d5a0dbeb..c14e3fa5e 100644
--- a/plugins/luamacro/luamacro.lua
+++ b/plugins/luamacro/luamacro.lua
@@ -390,7 +390,8 @@ local function Open_CommandLine (strCmdLine)
R = loadfile(R) or Quit(1)
OK, R = pcall(R)
OK = OK or Quit(2)
- R.test_all = R.test_all or Quit(3)
+ OK = R.test_all and R.SetMacroKeys or Quit(3)
+ R.SetMacroKeys("CtrlShiftF12")
OK = xpcall(R.test_all, errorhandler)
Quit(OK and 0 or 4)
]], 0, "CtrlShiftF12")
diff --git a/plugins/luamacro/macrotest.lua b/plugins/luamacro/macrotest.lua
index 74467ee04..38bb770ec 100644
--- a/plugins/luamacro/macrotest.lua
+++ b/plugins/luamacro/macrotest.lua
@@ -10,14 +10,16 @@ Macro {
action = function()
Far.DisableHistory(0x0F)
local f = assert(loadfile(far.PluginStartupInfo().ModuleDir.."macrotest.lua"))
- setfenv(f, getfenv())().test_all()
+ local mod = setfenv(f, getfenv())()
+ mod.SetMacroKeys("CtrlShiftF12")
+ mod.test_all()
far.Message("All tests OK", "LuaMacro")
end;
}
--]]

-- The keys that invoke the whole macrotest from a macro. Some tests depend on that.
-local MacroKey1, MacroKey2 = "CtrlShiftF12", "RCtrlShiftF12"
+local MacroKeys = {}

local AF = "my assertion failed"
local function assert_eq(a,b,m) assert(a == b, m or AF) return true; end
@@ -51,6 +53,10 @@ local luamacroId="4ebbefc8-2084-4b7f-94c0-692ce136894d"
local hlfviewerId = "1AF0754D-5020-49CB-9474-1F82691C84C1"
local TKEY_BINARY = "__binary"

+function MT.SetMacroKeys(...)
+ MacroKeys = { ... }
+end
+
local function pack (...)
return { n=select("#",...), ... }
end
@@ -118,8 +124,11 @@ end
local function test_mf_akey()
assert_eq(akey, mf.akey)
local key,name = akey(0),akey(1)
- assert(key==0x0501007B and name==MacroKey1 or
- key==0x1401007B and name==MacroKey2)
+ local ok = false
+ for _,refkey in ipairs(MacroKeys) do
+ if type(key)=="number" and name==refkey then ok=true; break; end
+ end
+ assert_true(ok)
-- (the 2nd parameter is tested in function test_mf_eval).
end

@@ -213,7 +222,7 @@ local function test_mf_eval()
assert(akey(1,1)=="CtrlA")
foobar = (foobar or 0) + 1
return foobar,false,5,nil,"foo"
- ]]):format(MacroKey1, MacroKey2)
+ ]]):format(MacroKeys[1] or "", MacroKeys[2] or "")
local Id = assert_udata(far.MacroAdd(nil,nil,"CtrlA",code))
for k=1,3 do
local ret1,a,b,c,d,e = eval("CtrlA",2)


Reply all
Reply to author
Forward
0 new messages