mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[spec] Better insulation (#4972)
Some combination of Travis and/or older Busted necessitated insufficient insulation. Follow-up to https://github.com/koreader/koreader/pull/4970 Space condensing carried over; reset at the start of readertoc.
This commit is contained in:
2
Makefile
2
Makefile
@@ -123,7 +123,6 @@ testfront: $(INSTALL_DIR)/koreader/.busted
|
|||||||
-rm -rf spec/unit/data/*.sdr
|
-rm -rf spec/unit/data/*.sdr
|
||||||
cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) \
|
cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) \
|
||||||
--sort-files \
|
--sort-files \
|
||||||
--no-auto-insulate \
|
|
||||||
--output=gtest \
|
--output=gtest \
|
||||||
--exclude-tags=notest $(BUSTED_OVERRIDES) $(BUSTED_SPEC_FILE)
|
--exclude-tags=notest $(BUSTED_OVERRIDES) $(BUSTED_SPEC_FILE)
|
||||||
|
|
||||||
@@ -136,7 +135,6 @@ coverage: $(INSTALL_DIR)/koreader/.luacov
|
|||||||
cd $(INSTALL_DIR)/koreader && \
|
cd $(INSTALL_DIR)/koreader && \
|
||||||
./luajit $(shell which busted) --output=gtest \
|
./luajit $(shell which busted) --output=gtest \
|
||||||
--sort-files \
|
--sort-files \
|
||||||
--no-auto-insulate \
|
|
||||||
--coverage --exclude-tags=nocov
|
--coverage --exclude-tags=nocov
|
||||||
# coverage report summary
|
# coverage report summary
|
||||||
cd $(INSTALL_DIR)/koreader && tail -n \
|
cd $(INSTALL_DIR)/koreader && tail -n \
|
||||||
|
|||||||
4
kodev
4
kodev
@@ -758,8 +758,6 @@ OPTIONS:
|
|||||||
|
|
||||||
echo "Running tests in" "${test_path}"
|
echo "Running tests in" "${test_path}"
|
||||||
busted --lua="./luajit" "${opts}" \
|
busted --lua="./luajit" "${opts}" \
|
||||||
--no-auto-insulate \
|
|
||||||
--lazy \
|
|
||||||
--output=gtest \
|
--output=gtest \
|
||||||
--exclude-tags=notest "${test_path}"
|
--exclude-tags=notest "${test_path}"
|
||||||
} && popd || exit
|
} && popd || exit
|
||||||
@@ -809,8 +807,6 @@ OPTIONS:
|
|||||||
echo "Running tests in" ${test_path}
|
echo "Running tests in" ${test_path}
|
||||||
busted --lua="./luajit" \
|
busted --lua="./luajit" \
|
||||||
--sort-files \
|
--sort-files \
|
||||||
--no-auto-insulate \
|
|
||||||
--lazy \
|
|
||||||
-o "./spec/${target}/unit/verbose_print" \
|
-o "./spec/${target}/unit/verbose_print" \
|
||||||
--coverage \
|
--coverage \
|
||||||
--exclude-tags=nocov "${test_path}" || {
|
--exclude-tags=nocov "${test_path}" || {
|
||||||
|
|||||||
@@ -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"
|
require "defaults"
|
||||||
package.path = "?.lua;common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
|
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
|
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
describe("Readertoc module", function()
|
describe("Readertoc module", function()
|
||||||
local DocumentRegistry, ReaderUI, DEBUG
|
local DocumentRegistry, Event, ReaderUI, DEBUG
|
||||||
local readerui, toc, toc_max_depth, title
|
local readerui, toc, toc_max_depth, title
|
||||||
|
|
||||||
setup(function()
|
setup(function()
|
||||||
require("commonrequire")
|
require("commonrequire")
|
||||||
DocumentRegistry = require("document/documentregistry")
|
DocumentRegistry = require("document/documentregistry")
|
||||||
|
Event = require("ui/event")
|
||||||
ReaderUI = require("apps/reader/readerui")
|
ReaderUI = require("apps/reader/readerui")
|
||||||
DEBUG = require("dbg")
|
DEBUG = require("dbg")
|
||||||
|
|
||||||
local sample_epub = "spec/front/unit/data/juliet.epub"
|
local sample_epub = "spec/front/unit/data/juliet.epub"
|
||||||
|
|
||||||
readerui = ReaderUI:new{
|
readerui = ReaderUI:new{
|
||||||
document = DocumentRegistry:openDocument(sample_epub),
|
document = DocumentRegistry:openDocument(sample_epub),
|
||||||
}
|
}
|
||||||
-- reset book to first page
|
-- reset book to first page
|
||||||
readerui.rolling:onGotoPage(0)
|
readerui.rolling:onGotoPage(0)
|
||||||
|
readerui.document:setSpaceCondensing(75)
|
||||||
|
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
|
||||||
toc = readerui.toc
|
toc = readerui.toc
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -24,9 +28,9 @@ describe("Readertoc module", function()
|
|||||||
it("should get toc title from page", function()
|
it("should get toc title from page", function()
|
||||||
title = toc:getTocTitleByPage(60)
|
title = toc:getTocTitleByPage(60)
|
||||||
DEBUG("toc", toc.toc)
|
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)
|
title = toc:getTocTitleByPage(187)
|
||||||
assert(title == "SCENE I. Friar Laurence's cell.")
|
assert.is.equal("SCENE I. Friar Laurence's cell.", title)
|
||||||
end)
|
end)
|
||||||
describe("getTocTicks API", function()
|
describe("getTocTicks API", function()
|
||||||
local ticks_level_0 = nil
|
local ticks_level_0 = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user