Skip to content

Commit

Permalink
Replace torch.Tester with totem.Tester + extra stuff.
Browse files Browse the repository at this point in the history
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
davidsaxton committed Feb 25, 2016
1 parent 3bbb49f commit d8ff64c
Show file tree
Hide file tree
Showing 12 changed files with 1,775 additions and 292 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -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)
Expand Down
30 changes: 30 additions & 0 deletions TestSuite.lua
@@ -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

4 comments on commit d8ff64c

@borisfom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indroduced circular dependency sys <->torch7.

@soumith
Copy link
Member

@soumith soumith commented on d8ff64c Mar 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@borisfom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.