diff --git a/testing/classes/TestMethod.lua b/testing/classes/TestMethod.lua
index b0c763082..8fa55080f 100644
--- a/testing/classes/TestMethod.lua
+++ b/testing/classes/TestMethod.lua
@@ -189,14 +189,23 @@ TestMethod = {
-- @param {table} obj - table to check is a valid love object
-- @return {nil}
assertObject = function(self, obj)
- self:assertNotEquals(nil, obj, 'check not nill')
+ self:assertNotNil(obj)
self:assertEquals('userdata', type(obj), 'check is userdata')
- if obj ~= nil then
+ if obj ~= nil then
self:assertNotEquals(nil, obj:type(), 'check has :type()')
end
end,
+ -- @method - TestMethod:assertNotNil()
+ -- @desc - quick assert for value not nil
+ -- @param {any} value - value to check not nil
+ -- @return {nil}
+ assertNotNil = function (self, value)
+ self:assertNotEquals(nil, value, 'check not nil')
+ end,
+
+
-- @method - TestMethod:skipTest()
-- @desc - used to mark this test as skipped for a specific reason
@@ -289,10 +298,7 @@ TestMethod = {
self.finish = love.timer.getTime() - self.start
love.test.time = love.test.time + self.finish
self.testmodule.time = self.testmodule.time + self.finish
- local endtime = tostring(math.floor((love.timer.getTime() - self.start)*1000))
- if string.len(endtime) == 1 then endtime = ' ' .. endtime end
- if string.len(endtime) == 2 then endtime = ' ' .. endtime end
- if string.len(endtime) == 3 then endtime = ' ' .. endtime end
+ local endtime = UtilTimeFormat(love.timer.getTime() - self.start)
-- get failure/skip message for output (if any)
local failure = ''
@@ -309,7 +315,7 @@ TestMethod = {
-- append XML for the test class result
self.testmodule.xml = self.testmodule.xml .. '\t\t\n' ..
+ '" time="' .. endtime .. '">\n' ..
failure .. '\t\t\n'
-- unused currently, adds a preview image for certain graphics methods to the output
@@ -329,7 +335,7 @@ TestMethod = {
'
' ..
'| ' .. status .. ' | ' ..
'' .. self.method .. ' | ' ..
- '' .. tostring(self.finish*1000) .. 'ms | ' ..
+ '' .. endtime .. 's | ' ..
'' .. output .. preview .. ' | ' ..
'
'
@@ -350,10 +356,10 @@ TestMethod = {
self.testmodule:log(
self.testmodule.colors[self.result.result],
' ' .. tested .. matching,
- ' ==> ' .. self.result.result .. ' - ' .. endtime .. 'ms ' ..
+ ' ==> ' .. self.result.result .. ' - ' .. endtime .. 's ' ..
self.result.total .. msg
)
end
-}
\ No newline at end of file
+}
diff --git a/testing/classes/TestModule.lua b/testing/classes/TestModule.lua
index 379aac360..9ee6cd62e 100644
--- a/testing/classes/TestModule.lua
+++ b/testing/classes/TestModule.lua
@@ -83,12 +83,13 @@ TestModule = {
-- the XML + HTML for the test to the testsuite output
-- @return {nil}
printResult = function(self)
+ local finaltime = UtilTimeFormat(self.time)
-- add xml to main output
love.test.xml = love.test.xml .. '\t\n' .. self.xml .. '\t\n'
+ '" time="' .. finaltime .. '">\n' .. self.xml .. '\t\n'
-- add html to main output
local status = '🔴'
if self.failed == 0 then status = '🟢' end
@@ -96,8 +97,8 @@ TestModule = {
'🟢 ' .. tostring(self.passed) .. ' Tests' ..
'🔴 ' .. tostring(self.failed) .. ' Failures' ..
'🟡 ' .. tostring(self.skipped) .. ' Skipped' ..
- '' .. tostring(self.time*1000) .. 'ms' .. '
' ..
- ' | Method | Time | Details |
' ..
+ '- ' .. finaltime .. 's
' .. '
' ..
+ ' | Method | Time | Details |
' ..
self.html .. '
'
-- print module results to console
self:log('yellow', 'love.' .. self.module .. '.testmodule.end')
@@ -105,10 +106,10 @@ TestModule = {
if self.failed == 0 then failedcol = '\27[37m' end
self:log('green', tostring(self.passed) .. ' PASSED' .. ' || ' ..
failedcol .. tostring(self.failed) .. ' FAILED || \27[37m' ..
- tostring(self.skipped) .. ' SKIPPED')
+ tostring(self.skipped) .. ' SKIPPED || ' .. finaltime .. 's')
self.start = false
self.fakequit = false
end
-}
\ No newline at end of file
+}
diff --git a/testing/classes/TestSuite.lua b/testing/classes/TestSuite.lua
index 234019c8f..9552b5aee 100644
--- a/testing/classes/TestSuite.lua
+++ b/testing/classes/TestSuite.lua
@@ -10,7 +10,7 @@ TestSuite = {
-- testsuite internals
modules = {},
module = nil,
- testcanvas = love.graphics.newCanvas(16, 16),
+ testcanvas = nil,
current = 1,
output = '',
totals = {0, 0, 0},
@@ -91,6 +91,9 @@ TestSuite = {
test.fatal = tostring(chunk) .. tostring(err)
end
end
+ -- save having to :release() anything we made in the last test
+ -- 7251ms > 7543ms
+ collectgarbage("collect")
-- move onto the next test
self.module.index = self.module.index + 1
end
@@ -124,15 +127,12 @@ TestSuite = {
-- the XML + HTML of the testsuite output
-- @return {nil}
printResult = function(self)
- local finaltime = tostring(math.floor(self.time*1000))
- if string.len(finaltime) == 1 then finaltime = ' ' .. finaltime end
- if string.len(finaltime) == 2 then finaltime = ' ' .. finaltime end
- if string.len(finaltime) == 3 then finaltime = ' ' .. finaltime end
+ local finaltime = UtilTimeFormat(self.time)
local xml = '\n'
+ '" time="' .. finaltime .. '">\n'
local status = '🔴'
if self.totals[2] == 0 then status = '🟢' end
@@ -141,14 +141,14 @@ TestSuite = {
'- 🟢 ' .. tostring(self.totals[1]) .. ' Tests
' ..
'- 🔴 ' .. tostring(self.totals[2]) .. ' Failures
' ..
'- 🟡 ' .. tostring(self.totals[3]) .. ' Skipped
' ..
- '- ' .. tostring(self.time*1000) .. 'ms
'
+ '- ' .. finaltime .. 's
'
-- @TODO use mountFullPath to write output to src?
love.filesystem.createDirectory('output')
love.filesystem.write('output/' .. self.output .. '.xml', xml .. self.xml .. '')
love.filesystem.write('output/' .. self.output .. '.html', html .. self.html .. '