From 2316b253176ab1b4410da02955b311778e6f00a9 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Sun, 10 Jul 2016 01:48:37 +0300 Subject: [PATCH] Give more details on unit test output This adds an output handler for Busted which reuses the built-in "utfTerminal" handler, and augments it by showing the name of each suite/test as it is run. --- .busted | 1 + spec/detailUtfTerm.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 spec/detailUtfTerm.lua diff --git a/.busted b/.busted index 03ce4cc..e4be841 100644 --- a/.busted +++ b/.busted @@ -2,5 +2,6 @@ return { _all = { verbose = true, + output = "spec.detailUtfTerm", } } diff --git a/spec/detailUtfTerm.lua b/spec/detailUtfTerm.lua new file mode 100644 index 0000000..6c3789a --- /dev/null +++ b/spec/detailUtfTerm.lua @@ -0,0 +1,28 @@ +#! /usr/bin/env lua +-- +-- detailUtfTerm.lua +-- Copyright (C) 2016 Adrian Perez +-- +-- Distributed under terms of the MIT license. +-- + +local colors = require 'term.colors' + +return function(options) + local busted = require 'busted' + local handler = require 'busted.outputHandlers.utfTerminal' (options) + + handler.fileStart = function(element) + io.write("\n" .. colors.cyan(handler.getFullName(element)) .. ':') + end + + handler.testStart = function(element, parent, status, debug) + io.write('\n ' .. handler.getFullName(element) .. '\r ') + io.flush() + end + + busted.subscribe({ 'file', 'start' }, handler.fileStart) + busted.subscribe({ 'test', 'start' }, handler.testStart) + + return handler +end