Merge pull request #956 from chrox/coverage

code coverage target for the unit test
This commit is contained in:
Qingping Hou
2014-10-06 21:07:17 -07:00
9 changed files with 93 additions and 19 deletions

58
.luacov Normal file
View File

@@ -0,0 +1,58 @@
--- Global configuration file. Copy, customize and store in your
-- project folder as '.luacov' for project specific configuration
-- @class module
-- @name luacov.defaults
return {
-- default filename to load for config options if not provided
-- only has effect in 'luacov.defaults.lua'
['configfile'] = '.luacov',
-- filename to store stats collected
['statsfile'] = 'luacov.stats.out',
-- filename to store report
['reportfile'] = 'luacov.report.out',
-- Run reporter on completion? (won't work for ticks)
runreport = true,
-- Delete stats file after reporting?
deletestats = false,
-- Patterns for files to include when reporting
-- all will be included if nothing is listed
-- (exclude overrules include, do not include
-- the .lua extension)
['include'] = {
},
-- Patterns for files to exclude when reporting
-- all will be included if nothing is listed
-- (exclude overrules include, do not include
-- the .lua extension)
['exclude'] = {
'luacov$',
'luacov.reporter$',
'luacov.defaults$',
'luacov.runner$',
'luacov.stats$',
'luacov.tick$',
'ansicolors$',
'copas$',
'coxpcall$',
'mediator$',
'moonscript.*$',
'socket$',
'busted.*$',
'luassert.*$',
'pl/.*$',
'say.init$',
'ffi/.*_h$',
'common/.*$',
'JSON',
'MD5',
},
}

View File

@@ -16,8 +16,14 @@ install:
- sudo apt-get install libsdl1.2-dev luarocks
- git clone https://github.com/Olivine-Labs/busted/
- cd busted && git checkout v1.10.0 && sudo luarocks make && cd ..
- sudo luarocks install luacov
- sudo luarocks install luacov-coveralls --server=http://rocks.moonscript.org/dev
script:
- make fetchthirdparty
- make
- make fetchthirdparty all
- sudo cp base/build/*/luajit /usr/bin/
- make testfront
- make coverage
after_success:
- cd koreader-*/koreader && luacov-coveralls -v

View File

@@ -82,6 +82,10 @@ $(INSTALL_DIR)/koreader/.busted:
test -e $(INSTALL_DIR)/koreader/.busted || \
ln -sf ../../.busted $(INSTALL_DIR)/koreader
$(INSTALL_DIR)/koreader/.luacov:
test -e $(INSTALL_DIR)/koreader/.luacov || \
ln -sf ../../.luacov $(INSTALL_DIR)/koreader
testfront: $(INSTALL_DIR)/koreader/.busted
cd $(INSTALL_DIR)/koreader && busted -l ./luajit
@@ -89,6 +93,13 @@ test:
$(MAKE) -C $(KOR_BASE) test
$(MAKE) testfront
coverage: $(INSTALL_DIR)/koreader/.luacov
cd $(INSTALL_DIR)/koreader && busted -c -l ./luajit --exclude-tags=nocov
# coverage report summary
cd $(INSTALL_DIR)/koreader && tail -n \
+$$(($$(grep -nm1 Summary luacov.report.out|cut -d: -f1)-1)) \
luacov.report.out
.PHONY: test
fetchthirdparty:

View File

@@ -1,4 +1,4 @@
KOReader [![Build Status][travis-icon]][travis-link]
KOReader [![Build Status][travis-icon]][travis-link] [![Coverage Status][coverage-icon]][coverage-link]
========
KOReader is a document viewer application, originally created for Kindle
@@ -189,4 +189,5 @@ http://ccache.samba.org
[linux-vm]:http://www.howtogeek.com/howto/11287/how-to-run-ubuntu-in-windows-7-with-vmware-player/
[l10n-readme]:https://github.com/koreader/koreader/blob/master/l10n/README.md
[koreader-transifex]:https://www.transifex.com/projects/p/koreader/
[coverage-icon]:https://coveralls.io/repos/koreader/koreader/badge.png
[coverage-link]:https://coveralls.io/r/koreader/koreader

View File

@@ -345,11 +345,8 @@ function Input:init()
self.event_map[10021] = "NotCharging"
if util.isEmulated() then
if not util.isWindows() then
os.remove("/tmp/emu_event")
os.execute("mkfifo /tmp/emu_event")
input.open("/tmp/emu_event")
end
-- open SDL if it's not dummy input device
if not self.dummy then input.open() end
-- SDL key codes
if not util.haveSDL2() then
self.event_map = self.sdl_event_map

View File

@@ -1,6 +1,6 @@
require "defaults"
package.path = "?.lua;common/?.lua;frontend/?.lua"
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so"
package.path = "?.lua;common/?.lua;frontend/?.lua;" .. package.path
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so;" .. package.cpath
require "libs/libkoreader-lfs"
-- global einkfb for Screen
@@ -26,22 +26,23 @@ describe("Cache module", function()
it("should clear cache", function()
Cache:clear()
end)
local max_page = 1
it("should serialize blitbuffer", function()
for pageno = 1, math.min(10, doc.info.number_of_pages) do
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
Cache:serialize()
end
Cache:clear()
end)
it("should deserialize blitbuffer", function()
for pageno = 1, math.min(10, doc.info.number_of_pages) do
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
doc:hintPage(pageno, 1, 0, 1.0, 0)
end
Cache:clear()
end)
it("should serialize koptcontext", function()
doc.configurable.text_wrap = 1
for pageno = 1, math.min(10, doc.info.number_of_pages) do
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
doc:getPageDimensions(pageno)
Cache:serialize()
@@ -49,7 +50,7 @@ describe("Cache module", function()
Cache:clear()
end)
it("should deserialize koptcontext", function()
for pageno = 1, math.min(10, doc.info.number_of_pages) do
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
end
Cache:clear()

View File

@@ -1,6 +1,6 @@
require "defaults"
package.path = "?.lua;common/?.lua;frontend/?.lua"
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so"
package.path = "?.lua;common/?.lua;frontend/?.lua;" .. package.path
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so;" .. package.cpath
-- global einkfb for Screen
einkfb = require("ffi/framebuffer")

View File

@@ -155,13 +155,13 @@ Title:
</feed>
]]
package.path = "?.lua;common/?.lua;frontend/?.lua"
package.path = "?.lua;common/?.lua;frontend/?.lua;" .. package.path
local OPDSParser = require("ui/opdsparser")
local DEBUG = require("dbg")
DEBUG:turnOn()
describe("OPDS parser module", function()
describe("OPDS parser module #nocov", function()
it("should parse OPDS navigation catalog", function()
local catalog = OPDSParser:parse(navigation_sample)
local feed = catalog.feed