Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions busted-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ description = {
dependencies = {
'lua >= 5.1',
'lua_cliargs >= 3.0',
'luasystem >= 0.2.0',
'luasystem >= 0.3.0',
'dkjson >= 2.1.0',
'say >= 1.4-1',
'luassert >= 1.9.0-1',
'lua-term >= 0.1',
'penlight >= 1.15.0',
'mediator_lua >= 1.1.1',
}
Expand Down Expand Up @@ -90,6 +89,7 @@ build = {
['busted.outputHandlers.TAP'] = 'busted/outputHandlers/TAP.lua',
['busted.outputHandlers.json'] = 'busted/outputHandlers/json.lua',
['busted.outputHandlers.junit'] = 'busted/outputHandlers/junit.lua',
['busted.outputHandlers.colors'] = 'busted/outputHandlers/colors.lua',
['busted.outputHandlers.gtest'] = 'busted/outputHandlers/gtest.lua',
['busted.outputHandlers.sound'] = 'busted/outputHandlers/sound.lua',

Expand Down
65 changes: 65 additions & 0 deletions busted/outputHandlers/colors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- fork of the lua-term's colors.lua, check it out: https://github.com/hoelzro/lua-term/blob/master/term/colors.lua

local pairs = pairs
local tostring = tostring
local setmetatable = setmetatable
local schar = string.char

local colors = {}

local colormt = {}

function colormt:__tostring()
return self.value
end

function colormt:__concat(other)
return tostring(self) .. tostring(other)
end

function colormt:__call(s)
return self .. s .. colors.reset
end

local function makecolor(value)
return setmetatable({ value = schar(27) .. '[' .. tostring(value) .. 'm' }, colormt)
end

local colorvalues = {
-- attributes
reset = 0,
clear = 0,
default = 0,
bright = 1,
dim = 2,
underscore = 4,
blink = 5,
reverse = 7,
hidden = 8,

-- foreground
black = 30,
red = 31,
green = 32,
yellow = 33,
blue = 34,
magenta = 35,
cyan = 36,
white = 37,

-- background
onblack = 40,
onred = 41,
ongreen = 42,
onyellow = 43,
onblue = 44,
onmagenta = 45,
oncyan = 46,
onwhite = 47,
}

for c, v in pairs(colorvalues) do
colors[c] = makecolor(v)
end

return colors
8 changes: 4 additions & 4 deletions busted/outputHandlers/gtest.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local pretty = require 'pl.pretty'
local term = require 'term'
local system = require 'system'
local luassert = require 'luassert'
local io = io
local type = type
Expand All @@ -9,7 +9,7 @@ local io_write = io.write
local io_flush = io.flush
local colors

local isatty = io.type(io.stdout) == 'file' and term.isatty(io.stdout)
local isatty = io.type(io.stdout) == 'file' and system.isatty(io.stdout)

return function(options)
local busted = require 'busted'
Expand All @@ -34,7 +34,7 @@ return function(options)
luassert:set_parameter("TableErrorHighlightColor", "none")

elseif cliArgs.color then
colors = require 'term.colors'
colors = require 'busted.outputHandlers.colors'
luassert:set_parameter("TableErrorHighlightColor", "red")

else
Expand All @@ -43,7 +43,7 @@ return function(options)
colors = setmetatable({}, {__index = function() return function(s) return s end end})
luassert:set_parameter("TableErrorHighlightColor", "none")
else
colors = require 'term.colors'
colors = require 'busted.outputHandlers.colors'
luassert:set_parameter("TableErrorHighlightColor", "red")
end
end
Expand Down
8 changes: 4 additions & 4 deletions busted/outputHandlers/utfTerminal.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local s = require 'say'
local pretty = require 'pl.pretty'
local term = require 'term'
local system = require 'system'
local luassert = require 'luassert'
local io = io
local type = type
Expand All @@ -11,7 +11,7 @@ local io_flush = io.flush
local pairs = pairs
local colors

local isatty = io.type(io.stdout) == 'file' and term.isatty(io.stdout)
local isatty = io.type(io.stdout) == 'file' and system.isatty(io.stdout)

return function(options)
local busted = require 'busted'
Expand All @@ -35,7 +35,7 @@ return function(options)
luassert:set_parameter("TableErrorHighlightColor", "none")

elseif cliArgs.color then
colors = require 'term.colors'
colors = require 'busted.outputHandlers.colors'
luassert:set_parameter("TableErrorHighlightColor", "red")

else
Expand All @@ -44,7 +44,7 @@ return function(options)
colors = setmetatable({}, {__index = function() return function(s) return s end end})
luassert:set_parameter("TableErrorHighlightColor", "none")
else
colors = require 'term.colors'
colors = require 'busted.outputHandlers.colors'
luassert:set_parameter("TableErrorHighlightColor", "red")
end
end
Expand Down
4 changes: 2 additions & 2 deletions busted/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ return function(options)

local path = require 'pl.path'
local tablex = require 'pl.tablex'
local term = require 'term'
local system = require 'system'

local isatty = io.type(io.stdout) == 'file' and term.isatty(io.stdout)
local isatty = io.type(io.stdout) == 'file' and system.isatty(io.stdout)
options = tablex.update(require 'busted.options', options or {})
options.output = options.output or (isatty and 'utfTerminal' or 'plainTerminal')

Expand Down