More cleaning/linting
This commit is contained in:
parent
7dc8d75b6c
commit
86ed0ecb3e
|
@ -12,13 +12,14 @@ local function make_dist(name, bundle)
|
|||
|
||||
-- Chomps file
|
||||
local function chomp(str)
|
||||
local without = without or false
|
||||
str = string.readtext(str):strip()
|
||||
return "\n" .. str .. "\n"
|
||||
end
|
||||
|
||||
-- Defaults to true
|
||||
bundle = (bundle == nil or bundle == true)
|
||||
|
||||
-- Variables
|
||||
local bundle = (bundle == nil or bundle == true)
|
||||
local dist = pandoc.path.join({"dist", name})
|
||||
local fnl = chomp(optpath .. "fennel.lua"):gsub("\nreturn mod\n", "\nlocal fnl = mod\n")
|
||||
local dog = chomp(optpath .. "dog.lua")
|
||||
|
@ -43,7 +44,7 @@ Fennel:
|
|||
]])
|
||||
|
||||
-- Bundles Fennel and Computable Pandoc
|
||||
file = io.open(dist, "w")
|
||||
local file = io.open(dist, "w")
|
||||
if bundle then
|
||||
file:write("--[[\n", extralicense, "\n]]--\n")
|
||||
file:write(fnl, dog, nat)
|
||||
|
|
|
@ -7,8 +7,7 @@ package.path = "./opt/share/lua/5.4/?.lua;" .. package.path
|
|||
require "dog"
|
||||
|
||||
-- Gets command according to OS
|
||||
local function getcmd(str)
|
||||
local system = (os.isunix() and "unix" or "win")
|
||||
local function getcmd()
|
||||
if os:isunix() then
|
||||
return "ls"
|
||||
else
|
||||
|
@ -17,7 +16,7 @@ local function getcmd(str)
|
|||
end
|
||||
|
||||
-- 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 mark = pandoc.path.join({"tests", pandoc.path.filename(json:stem())})
|
||||
pandoc.convert(mark, "json", json)
|
||||
|
|
|
@ -53,10 +53,10 @@ local function getcmd(str)
|
|||
end
|
||||
|
||||
-- Obtains result as "pass" | "fail" | "diff" (AST doesn't match)
|
||||
local function getresult(file, f, v, t)
|
||||
local tmp, name = "tmp.json", pandoc.path.filename(file)
|
||||
local function getresult(test)
|
||||
local tmp, name = "tmp.json", pandoc.path.filename(test)
|
||||
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()
|
||||
os.remove("tmp.json")
|
||||
if (ok and json2 == nil) or (ok and json1 == json2) then
|
||||
|
@ -100,7 +100,7 @@ print "🐾 Starting tests"
|
|||
-- Does tests
|
||||
for _, file in ipairs(files) do
|
||||
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(" Expect: " .. expectation)
|
||||
print(" Result: " .. result)
|
||||
|
|
Loading…
Reference in New Issue