[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lunit and File-scoped Strictness, loadfile Path?
- From: Veli-Pekka Tätilä <vtatila@...>
- Date: Tue, 5 Aug 2008 15:07:58 +0300
Hi, a summary of questions:
1. Does Lunit work under strict?
2. How do I use strictness file scoped?
3. Does loadfile follow the Lua path?
And the long story:
I'm trying to use Lunit 0.4 for work. Since I'm in Windows I replaced the
Bash script doing the testing with a bit of Lua code which runs in the app
in which Lua Plus is integrated. However, when I run the app running lunit,
and the code being tested, both of which require strict, strict complains
about LUnit internals.
How can I use Lunit and still write code under strict? Seems to me that as
long as my code running LUnit has anything included that includes strict,
I'm in trouble. I've read the strict source and often for global assignments
saying:
__STRICT = false
temporarily, does get rid of the problem. HOwever, not in this case. Or else
I'm just not thinking clearly at the moment. Can strict be made a truely
file scoped pragma as in Perl?
I also have a final question. I'd like to respect the app's path in which
Lua (Plus) is integrated, which require happily does. HOwever, lunit seems
to load its code via loadfile, in stead, and not pass my modules their name
as the first variable arg, I guess - among other things. Does loadfile
respect the luapath? I thought it would not.
Finally, some sample code of how I'm running Lunit follows:
function Run(...)
require "lunit" -- The framework doing the hard work.
local old_out = io.output() -- Save away our stdout before logging.
<snip>
for k, basename in ipairs({ ... }) do
local filename, logname = basename .. ".lua", basename .. ".log"
local out, message = io.open(logname, "w")
if not out then error(message) end
io.output(out)
-- Lunit does all the work here.
rawset(_G, 'myerror', error) -- For custom Lunit errors.
lunit.main{filename} -- The testing happens here.
rawset(_G, 'myerror', nil)
-- Work done.
out:close()
io.output(old_out) -- errors on loading next file get to stdout.
end
<snippage>
end
--
With kind regards Veli-Pekka Tätilä
Accessibility, Apps and Coding plus Synths and Music:
http://vtatila.kapsi.fi