diff --git a/.ci/script.sh b/.ci/script.sh index b06bd338a..5a539b0ca 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -10,7 +10,7 @@ travis_retry make fetchthirdparty "${CI_DIR}/helper_shellchecks.sh" echo -e "\n${ANSI_GREEN}Luacheck results" -luajit "$(which luacheck)" --no-color -q {reader,setupkoenv,datastorage}.lua frontend plugins +luajit "$(which luacheck)" --no-color -q {reader,setupkoenv,datastorage}.lua frontend plugins spec echo -e "\n${ANSI_GREEN}make all" make all diff --git a/.luacheckrc b/.luacheckrc index 6bc2ab784..946d1a9bf 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -102,5 +102,15 @@ exclude_files = { "plugins/newsdownloader.koplugin/lib/xml.lua", } +-- don't balk on busted stuff in spec +files["spec/unit/*"].std = "+busted" +files["spec/unit/*"].globals = { + "package", + "assertAlmostEquals", + "assertNotAlmostEquals", + "requireBackgroundRunner", + "stopBackgroundRunner", +} + -- TODO: clean up and enforce max line width (631) ignore = {"631"} diff --git a/spec/unit/autosuspend_spec.lua b/spec/unit/autosuspend_spec.lua index ad07e3548..bb1416a4b 100644 --- a/spec/unit/autosuspend_spec.lua +++ b/spec/unit/autosuspend_spec.lua @@ -26,7 +26,7 @@ describe("AutoSuspend widget tests", function() it("should be able to execute suspend when timing out", function() local mock_time = require("mock_time") local widget_class = dofile("plugins/autosuspend.koplugin/main.lua") - local widget = widget_class:new() + local widget = widget_class:new() --luacheck: ignore local UIManager = require("ui/uimanager") mock_time:increase(5) UIManager:handleInput() @@ -41,10 +41,10 @@ describe("AutoSuspend widget tests", function() local mock_time = require("mock_time") -- AutoSuspend plugin set the last_action_sec each time it is initialized. local widget_class = dofile("plugins/autosuspend.koplugin/main.lua") - local widget1 = widget_class:new() + local widget1 = widget_class:new() --luacheck: ignore -- So if one more initialization happens, it won't sleep after another 5 seconds. mock_time:increase(5) - local widget2 = widget_class:new() + local widget2 = widget_class:new() --luacheck: ignore local UIManager = require("ui/uimanager") mock_time:increase(6) UIManager:handleInput() diff --git a/spec/unit/background_runner_spec.lua b/spec/unit/background_runner_spec.lua index ff31f32d6..eab9cbe9f 100644 --- a/spec/unit/background_runner_spec.lua +++ b/spec/unit/background_runner_spec.lua @@ -217,7 +217,6 @@ describe("BackgroundRunner widget tests", function() end) it("should block long binary job", function() - local executed = 0 local job = { when = 1, repeated = true, diff --git a/spec/unit/batterystat_spec.lua b/spec/unit/batterystat_spec.lua index cb287e989..3c5062e97 100644 --- a/spec/unit/batterystat_spec.lua +++ b/spec/unit/batterystat_spec.lua @@ -1,7 +1,7 @@ describe("BatteryState plugin tests", function() local MockTime, module - local stat = function() + local stat = function() --luacheck: ignore return module:new():stat() end, diff --git a/spec/unit/benchmark.lua b/spec/unit/benchmark.lua index 79732b8d8..d2f31c62a 100644 --- a/spec/unit/benchmark.lua +++ b/spec/unit/benchmark.lua @@ -2,7 +2,7 @@ require("commonrequire") local DocumentRegistry = require("document/documentregistry") local util = require("ffi/util") -function logDuration(filename, pageno, dur) +local function logDuration(filename, pageno, dur) local file = io.open(filename, "a+") if file then if file:seek("end") == 0 then -- write the header only once diff --git a/spec/unit/cache_spec.lua b/spec/unit/cache_spec.lua index 4ed7597e6..a502e1e2b 100644 --- a/spec/unit/cache_spec.lua +++ b/spec/unit/cache_spec.lua @@ -1,12 +1,11 @@ describe("Cache module", function() - local DocumentRegistry, Cache, DEBUG + local DocumentRegistry, Cache local doc local max_page = 1 setup(function() require("commonrequire") DocumentRegistry = require("document/documentregistry") Cache = require("cache") - DEBUG = require("dbg") local sample_pdf = "spec/front/unit/data/sample.pdf" doc = DocumentRegistry:openDocument(sample_pdf) diff --git a/spec/unit/commonrequire.lua b/spec/unit/commonrequire.lua index bb72cc0a6..bdac7dff4 100644 --- a/spec/unit/commonrequire.lua +++ b/spec/unit/commonrequire.lua @@ -10,12 +10,11 @@ logger:setLevel(logger.levels.warn) -- global reader settings local DataStorage = require("datastorage") os.remove(DataStorage:getDataDir().."/settings.reader.lua") -local DocSettings = require("docsettings") G_reader_settings = require("luasettings"):open(".reader") -- global einkfb for Screen (do not show SDL window) -einkfb = require("ffi/framebuffer") -einkfb.dummy = true +einkfb = require("ffi/framebuffer") --luacheck: ignore +einkfb.dummy = true --luacheck: ignore -- init output device local Screen = require("device").screen diff --git a/spec/unit/dbg_spec.lua b/spec/unit/dbg_spec.lua index 001a23e70..45c399b06 100644 --- a/spec/unit/dbg_spec.lua +++ b/spec/unit/dbg_spec.lua @@ -54,7 +54,8 @@ describe("Dbg module", function() end) it("should return all values returned by the guarded function", function() - local called = false, re + local called = false + local re local foo = {} function foo:bar() return 1 end assert.is.falsy(called) diff --git a/spec/unit/depgraph_spec.lua b/spec/unit/depgraph_spec.lua index 932847e49..66241c592 100644 --- a/spec/unit/depgraph_spec.lua +++ b/spec/unit/depgraph_spec.lua @@ -1,8 +1,7 @@ describe("DepGraph module", function() - local DepGraph, logger + local DepGraph setup(function() require("commonrequire") - logger = require("logger") DepGraph = require("depgraph") end) diff --git a/spec/unit/device_spec.lua b/spec/unit/device_spec.lua index 3aa1a0224..ae35aa939 100644 --- a/spec/unit/device_spec.lua +++ b/spec/unit/device_spec.lua @@ -1,4 +1,5 @@ describe("device module", function() + -- luacheck: push ignore local mock_fb, mock_input local iopen = io.open local osgetenv = os.getenv @@ -286,4 +287,5 @@ describe("device module", function() UIManager.onRotation:revert() end) end) + -- luacheck: pop end) diff --git a/spec/unit/frontlight_spec.lua b/spec/unit/frontlight_spec.lua index 3f0fe5283..376a3c56c 100644 --- a/spec/unit/frontlight_spec.lua +++ b/spec/unit/frontlight_spec.lua @@ -1,5 +1,6 @@ describe("Frontlight function in PowerD", function() - local PowerD, device + local PowerD + local param, test_when_on, test_when_off setup(function() require("commonrequire") @@ -17,7 +18,6 @@ describe("Frontlight function in PowerD", function() end) before_each(function() - frontlight = param.fl_min stub(PowerD, "init") stub(PowerD, "frontlightIntensityHW") stub(PowerD, "setIntensityHW") diff --git a/spec/unit/httpclient_spec.lua b/spec/unit/httpclient_spec.lua index f508e38c0..2dcfdb6f6 100644 --- a/spec/unit/httpclient_spec.lua +++ b/spec/unit/httpclient_spec.lua @@ -1,5 +1,5 @@ -- set true to test httpclient -DUSE_TURBO_LIB = false +DUSE_TURBO_LIB = false --luacheck: ignore describe("HTTP client module #notest #nocov", function() local UIManager diff --git a/spec/unit/koptinterface_spec.lua b/spec/unit/koptinterface_spec.lua index 74b400d2b..1406e3971 100644 --- a/spec/unit/koptinterface_spec.lua +++ b/spec/unit/koptinterface_spec.lua @@ -76,14 +76,14 @@ describe("Koptinterface module", function() end) it("should get native text boxes", function() - local kc = Koptinterface:getCachedContext(doc, 1) + Koptinterface:getCachedContext(doc, 1) local boxes = Koptinterface:getNativeTextBoxes(doc, 1) local lines_in_native_page = #boxes assert.truthy(lines_in_native_page == 60) end) it("should get native text boxes from scratch", function() - local kc = Koptinterface:getCachedContext(doc, 1) + Koptinterface:getCachedContext(doc, 1) local boxes = Koptinterface:getNativeTextBoxesFromScratch(doc, 1) local lines_in_native_page = #boxes assert.truthy(lines_in_native_page == 60) @@ -91,7 +91,7 @@ describe("Koptinterface module", function() it("should get reflow text boxes", function() doc.configurable.text_wrap = 1 - local kc = Koptinterface:getCachedContext(doc, 1) + Koptinterface:getCachedContext(doc, 1) local boxes = Koptinterface:getReflowedTextBoxes(doc, 1) local lines_in_reflowed_page = #boxes assert.truthy(lines_in_reflowed_page > 60) @@ -99,7 +99,7 @@ describe("Koptinterface module", function() it("should get reflow text boxes from scratch", function() doc.configurable.text_wrap = 1 - local kc = Koptinterface:getCachedContext(doc, 1) + Koptinterface:getCachedContext(doc, 1) local boxes = Koptinterface:getReflowedTextBoxesFromScratch(doc, 1) local lines_in_reflowed_page = #boxes assert.truthy(lines_in_reflowed_page > 60) @@ -123,7 +123,7 @@ describe("Koptinterface module", function() it("should get word from reflow position", function() complex_doc.configurable.text_wrap = 1 - local kc = Koptinterface:getCachedContext(complex_doc, 19) + Koptinterface:getCachedContext(complex_doc, 19) local word_boxes = Koptinterface:getWordFromPosition(complex_doc, { page = 19, x = 320, y = 730, }) diff --git a/spec/unit/kosync_spec.lua b/spec/unit/kosync_spec.lua index a12a94f35..e8c257c79 100644 --- a/spec/unit/kosync_spec.lua +++ b/spec/unit/kosync_spec.lua @@ -51,15 +51,13 @@ local service = [[ ]] describe("KOSync modules #notest #nocov", function() - local UIManager, logger, md5, client + local logger, md5, client local username, password, doc, percentage, progress, device setup(function() require("commonrequire") - UIManager = require("ui/uimanager") logger = require("logger") md5 = require("ffi/MD5") - local HTTPClient = require("httpclient") local Spore = require("Spore") client = Spore.new_from_string(service) package.loaded['Spore.Middleware.GinClient'] = {} @@ -188,13 +186,13 @@ describe("KOSync modules #notest #nocov", function() } -- TODO: Test kosync module - local function mockKOSyncClient() + local function mockKOSyncClient() --luacheck: ignore package.loaded["KOSyncClient"] = nil local c = require("KOSyncClient") c.new = function(o) - local o = o or {} - setmetatable(o, self) - self.__index = self + o = o or {} + setmetatable(o, self) --luacheck: ignore + self.__index = self --luacheck: ignore return o end @@ -208,11 +206,11 @@ describe("KOSync modules #notest #nocov", function() return res.result, res.body end - c.update_progress = function(name, passwd, doc, prog, percent, device, device_id, cb) + c.update_progress = function(name, passwd, doc, prog, percent, device, device_id, cb) --luacheck: ignore cb(res.result, res.body) end - c.get_progress = function(name, passwd, doc, cb) + c.get_progress = function(name, passwd, doc, cb) --luacheck: ignore cb(res.result, res.body) end end diff --git a/spec/unit/mock_time.lua b/spec/unit/mock_time.lua index c31b30c49..407b0cd5c 100644 --- a/spec/unit/mock_time.lua +++ b/spec/unit/mock_time.lua @@ -13,7 +13,7 @@ function MockTime:install() self.original_util_time = util.gettime assert(self.original_util_time ~= nil) end - os.time = function() + os.time = function() --luacheck: ignore logger.dbg("MockTime:os.time: ", self.value) return self.value end @@ -26,7 +26,7 @@ end function MockTime:uninstall() assert(self ~= nil) local util = require("ffi/util") - os.time = self.original_os_time + os.time = self.original_os_time --luacheck: ignore if self.original_util_time ~= nil then util.gettime = self.original_util_time end diff --git a/spec/unit/mock_time_spec.lua b/spec/unit/mock_time_spec.lua index cf9af9d3f..17106f5ab 100644 --- a/spec/unit/mock_time_spec.lua +++ b/spec/unit/mock_time_spec.lua @@ -41,7 +41,6 @@ describe("MockTime tests", function() it("should increase time", function() local mock_time = require("mock_time") - local current_time = os.time() mock_time:install() assert.is.truthy(mock_time:set(10.1)) assert.are.equal(os.time(), 10) diff --git a/spec/unit/network_manager_spec.lua b/spec/unit/network_manager_spec.lua index 67fdcb7ab..94f88e96d 100644 --- a/spec/unit/network_manager_spec.lua +++ b/spec/unit/network_manager_spec.lua @@ -51,7 +51,7 @@ describe("network_manager module", function() package.loaded["ui/network/manager"] = nil clearState() G_reader_settings:saveSetting("wifi_was_on", true) - local network_manager = require("ui/network/manager") + local network_manager = require("ui/network/manager") --luacheck: ignore assert.is.same(turn_on_wifi_called, 1) assert.is.same(turn_off_wifi_called, 0) assert.is.same(obtain_ip_called, 1) @@ -62,7 +62,7 @@ describe("network_manager module", function() package.loaded["ui/network/manager"] = nil clearState() G_reader_settings:saveSetting("wifi_was_on", false) - local network_manager = require("ui/network/manager") + local network_manager = require("ui/network/manager") --luacheck: ignore assert.is.same(turn_on_wifi_called, 0) assert.is.same(turn_off_wifi_called, 0) assert.is.same(obtain_ip_called, 0) diff --git a/spec/unit/nickel_conf_spec.lua b/spec/unit/nickel_conf_spec.lua index c30df125e..10c573915 100644 --- a/spec/unit/nickel_conf_spec.lua +++ b/spec/unit/nickel_conf_spec.lua @@ -166,6 +166,7 @@ bar=baz end) it("should create config file", function() + local fd local fn = "/tmp/abcfoobarbaz449" assert.is_not.Equals(lfs.attributes(fn, "mode"), "file") finally(function() os.remove(fn) end) diff --git a/spec/unit/optmath_spec.lua b/spec/unit/optmath_spec.lua index b8e60aa97..55610968f 100644 --- a/spec/unit/optmath_spec.lua +++ b/spec/unit/optmath_spec.lua @@ -1,4 +1,5 @@ describe("Math module", function() + local Math setup(function() require("commonrequire") diff --git a/spec/unit/readerbookmark_spec.lua b/spec/unit/readerbookmark_spec.lua index 057a82233..3bc934fd1 100644 --- a/spec/unit/readerbookmark_spec.lua +++ b/spec/unit/readerbookmark_spec.lua @@ -1,5 +1,5 @@ describe("ReaderBookmark module", function() - local DocumentRegistry, ReaderUI, UIManager, Screen, Geom, dbg, DocSettings + local DocumentRegistry, ReaderUI, UIManager, Screen, Geom, DocSettings local sample_epub, sample_pdf setup(function() @@ -10,7 +10,6 @@ describe("ReaderBookmark module", function() UIManager = require("ui/uimanager") Screen = require("device").screen Geom = require("ui/geometry") - dbg = require("dbg") sample_epub = "spec/front/unit/data/juliet.epub" sample_pdf = "spec/front/unit/data/sample.pdf" @@ -45,7 +44,6 @@ describe("ReaderBookmark module", function() end describe("bookmark for EPUB document", function() - local page = 10 local readerui setup(function() DocSettings:open(sample_epub):purge() diff --git a/spec/unit/readerdictionary_spec.lua b/spec/unit/readerdictionary_spec.lua index 0219c0ad6..f60621558 100644 --- a/spec/unit/readerdictionary_spec.lua +++ b/spec/unit/readerdictionary_spec.lua @@ -1,15 +1,12 @@ describe("Readerdictionary module", function() - local DocumentRegistry, ReaderUI, lfs, UIManager, Screen, Event, DEBUG + local DocumentRegistry, ReaderUI, UIManager, Screen setup(function() require("commonrequire") DocumentRegistry = require("document/documentregistry") ReaderUI = require("apps/reader/readerui") - lfs = require("libs/libkoreader-lfs") UIManager = require("ui/uimanager") Screen = require("device").screen - Event = require("ui/event") - DEBUG = require("dbg") end) local readerui, rolling, dictionary diff --git a/spec/unit/readerfooter_spec.lua b/spec/unit/readerfooter_spec.lua index c0a72f10b..3a4139690 100644 --- a/spec/unit/readerfooter_spec.lua +++ b/spec/unit/readerfooter_spec.lua @@ -1,14 +1,13 @@ describe("Readerfooter module", function() - local DocumentRegistry, ReaderUI, MenuSorter, DocSettings, UIManager, DEBUG + local DocumentRegistry, ReaderUI, DocSettings, UIManager local purgeDir, Screen + local tapFooterMenu setup(function() require("commonrequire") package.unloadAll() - DEBUG = require("dbg") DocumentRegistry = require("document/documentregistry") DocSettings = require("docsettings") - MenuSorter = require("ui/menusorter") ReaderUI = require("apps/reader/readerui") UIManager = require("ui/uimanager") purgeDir = require("ffi/util").purgeDir @@ -432,8 +431,8 @@ describe("Readerfooter module", function() it("should support toggle footer through menu if tap zone is disabled", function() local saved_tap_zone_minibar = DTAP_ZONE_MINIBAR - DTAP_ZONE_MINIBAR.w = 0 - DTAP_ZONE_MINIBAR.h = 0 + DTAP_ZONE_MINIBAR.w = 0 --luacheck: ignore + DTAP_ZONE_MINIBAR.h = 0 --luacheck: ignore local sample_pdf = "spec/front/unit/data/2col.pdf" purgeDir(DocSettings:getSidecarDir(sample_pdf)) @@ -471,7 +470,7 @@ describe("Readerfooter module", function() tapFooterMenu(fake_menu, "Toggle mode") assert.is.same(2, footer.mode) - DTAP_ZONE_MINIBAR = saved_tap_zone_minibar + DTAP_ZONE_MINIBAR = saved_tap_zone_minibar --luacheck: ignore end) it("should remove and add modes to footer text in all_at_once mode", function() diff --git a/spec/unit/readerhighlight_spec.lua b/spec/unit/readerhighlight_spec.lua index a94dc1411..5ae02a34a 100644 --- a/spec/unit/readerhighlight_spec.lua +++ b/spec/unit/readerhighlight_spec.lua @@ -1,5 +1,5 @@ describe("Readerhighlight module", function() - local DocumentRegistry, ReaderUI, UIManager, Screen, Geom, dbg, Event + local DocumentRegistry, ReaderUI, UIManager, Screen, Geom, Event setup(function() require("commonrequire") package.unloadAll() @@ -9,7 +9,6 @@ describe("Readerhighlight module", function() ReaderUI = require("apps/reader/readerui") Screen = require("device").screen UIManager = require("ui/uimanager") - dbg = require("dbg") end) local function highlight_single_word(readerui, pos0) diff --git a/spec/unit/readerpaging_spec.lua b/spec/unit/readerpaging_spec.lua index 439a91ad1..89d477b7e 100644 --- a/spec/unit/readerpaging_spec.lua +++ b/spec/unit/readerpaging_spec.lua @@ -84,7 +84,7 @@ describe("Readerpaging module", function() local tmp_readerui = ReaderUI:new{ document = DocumentRegistry:openDocument(sample_djvu), } - local paging = tmp_readerui.paging + paging = tmp_readerui.paging paging:onGotoPage(tmp_readerui.document:getPageCount()) paging:onScrollPanRel(120) paging:onScrollPanRel(-1) diff --git a/spec/unit/readerrolling_spec.lua b/spec/unit/readerrolling_spec.lua index ab40ceb36..b28f82326 100644 --- a/spec/unit/readerrolling_spec.lua +++ b/spec/unit/readerrolling_spec.lua @@ -1,5 +1,5 @@ describe("Readerrolling module", function() - local DocumentRegistry, ReaderUI, Event, DEBUG + local DocumentRegistry, ReaderUI, Event local readerui, rolling setup(function() @@ -7,7 +7,6 @@ describe("Readerrolling module", function() DocumentRegistry = require("document/documentregistry") ReaderUI = require("apps/reader/readerui") Event = require("ui/event") - DEBUG = require("dbg") local sample_epub = "spec/front/unit/data/juliet.epub" readerui = ReaderUI:new{ diff --git a/spec/unit/readertoc_spec.lua b/spec/unit/readertoc_spec.lua index 21b615ff5..e4a7157a2 100644 --- a/spec/unit/readertoc_spec.lua +++ b/spec/unit/readertoc_spec.lua @@ -1,6 +1,6 @@ describe("Readertoc module", function() local DocumentRegistry, ReaderUI, DEBUG - local readerui, toc, toc_max_depth + local readerui, toc, toc_max_depth, title setup(function() require("commonrequire") @@ -22,10 +22,10 @@ describe("Readertoc module", function() assert.are.same(2, toc_max_depth) end) it("should get toc title from page", function() - local title = toc:getTocTitleByPage(51) + title = toc:getTocTitleByPage(51) DEBUG("toc", toc.toc) assert(title == "SCENE V. A hall in Capulet's house.") - local title = toc:getTocTitleByPage(155) + title = toc:getTocTitleByPage(155) assert(title == "SCENE I. Friar Laurence's cell.") end) describe("getTocTicks API", function() diff --git a/spec/unit/readhistory_spec.lua b/spec/unit/readhistory_spec.lua index 11a704b30..1dedd6bab 100644 --- a/spec/unit/readhistory_spec.lua +++ b/spec/unit/readhistory_spec.lua @@ -23,16 +23,16 @@ describe("ReadHistory module", function() return DocSettings:getHistoryPath(realpath(test_file(name))) end - local function rm(file) - os.remove(file) + local function rm(filename) + os.remove(filename) end local function mv(source, target) os.rename(source, target) end - local function touch(file) - local f = io.open(file, "w") + local function touch(filename) + local f = io.open(filename, "w") f:close() end diff --git a/spec/unit/screenshoter_spec.lua b/spec/unit/screenshoter_spec.lua index 2cab78dce..33ff15186 100644 --- a/spec/unit/screenshoter_spec.lua +++ b/spec/unit/screenshoter_spec.lua @@ -1,5 +1,5 @@ describe("ReaderScreenshot module", function() - local DocumentRegistry, ReaderUI, lfs, UIManager, Screen, Event + local DocumentRegistry, ReaderUI, lfs, UIManager, Event local sample_epub = "spec/front/unit/data/leaves.epub" local readerui setup(function() @@ -8,7 +8,6 @@ describe("ReaderScreenshot module", function() ReaderUI = require("apps/reader/readerui") lfs = require("libs/libkoreader-lfs") UIManager = require("ui/uimanager") - Screen = require("device").screen Event = require("ui/event") readerui = ReaderUI:new{ diff --git a/spec/unit/touch_probe_spec.lua b/spec/unit/touch_probe_spec.lua index c2cf072fd..f74240af0 100644 --- a/spec/unit/touch_probe_spec.lua +++ b/spec/unit/touch_probe_spec.lua @@ -1,4 +1,5 @@ describe("touch probe module", function() + local x, y setup(function() require("commonrequire") end) @@ -12,7 +13,7 @@ describe("touch probe module", function() end -- for kobo touch, we have mirror_x, then switch_xy -- tap lower right corner - local x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40 + x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40 need_to_switch_xy = nil TouchProbe:onTapProbe(nil, { pos = { @@ -25,7 +26,7 @@ describe("touch probe module", function() -- now only test mirror_x -- tap lower right corner - local x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40 + x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40 need_to_switch_xy = nil TouchProbe:onTapProbe(nil, { pos = { @@ -38,7 +39,7 @@ describe("touch probe module", function() -- now only test switch_xy -- tap lower right corner - local x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40 + x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40 need_to_switch_xy = nil TouchProbe:onTapProbe(nil, { pos = { @@ -49,7 +50,7 @@ describe("touch probe module", function() assert.is.same(TouchProbe.curr_probe_step, 2) assert.falsy(need_to_switch_xy) -- tap upper right corner - local x, y = Device.screen:getWidth()-40, 40 + x, y = Device.screen:getWidth()-40, 40 TouchProbe:onTapProbe(nil, { pos = { x = y, diff --git a/spec/unit/translator_spec.lua b/spec/unit/translator_spec.lua index 65b2b7028..6c0270e13 100644 --- a/spec/unit/translator_spec.lua +++ b/spec/unit/translator_spec.lua @@ -1,4 +1,5 @@ local dutch_wikipedia_text = "Wikipedia is een meertalige encyclopedie, waarvan de inhoud vrij beschikbaar is. Iedereen kan hier kennis toevoegen!" +local Translator describe("Translator module", function() setup(function() diff --git a/spec/unit/uimanager_bench.lua b/spec/unit/uimanager_bench.lua index 2eafcd64a..bb41f16ad 100644 --- a/spec/unit/uimanager_bench.lua +++ b/spec/unit/uimanager_bench.lua @@ -6,6 +6,7 @@ local noop = function() end describe("UIManager checkTasks benchmark", function() local now = { util.gettime() } + local wait_until -- luacheck: no unused UIManager:quit() UIManager._task_queue = {} @@ -17,7 +18,7 @@ describe("UIManager checkTasks benchmark", function() end -- for i=1,1000 do - wait_until, now = UIManager:_checkTasks() + wait_until, now = UIManager:_checkTasks() -- luacheck: no unused -- end end) diff --git a/spec/unit/uimanager_spec.lua b/spec/unit/uimanager_spec.lua index f0ce0fd31..a15060606 100644 --- a/spec/unit/uimanager_spec.lua +++ b/spec/unit/uimanager_spec.lua @@ -1,16 +1,16 @@ describe("UIManager spec", function() - local Device, UIManager, util + local UIManager, util + local now, wait_until local noop = function() end setup(function() require("commonrequire") util = require("ffi/util") UIManager = require("ui/uimanager") - Device = require("device") end) it("should consume due tasks", function() - local now = { util.gettime() } + now = { util.gettime() } local future = { now[1] + 60000, now[2] } local future2 = {future[1] + 5, future[2]} UIManager:quit() @@ -28,7 +28,7 @@ describe("UIManager spec", function() end) it("should calcualte wait_until properly in checkTasks routine", function() - local now = { util.gettime() } + now = { util.gettime() } local future = { now[1] + 60000, now[2] } UIManager:quit() UIManager._task_queue = { @@ -43,7 +43,7 @@ describe("UIManager spec", function() end) it("should return nil wait_until properly in checkTasks routine", function() - local now = { util.gettime() } + now = { util.gettime() } UIManager:quit() UIManager._task_queue = { { time = {now[1] - 10, now[2] }, action = noop }, @@ -55,7 +55,7 @@ describe("UIManager spec", function() end) it("should insert new task properly in empty task queue", function() - local now = { util.gettime() } + now = { util.gettime() } UIManager:quit() UIManager._task_queue = {} assert.are.same(0, #UIManager._task_queue) @@ -65,7 +65,7 @@ describe("UIManager spec", function() end) it("should insert new task properly in single task queue", function() - local now = { util.gettime() } + now = { util.gettime() } local future = { now[1]+10000, now[2] } UIManager:quit() UIManager._task_queue = { @@ -90,8 +90,7 @@ describe("UIManager spec", function() end) it("should insert new task in ascendant order", function() - local now = { util.gettime() } - local noop1 = function() end + now = { util.gettime() } UIManager:quit() UIManager._task_queue = { { time = {now[1] - 10, now[2] }, action = '1' }, @@ -116,8 +115,7 @@ describe("UIManager spec", function() end) it("should unschedule all the tasks with the same action", function() - local now = { util.gettime() } - local noop1 = function() end + now = { util.gettime() } UIManager:quit() UIManager._task_queue = { { time = {now[1] - 15, now[2] }, action = '3' }, @@ -135,7 +133,7 @@ describe("UIManager spec", function() end) it("should not have race between unschedule and _checkTasks", function() - local now = { util.gettime() } + now = { util.gettime() } local run_count = 0 local task_to_remove = function() run_count = run_count + 1 diff --git a/spec/unit/util_spec.lua b/spec/unit/util_spec.lua index 4e606c24c..8fcac79a2 100644 --- a/spec/unit/util_spec.lua +++ b/spec/unit/util_spec.lua @@ -146,7 +146,7 @@ describe("util module", function() local text = "Ce test : 1) est très simple ; 2 ) simple comme ( 2/2 ) > 50 % ? ok." local word = "" local table_of_words = {} - local c + local c, next_c local table_chars = util.splitToChars(text) for i = 1, #table_chars do c = table_chars[i] @@ -179,7 +179,7 @@ describe("util module", function() local text = "Ce test : 1) est « très simple » ; 2 ) simple comme ( 2/2 ) > 50 % ? ok." local word = "" local table_of_words = {} - local c + local c, next_c, prev_c local table_chars = util.splitToChars(text) for i = 1, #table_chars do c = table_chars[i] diff --git a/spec/unit/widget_menu_spec.lua b/spec/unit/widget_menu_spec.lua index 1fa9f2e38..f94012047 100644 --- a/spec/unit/widget_menu_spec.lua +++ b/spec/unit/widget_menu_spec.lua @@ -1,15 +1,14 @@ describe("Menu widget", function() - local Menu, dbg + local Menu setup(function() require("commonrequire") Menu = require("ui/widget/menu") - dbg = require("dbg") end) it("should convert item table from touch menu properly", function() local cb1 = function() end local cb2 = function() end - re = Menu.itemTableFromTouchMenu({ + local re = Menu.itemTableFromTouchMenu({ navi = { icon = 'foo/bar.png', { text = 'foo', callback = cb1 }, diff --git a/spec/unit/wikipedia_spec.lua b/spec/unit/wikipedia_spec.lua index 5e35fd79e..d5eb74fef 100644 --- a/spec/unit/wikipedia_spec.lua +++ b/spec/unit/wikipedia_spec.lua @@ -1,5 +1,5 @@ describe("Wikipedia module", function() - local util + local Wikipedia setup(function() require("commonrequire") Wikipedia = require("ui/wikipedia")