-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fennel loader? #738
Comments
I have made some progress, but it's not yet there. local path = require 'pl.path'
local ok, fennel = pcall(require, 'fennel')
local ret = {}
local getTrace = function(filename, info)
return info -- TODO
end
local rewriteMessage = function(filename, message)
return message -- TODO
end
ret.match = function(busted, filename)
return ok and path.extension(filename) == '.fnl'
end
ret.load = function(busted, filename)
if not ok then
error 'unable to load Fennel.'
end
local err = nil
local file = function()
return fennel.dofile(filename, {env = _G})
end
-- TODO: Check if filename exists and is readable
if not file then
busted.publish({ 'error', 'file' }, { descriptor = 'file', name = filename }, nil, err, {})
end
return file, getTrace, rewriteMessage
end
return ret This lets me at least load Fennel tests, but they won't work because the
What kind of magic is busted using to make |
OK, I think I got it working using a custom local function loadfile_(fname, ...)
local file, err = io.open(fname)
if not (file) then
return nil, err
end
local text = assert(file:read("*a"))
file:close()
local lua = fennel.compileString(text)
return (loadstring or load)(lua)
end Now that I have a working minimum example I can start making the code good. |
Hello,
I would like to write tests in Fennel. My understanding is that this would be possible by implementing a Fennel runner. Looking at the source code it seems like the files under
busted/modules/files
implement loaders for Lua, Moonscript and Terra. A loader is a table with two functionsload
andmatch
, but there is no explanation as to what interface these two functions must implement.I would like to try my hands at writing a Fennel runner. Is there some explanation, or can someone here please elaborate on the protocol that needs to be implemented?
The text was updated successfully, but these errors were encountered: