diff --git a/Makefile b/Makefile index cbd2c1ce3..24cf349f5 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,6 @@ testfront: $(INSTALL_DIR)/koreader/.busted -rm -rf spec/unit/data/*.sdr cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) \ --sort-files \ - --no-auto-insulate \ --output=gtest \ --exclude-tags=notest $(BUSTED_OVERRIDES) $(BUSTED_SPEC_FILE) @@ -136,7 +135,6 @@ coverage: $(INSTALL_DIR)/koreader/.luacov cd $(INSTALL_DIR)/koreader && \ ./luajit $(shell which busted) --output=gtest \ --sort-files \ - --no-auto-insulate \ --coverage --exclude-tags=nocov # coverage report summary cd $(INSTALL_DIR)/koreader && tail -n \ diff --git a/kodev b/kodev index 4e0510813..4252e7bfb 100755 --- a/kodev +++ b/kodev @@ -758,8 +758,6 @@ OPTIONS: echo "Running tests in" "${test_path}" busted --lua="./luajit" "${opts}" \ - --no-auto-insulate \ - --lazy \ --output=gtest \ --exclude-tags=notest "${test_path}" } && popd || exit @@ -809,8 +807,6 @@ OPTIONS: echo "Running tests in" ${test_path} busted --lua="./luajit" \ --sort-files \ - --no-auto-insulate \ - --lazy \ -o "./spec/${target}/unit/verbose_print" \ --coverage \ --exclude-tags=nocov "${test_path}" || { diff --git a/spec/unit/commonrequire.lua b/spec/unit/commonrequire.lua index 72eb71eed..538bdbc86 100644 --- a/spec/unit/commonrequire.lua +++ b/spec/unit/commonrequire.lua @@ -1,3 +1,14 @@ +-- don't try to overwrite metatables so we can use --auto-insulate-tests +-- shamelessly copied from https://github.com/Olivine-Labs/busted/commit/db6d8b4be8fd099ab387efeb8232cfd905912abb +local ffi = require "ffi" +local old_metatype = ffi.metatype +local exists = {} +ffi.metatype = function(def, mttable) + if exists[def] then return exists[def] end + exists[def] = old_metatype(def, mttable) + return exists[def] +end + require "defaults" package.path = "?.lua;common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath diff --git a/spec/unit/readertoc_spec.lua b/spec/unit/readertoc_spec.lua index 6c160924e..7c011dc1f 100644 --- a/spec/unit/readertoc_spec.lua +++ b/spec/unit/readertoc_spec.lua @@ -1,19 +1,23 @@ describe("Readertoc module", function() - local DocumentRegistry, ReaderUI, DEBUG + local DocumentRegistry, Event, ReaderUI, DEBUG local readerui, toc, toc_max_depth, title setup(function() require("commonrequire") DocumentRegistry = require("document/documentregistry") + Event = require("ui/event") ReaderUI = require("apps/reader/readerui") DEBUG = require("dbg") local sample_epub = "spec/front/unit/data/juliet.epub" + readerui = ReaderUI:new{ document = DocumentRegistry:openDocument(sample_epub), } -- reset book to first page readerui.rolling:onGotoPage(0) + readerui.document:setSpaceCondensing(75) + readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) toc = readerui.toc end) @@ -24,9 +28,9 @@ describe("Readertoc module", function() it("should get toc title from page", function() title = toc:getTocTitleByPage(60) DEBUG("toc", toc.toc) - assert(title == "SCENE V. A hall in Capulet's house.") + assert.is.equal("SCENE V. A hall in Capulet's house.", title) title = toc:getTocTitleByPage(187) - assert(title == "SCENE I. Friar Laurence's cell.") + assert.is.equal("SCENE I. Friar Laurence's cell.", title) end) describe("getTocTicks API", function() local ticks_level_0 = nil