From 429eeed3728ff9db997d11dcf337512739640e21 Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 7 Oct 2015 15:14:27 +0800 Subject: [PATCH] verbose unit test log so that we have a clue when there is segfault --- .travis.yml | 1 + Makefile | 2 +- spec/unit/verbose_print.lua | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 spec/unit/verbose_print.lua diff --git a/.travis.yml b/.travis.yml index 2ee0b22ba..c9a2947a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,7 @@ install: - cp /etc/luarocks/config.lua $HOME/.luarocks/config.lua - echo "wrap_bin_scripts = false" >> $HOME/.luarocks/config.lua - travis_retry luarocks --local install lua_cliargs + - travis_retry luarocks --local install ansicolors - travis_retry luarocks --local install busted #- travis_retry luarocks --local install busted 1.11.1-1 #- mv -f $HOME/.luarocks/bin/busted_bootstrap $HOME/.luarocks/bin/busted diff --git a/Makefile b/Makefile index 58db7b5c1..35a40972a 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ $(INSTALL_DIR)/koreader/.luacov: ln -sf ../../.luacov $(INSTALL_DIR)/koreader testfront: $(INSTALL_DIR)/koreader/.busted - cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) --exclude-tags=notest + cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) -o verbose_print --exclude-tags=notest test: $(MAKE) -C $(KOR_BASE) test diff --git a/spec/unit/verbose_print.lua b/spec/unit/verbose_print.lua new file mode 100644 index 000000000..f194a8dbe --- /dev/null +++ b/spec/unit/verbose_print.lua @@ -0,0 +1,22 @@ +-- from Mashape/kong/spec/busted-print.lua +local ansicolors = require 'ansicolors' + +return function(options) + local handler = require 'busted.outputHandlers.utfTerminal'(options) + + handler.fileStart = function(file) + io.write('\n' .. ansicolors('%{cyan}' .. file.name) .. ':') + end + + handler.testStart = function(element, parent, status, debug) + io.write('\n ' .. handler.getFullName(element) .. ' ... ') + io.flush() + end + + local busted = require 'busted' + + busted.subscribe({ 'file', 'start' }, handler.fileStart) + busted.subscribe({ 'test', 'start' }, handler.testStart) + + return handler +end