Skip to content

Commit

Permalink
Remove dependency on luasocket
Browse files Browse the repository at this point in the history
This removes the dependency on luasocket by using luasystem for
`gettime`, instead of using `socket.gettime`.
  • Loading branch information
o-lim committed Feb 11, 2016
1 parent 7d75cc1 commit 7d94962
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
1 change: 0 additions & 1 deletion .luacov
Expand Up @@ -46,7 +46,6 @@ return {
'coxpcall$',
'mediator$',
'moonscript.*$',
'socket$',
},


Expand Down
3 changes: 2 additions & 1 deletion busted-2.0.rc11-0.rockspec
Expand Up @@ -21,14 +21,15 @@ dependencies = {
'lua >= 5.1',
'lua_cliargs = 3.0-1',
'luafilesystem >= 1.5.0',
'luasystem >= 0.1.0-0',
'dkjson >= 2.1.0',
'say >= 1.3-0',
'luassert >= 1.7.8-0',
'lua-term >= 0.1-1',
'penlight >= 1.3.2-2',
'mediator_lua >= 1.1.1-0',
'luasocket >= 2.0.1'
}

build = {
type = 'builtin',
modules = {
Expand Down
3 changes: 2 additions & 1 deletion busted-scm-0.rockspec
Expand Up @@ -21,14 +21,15 @@ dependencies = {
'lua >= 5.1',
'lua_cliargs = 3.0-1',
'luafilesystem >= 1.5.0',
'luasystem >= 0.1.0-0',
'dkjson >= 2.1.0',
'say >= 1.3-0',
'luassert >= 1.7.8-0',
'lua-term >= 0.1-1',
'penlight >= 1.3.2-2',
'mediator_lua >= 1.1.1-0',
'luasocket >= 2.0.1'
}

build = {
type = 'builtin',
modules = {
Expand Down
3 changes: 3 additions & 0 deletions busted/core.lua
Expand Up @@ -3,6 +3,7 @@ local setfenv = require 'busted.compatibility'.setfenv
local unpack = require 'busted.compatibility'.unpack
local path = require 'pl.path'
local pretty = require 'pl.pretty'
local system = require 'system'
local throw = error

local failureMt = {
Expand Down Expand Up @@ -56,6 +57,8 @@ return function()
local executors = {}
local eattributes = {}

busted.gettime = system.gettime
busted.sleep = system.sleep
busted.status = require 'busted.status'

function busted.getTrace(element, level, msg)
Expand Down
6 changes: 2 additions & 4 deletions busted/outputHandlers/base.lua
@@ -1,5 +1,3 @@
local socket = require 'socket'

return function()
local busted = require 'busted'
local handler = {
Expand Down Expand Up @@ -85,7 +83,7 @@ return function()
end

handler.baseSuiteStart = function()
handler.startTime = socket.gettime()
handler.startTime = busted.gettime()
return nil, true
end

Expand All @@ -104,7 +102,7 @@ return function()
end

handler.baseSuiteEnd = function()
handler.endTime = socket.gettime()
handler.endTime = busted.gettime()
return nil, true
end

Expand Down
13 changes: 6 additions & 7 deletions busted/outputHandlers/gtest.lua
@@ -1,5 +1,4 @@
local s = require 'say'
local socket = require 'socket'
local pretty = require 'pl.pretty'
local term = require 'term'

Expand Down Expand Up @@ -172,7 +171,7 @@ return function(options)
end

handler.suiteStart = function(suite, count, total, randomseed)
suiteStartTime = socket.gettime()
suiteStartTime = busted.gettime()
if total > 1 then
io.write(repeatSuiteString:format(count, total))
end
Expand All @@ -187,7 +186,7 @@ return function(options)
end

handler.suiteEnd = function(suite, count, total)
local elapsedTime_ms = (socket.gettime() - suiteStartTime) * 1000
local elapsedTime_ms = (busted.gettime() - suiteStartTime) * 1000
local tests = (testCount == 1 and 'test' or 'tests')
local files = (fileCount == 1 and 'file' or 'files')
io.write(globalTeardown)
Expand All @@ -199,15 +198,15 @@ return function(options)
end

handler.fileStart = function(file)
fileStartTime = socket.gettime()
fileStartTime = busted.gettime()
fileTestCount = 0
io.write(fileStartString:format(file.name))
io.flush()
return nil, true
end

handler.fileEnd = function(file)
local elapsedTime_ms = (socket.gettime() - fileStartTime) * 1000
local elapsedTime_ms = (busted.gettime() - fileStartTime) * 1000
local tests = (fileTestCount == 1 and 'test' or 'tests')
fileCount = fileCount + 1
io.write(fileEndString:format(fileTestCount, tests, file.name, elapsedTime_ms))
Expand All @@ -216,15 +215,15 @@ return function(options)
end

handler.testStart = function(element, parent)
testStartTime = socket.gettime()
testStartTime = busted.gettime()
io.write(runString:format(getFullName(element)))
io.flush()

return nil, true
end

handler.testEnd = function(element, parent, status, debug)
local elapsedTime_ms = (socket.gettime() - testStartTime) * 1000
local elapsedTime_ms = (busted.gettime() - testStartTime) * 1000
local string

fileTestCount = fileTestCount + 1
Expand Down
9 changes: 4 additions & 5 deletions busted/outputHandlers/junit.lua
@@ -1,12 +1,11 @@
local xml = require 'pl.xml'
local socket = require("socket")
local string = require("string")

return function(options)
local busted = require 'busted'
local handler = require 'busted.outputHandlers.base'()
local top = {
start_time = socket.gettime(),
start_time = busted.gettime(),
xml_doc = xml.new('testsuites', {
tests = 0,
errors = 0,
Expand All @@ -20,7 +19,7 @@ return function(options)

handler.suiteStart = function(suite, count, total)
local suite = {
start_time = socket.gettime(),
start_time = busted.gettime(),
xml_doc = xml.new('testsuite', {
name = 'Run ' .. count .. ' of ' .. total,
tests = 0,
Expand All @@ -38,7 +37,7 @@ return function(options)
end

local function elapsed(start_time)
return string.format("%.2f", (socket.gettime() - start_time))
return string.format("%.2f", (busted.gettime() - start_time))
end

handler.suiteEnd = function(suite, count, total)
Expand Down Expand Up @@ -74,7 +73,7 @@ return function(options)
end

handler.testStart = function(element, parent)
testStartTime = socket.gettime()
testStartTime = busted.gettime()
testcase_node = xml.new('testcase', {
classname = element.trace.short_src .. ':' .. element.trace.currentline,
name = handler.getFullName(element),
Expand Down

0 comments on commit 7d94962

Please sign in to comment.