More cleaning/linting

This commit is contained in:
perro tuerto 2023-06-16 11:03:16 -07:00
parent 7dc8d75b6c
commit 86ed0ecb3e
3 changed files with 10 additions and 10 deletions

View File

@ -12,13 +12,14 @@ local function make_dist(name, bundle)
-- Chomps file -- Chomps file
local function chomp(str) local function chomp(str)
local without = without or false
str = string.readtext(str):strip() str = string.readtext(str):strip()
return "\n" .. str .. "\n" return "\n" .. str .. "\n"
end end
-- Defaults to true
bundle = (bundle == nil or bundle == true)
-- Variables -- Variables
local bundle = (bundle == nil or bundle == true)
local dist = pandoc.path.join({"dist", name}) local dist = pandoc.path.join({"dist", name})
local fnl = chomp(optpath .. "fennel.lua"):gsub("\nreturn mod\n", "\nlocal fnl = mod\n") local fnl = chomp(optpath .. "fennel.lua"):gsub("\nreturn mod\n", "\nlocal fnl = mod\n")
local dog = chomp(optpath .. "dog.lua") local dog = chomp(optpath .. "dog.lua")
@ -43,7 +44,7 @@ Fennel:
]]) ]])
-- Bundles Fennel and Computable Pandoc -- Bundles Fennel and Computable Pandoc
file = io.open(dist, "w") local file = io.open(dist, "w")
if bundle then if bundle then
file:write("--[[\n", extralicense, "\n]]--\n") file:write("--[[\n", extralicense, "\n]]--\n")
file:write(fnl, dog, nat) file:write(fnl, dog, nat)

View File

@ -7,8 +7,7 @@ package.path = "./opt/share/lua/5.4/?.lua;" .. package.path
require "dog" require "dog"
-- Gets command according to OS -- Gets command according to OS
local function getcmd(str) local function getcmd()
local system = (os.isunix() and "unix" or "win")
if os:isunix() then if os:isunix() then
return "ls" return "ls"
else else
@ -17,7 +16,7 @@ local function getcmd(str)
end end
-- Makes JSON from markup files -- Makes JSON from markup files
for file in io.popen(getcmd("ls") .. " tests/asts"):lines() do for file in io.popen(getcmd() .. " tests/asts"):lines() do
local json = pandoc.path.join({"tests", "asts", file}) local json = pandoc.path.join({"tests", "asts", file})
local mark = pandoc.path.join({"tests", pandoc.path.filename(json:stem())}) local mark = pandoc.path.join({"tests", pandoc.path.filename(json:stem())})
pandoc.convert(mark, "json", json) pandoc.convert(mark, "json", json)

View File

@ -53,10 +53,10 @@ local function getcmd(str)
end end
-- Obtains result as "pass" | "fail" | "diff" (AST doesn't match) -- Obtains result as "pass" | "fail" | "diff" (AST doesn't match)
local function getresult(file, f, v, t) local function getresult(test)
local tmp, name = "tmp.json", pandoc.path.filename(file) local tmp, name = "tmp.json", pandoc.path.filename(test)
local json = pandoc.path.join({"tests", "asts", name .. ".json"}) local json = pandoc.path.join({"tests", "asts", name .. ".json"})
local ok, out = io.try(getcmd("pandoc"), f, v, t, "-t json", "-o", tmp, file) local ok, out = io.try(getcmd("pandoc"), "-L", filter, verbose, trace, "-t json", "-o", tmp, test)
local json1, json2 = tmp:readtext(), json:readtext() local json1, json2 = tmp:readtext(), json:readtext()
os.remove("tmp.json") os.remove("tmp.json")
if (ok and json2 == nil) or (ok and json1 == json2) then if (ok and json2 == nil) or (ok and json1 == json2) then
@ -100,7 +100,7 @@ print "🐾 Starting tests"
-- Does tests -- Does tests
for _, file in ipairs(files) do for _, file in ipairs(files) do
local expectation = pandoc.path.filename(file):gsub("%W.+$", "") local expectation = pandoc.path.filename(file):gsub("%W.+$", "")
local result, output = getresult(file, "-L", filter, verbose, trace) local result, output = getresult(file)
print("⚗️ " .. file .. ":") print("⚗️ " .. file .. ":")
print(" Expect: " .. expectation) print(" Expect: " .. expectation)
print(" Result: " .. result) print(" Result: " .. result)