norman / telescope Goto Github PK
View Code? Open in Web Editor NEWA highly customizable test library for Lua that allows declarative tests with nested contexts.
Home Page: http://norman.github.com/telescope/
A highly customizable test library for Lua that allows declarative tests with nested contexts.
Home Page: http://norman.github.com/telescope/
I would like to know if there is an easy way to make telescope use LuaJIT when running specs/or if there is any 'best practice' to do so?
When using assert_error to test a function that does not raise any error, telescope gets stuck on that test with the CPU at 100% until the user intervenes with CTRL+C, then the rest of the tests are processed (tested with Lua 5.1.4).
See the following gist http://gist.github.com/418929 for reproduction code and the respective output.
TLua was a result of my Ruby-infected mind leaving me unable to realize that I could get by just fine without a Rakefile. Really, there's no need for this at least with Telescope, just use a damn Makefile and give people one dependency less.
Please add "test_report" to the list of local function aliases that are included in the "telescope" table that is returned at the bottom of "telescope.lua". Otherwise, the "-f" option breaks, complaining of nil field "test_report".
Hi,
Thanks for the work you've done on Telescope. I'm pretty new to testing frameworks, but I've enjoyed using it.
I just wanted to get in contact regarding the order in which the before and after functions are executed when nested contexts are involved.
I wrote a little script which just prints out the order things get called in and I got some weird results. When I run:
context("Outer", function()
context("Inner", function()
before(function() print(" before inner") end)
after(function() print (" after inner") end)
test("Inner test", function() print(" test inner") end)
end)
before(function() print("before outer") end)
after(function() print ("after outer")end)
test("Outer test", function() print("test outer") end)
end)
I get the following output, which shows an odd ordering. I don't know whether my script was too contrived, but I thought I'd pass it on.
before outer
before inner
test inner
after outer
after inner
before outer
test outer
after outer
------------------------------------------------------------------------
Outer:
Inner:
Inner test [U]
Outer test [U]
------------------------------------------------------------------------
I had expected each of the set up and teardown functions to be called only once, and was surprised to see the outer after being called immediately after the inner test. Is that the expected order of execution, or is something going wrong?
I'm using the latest master branch from git hub.
Thanks,
Tom
Hello !
I'm currently packaging telescope for Debian (it's part of a dependency tree leading up to neovim), and since we usually prefer rebuilding everything from sources during package building, including the documentation if a possible, I added "make docs" to our build scripts.
However I am getting the following error:
[...]/telescope:$ make docs
rm -rf docs
ldoc -t "Telescope API Docs" telescope.lua
/mnt/data/packages/lua/lua-telescope/telescope/telescope.lua:18: ?: 'class' cannot have multiple values; {module,module,module}
Makefile:15: recipe for target 'docs' failed
make: *** [docs] Error 1
Do you have any idea what could cause this? I am using ldoc-1.4.2.
Thanks !
I've frequently found this error when writing new tests. I forgot to close a function() with its corresponding end clause, and suddenly telescope just explodes:
telescope.lua:301: Test_spec.lua:104: '<eof>' expected near 'end'
Telescope.lua:301 currently says:
local func = assert(loadfile(path))
setfenv(func, env)()
loadfile detects a syntax error on path, and this error goes 'up' until telescope crashes.
I suggest wrapping that loadfile with function() and pcall so telescope is a bit more resilient. Something similar to this:
local func = function() assert(loadfile(path)) end
setfenv(func, env)
local status, errmsg = pcall(func)
if status == false then -- indicate that there was a syntax error on the path
else -- regular treatment of path here
"luarocks install telescope" currently installs version 0.4.1, which doesn't work with Lua 5.2. Confusingly, it doesn't fail to install, even on Lua 5.2. Please could you update the version on luarocks.org?
We need to change the module system (easy) and the way telescope handles environments (harder) in order for it to work properly on 5.2.
As requested by @ignacio.
Hi,
In telescope.lua, the private function invert_table
creates a global table named t2
at line 183.
Shouldn't it be local to the function, or is it intended ?
Regards,
Roland.
I have redefined some functions in my code for prettying up the output, but these seem to break telescope a bit. Is there a way to pass an argument to my code so that I can disable setting these functions?
Are there any plans for making telescope compatible with Lua 5.2 which removes setfenv and getfenv?
Hi!
I'd like to use your library in order to make some testing on my lib, MiddleClass. Unfortunately I'm getting the error you see above.
Steps for reproducing:
Installed with luarocks:
sudo luarocks build telescope --from=http://luarocks.luaforge.net/rocks-cvs/
I then tried the following command:
tsc -f test/*.lua
The test folder only has one file, called MiddleClass_test.lua:
require '../MiddleClass.lua'
-- Test base classes (classes that depend directly from Object)
context( 'Root Classes', function()
context( 'When created using class("name")', function()
local MyClass = class('MyClass')
test( 'should have their name set up', function()
assert_equal(MyClass.name, 'MyClass')
end)
test( 'should have Object as their superclass' function()
assert_equal(MyClass.superclass, Object)
end)
end)
end)
This is in Ubuntu 10.04.
This was just a quick hack and should be removed from Telescope.
Telescope currently does not adjust the package path in its own specs. When you have Telescope installed via Luarocks, you can't run Telescope's own specs because the telescope
from the system is required rather than the one in the current working directory.
By non-rvalued expressions I mean expressions that can not be used on the right side of an assignment.
The usual example of non-rvalues on lua are assignments themselves. If you put an assignment (or any other expression without an r-value) on a callback tsc throws an error.
Example:
tsc --before="a=1" -t *.lua
The conflict can be found on this line:
http://github.com/norman/telescope/blob/master/tsc#L254
This line appends 'return ' to the callback string; return needs an r-valued expression on its right side, or else it fails.
The simplest fix is removing the 'return':
add_callback(callback, loadstring(opts[callback])())
If for some reason (i.e. tests failing) the "return" is needed, then the opts[callback] should be encased inside a (function() ... end)() call, like so:
add_callback(callback, loadstring('return (function() ' .. opts[callback] .. ' end)()' )())
This should have the same behaviour as before, but allowing assignments on callbacks.
Regards!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.