Giter Site home page Giter Site logo

norman / telescope Goto Github PK

View Code? Open in Web Editor NEW
159.0 159.0 35.0 471 KB

A highly customizable test library for Lua that allows declarative tests with nested contexts.

Home Page: http://norman.github.com/telescope/

CSS 11.31% Lua 73.23% Perl 15.46%

telescope's People

Contributors

dcharbon avatar haste avatar norman avatar odie avatar pflaquerre avatar richardfinegan avatar sebnow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telescope's Issues

Telescope is too sensitive to syntax errors on test files

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    

Can't build documentation with ldoc-1.4.2

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 !

package path needs to be adjusted to run Telescope's own tests

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.

nested tests run in incorrect order

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

remove LuaTasks in favor of a plain old Makefile

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.

tsc's callbacks don't support non-rvalued expressions

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!

Is there a way to supply arguments to a lua file?

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?

Global "t2" ?

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.

Recent changes for Lua 5.2 compatibility broke "-f" option

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".

bad argument #1 to 'setfenv' (number expected, got nil) on telescope.lua:289

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.