Permalink
Browse files

Replace torch.Tester with totem.Tester + extra stuff.

This should bring a lot of benefit to code that uses torch.Tester (totem will
eventually become deprecated). Note that torch.Tester and totem.Tester once
shared the same code - this change brings it full circle.

At a glance, extra functionality includes:
- A general equality checker that accepts many different objects.
- Deep table comparison with precision checking.
- Stricter argument checking in using the test functions.
- Better output.
- torch.Storage comparison.
- Extra features for fine-grained control of testing.
  • Loading branch information...
1 parent 3bbb49f commit d8ff64c5707f716199e7782d630e44e2cf402a54 @davidsaxton davidsaxton committed Feb 24, 2016
Showing with 1,775 additions and 292 deletions.
  1. +1 −0 .travis.yml
  2. +1 −1 CMakeLists.txt
  3. +30 −0 TestSuite.lua
  4. +797 −150 Tester.lua
  5. +278 −66 doc/tester.md
  6. +1 −0 init.lua
  7. +2 −1 rocks/torch-scm-1.rockspec
  8. +35 −70 test/test.lua
  9. +626 −0 test/test_Tester.lua
  10. +1 −1 test/test_qr.lua
  11. +1 −1 test/test_sharedmem.lua
  12. +2 −2 test/test_writeObject.lua
View
@@ -57,3 +57,4 @@ script:
- ${TESTLUA} -ltorch -e "t=torch.test(); if t.errors[1] then os.exit(1) end"
- cd test
- ${TESTLUA} test_writeObject.lua
+- ${TESTLUA} test_Tester.lua
View
@@ -71,7 +71,7 @@ INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/lib/luaT")
LINK_DIRECTORIES("${LUA_LIBDIR}")
SET(src DiskFile.c File.c MemoryFile.c PipeFile.c Storage.c Tensor.c Timer.c utils.c init.c TensorOperator.c TensorMath.c random.c Generator.c)
-SET(luasrc init.lua File.lua Tensor.lua CmdLine.lua FFI.lua Tester.lua test/test.lua)
+SET(luasrc init.lua File.lua Tensor.lua CmdLine.lua FFI.lua Tester.lua TestSuite.lua test/test.lua)
# Necessary do generate wrapper
ADD_TORCH_WRAP(tensormathwrap TensorMath.lua)
View
@@ -0,0 +1,30 @@
+function torch.TestSuite()
+ local obj = {
+ __tests = {},
+ __isTestSuite = true
+ }
+
+ local metatable = {}
+
+ function metatable:__index(key)
+ return self.__tests[key]
+ end
+
+ function metatable:__newindex(key, value)
+ if self.__tests[key] ~= nil then
+ error("Test " .. tostring(key) .. " is already defined.")
+ end
+ if type(value) ~= "function" then
+ if type(value) == "table" then
+ error("Nested tables of tests are not supported")
+ else
+ error("Only functions are supported as members of a TestSuite")
+ end
+ end
+ self.__tests[key] = value
+ end
+
+ setmetatable(obj, metatable)
+
+ return obj
+end
Oops, something went wrong.

4 comments on commit d8ff64c

@borisfom
Contributor

This indroduced circular dependency sys <->torch7.

@soumith
Member
soumith commented on d8ff64c Mar 9, 2016

not really, sys only (wrongly) depends on torch7 in it's rockspec, but doesn't actually depend on it in the code itself.

@borisfom
Contributor

I thought that too :).

Sys should be fixed as now it leads to the thing below.
I can prepare PR for sys - let me know!

-- Installing: /home/bfomitchev/git/distro/install/lib/luarocks/rocks/paths/scm-1/lib/libpaths.so
Updating manifest for /home/bfomitchev/git/distro/install/lib/luarocks/rocks
paths scm-1 is now built and installed in /home/bfomitchev/git/distro/install/ (license: BSD)

Missing dependencies for torch:
sys >= 1.0

Using https://raw.githubusercontent.com/torch/rocks/master/sys-1.1-0.rockspec... switching to 'build' mode

Missing dependencies for sys:
torch >= 7.0

Using https://raw.githubusercontent.com/torch/rocks/master/torch-scm-1.rockspec... switching to 'build' mode
Cloning into 'torch7'...

@borisfom
Contributor

Also - sys does use Torch cmake macros, so the build-time dependency is real - sys build would fail if torch7 not installed first - luarocks defect? But yes, can be easily fixed by sys not using torch7 macros.

Please sign in to comment.