mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Preserve tags in choices children
This commit is contained in:
parent
b9c6d1d704
commit
5c3e9d2c5d
5 changed files with 134 additions and 30 deletions
29
test/run.lua
29
test/run.lua
|
|
@ -9,7 +9,7 @@ local function format_text(t, prefix)
|
|||
for _, l in ipairs(t) do
|
||||
r = r .. prefix
|
||||
local tags = ""
|
||||
for k, v in ipairs(l.tags) do
|
||||
for k, v in pairs(l.tags) do
|
||||
tags = tags .. ("[%q]=%q"):format(k, v)
|
||||
end
|
||||
if tags ~= "" then
|
||||
|
|
@ -39,6 +39,17 @@ local function compare(a, b)
|
|||
end
|
||||
end
|
||||
|
||||
local function write_result(filebase, result)
|
||||
local o = assert(io.open(filebase..".lua", "w"))
|
||||
o:write(ser(result))
|
||||
o:write("\n--[[\n")
|
||||
for _, v in ipairs(result) do
|
||||
o:write(inspect(v).."\n")
|
||||
end
|
||||
o:write("]]--")
|
||||
o:close()
|
||||
end
|
||||
|
||||
-- parse args
|
||||
local args = {}
|
||||
local i=1
|
||||
|
|
@ -163,15 +174,8 @@ else
|
|||
table.insert(result, { "error", err })
|
||||
end
|
||||
|
||||
if args.write then
|
||||
local o = assert(io.open(filebase..".lua", "w"))
|
||||
o:write(ser(result))
|
||||
o:write("\n--[[\n")
|
||||
for _, v in ipairs(result) do
|
||||
o:write(inspect(v).."\n")
|
||||
end
|
||||
o:write("]]--")
|
||||
o:close()
|
||||
if args["write-all"] then
|
||||
write_result(filebase, result)
|
||||
else
|
||||
local o, e = loadfile(filebase..".lua")
|
||||
if o then
|
||||
|
|
@ -188,7 +192,10 @@ else
|
|||
success = success + 1
|
||||
end
|
||||
else
|
||||
if not args.silent then
|
||||
if args["write-new"] and e:match("No such file") then
|
||||
write_result(filebase, result)
|
||||
print("Written result file for "..filebase)
|
||||
elseif not args.silent then
|
||||
print("> "..namespace)
|
||||
print(e)
|
||||
print("result was:")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue