diff --git a/.luacov b/.luacov new file mode 100644 index 000000000..656b1cef0 --- /dev/null +++ b/.luacov @@ -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', + }, + + +} diff --git a/.travis.yml b/.travis.yml index ca0ac94f4..61d8613e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Makefile b/Makefile index 732fe99c8..d0247c0e7 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/README.md b/README.md index fea2fd372..5bbbd20b7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/frontend/ui/input.lua b/frontend/ui/input.lua index 5e0c457d4..5db69b84a 100644 --- a/frontend/ui/input.lua +++ b/frontend/ui/input.lua @@ -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 diff --git a/spec/unit/benchmark_spec.lua b/spec/unit/benchmark.lua similarity index 100% rename from spec/unit/benchmark_spec.lua rename to spec/unit/benchmark.lua diff --git a/spec/unit/cache_spec.lua b/spec/unit/cache_spec.lua index f32ff3f8e..d6f909173 100644 --- a/spec/unit/cache_spec.lua +++ b/spec/unit/cache_spec.lua @@ -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() diff --git a/spec/unit/document_spec.lua b/spec/unit/document_spec.lua index ca84cbeda..53c454de3 100644 --- a/spec/unit/document_spec.lua +++ b/spec/unit/document_spec.lua @@ -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") diff --git a/spec/unit/opdsparser_spec.lua b/spec/unit/opdsparser_spec.lua index 2e54cdcc6..ef4fca8f8 100644 --- a/spec/unit/opdsparser_spec.lua +++ b/spec/unit/opdsparser_spec.lua @@ -155,13 +155,13 @@ Title: ]] -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