From bf3b9b5f42556bdd8b2896c8e2c26ee72cfaf67c Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 7 Feb 2016 13:04:01 +0100 Subject: [PATCH] tests: Fix luacheck warnings This leaves one warning in tests/test-urgent.lua which points out an actual bug/problem. Signed-off-by: Uli Schlachter --- tests/_runner.lua | 2 +- tests/test-benchmark.lua | 4 ++-- tests/test-focus.lua | 5 ++--- tests/test-leaks.lua | 8 +++----- tests/test-spawn-snid.lua | 1 - tests/test-urgent.lua | 10 +++++++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/_runner.lua b/tests/_runner.lua index c07490fe9..b954c5396 100644 --- a/tests/_runner.lua +++ b/tests/_runner.lua @@ -1,7 +1,7 @@ local timer = require("gears.timer") local awful = require("awful") -runner = { +local runner = { quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1', -- quit-on-timeout defaults to false: indicates some problem with the test itself. quit_awesome_on_timeout = os.getenv('TEST_QUIT_ON_TIMEOUT') ~= '1', diff --git a/tests/test-benchmark.lua b/tests/test-benchmark.lua index 0b09254ca..ca35f171f 100644 --- a/tests/test-benchmark.lua +++ b/tests/test-benchmark.lua @@ -15,7 +15,7 @@ do local timer_measure = GLib.Timer() measure = function(f, iter) timer_measure:start() - for i = 1, iter do + for _ = 1, iter do f() end local elapsed = timer_measure:elapsed() @@ -47,7 +47,7 @@ local function create_and_draw_wibox() do_pending_repaint() end -local wb, textclock = create_wibox() +local _, textclock = create_wibox() local function relayout_textclock() textclock:emit_signal("widget::layout_changed") diff --git a/tests/test-focus.lua b/tests/test-focus.lua index bc8b86732..084be2fbd 100644 --- a/tests/test-focus.lua +++ b/tests/test-focus.lua @@ -1,10 +1,9 @@ --- Tests for focus signals / property. -- Test for https://github.com/awesomeWM/awesome/issues/134. -awful = require("awful") -timer = require("gears.timer") +local awful = require("awful") -beautiful = require("beautiful") +local beautiful = require("beautiful") beautiful.border_normal = "#0000ff" beautiful.border_focus = "#00ff00" diff --git a/tests/test-leaks.lua b/tests/test-leaks.lua index a7622fbd1..e271bc55a 100644 --- a/tests/test-leaks.lua +++ b/tests/test-leaks.lua @@ -3,17 +3,15 @@ local awful = require("awful") local cairo = require("lgi").cairo local create_wibox = require("_wibox_helper").create_wibox -local gears = require("gears") local wibox = require("wibox") -local errors = {} - local prepare_for_collect = nil local function emit_refresh() awesome.emit_signal("refresh") end -- Make the layoutbox in the default config GC'able +-- luacheck: globals mywibox mylayoutbox mywibox[1].visible = false mywibox = nil mylayoutbox = nil @@ -23,7 +21,7 @@ emit_refresh() local function collectable(a, b, c, d, e, f, g, h, last) assert(last == nil, "got more arguments than supported") local objs = setmetatable({ a, b, c, d, e, f, g, h }, { __mode = "v" }) - a, b, c, d, e, f, g, h = nil, nil, nil, nil, nil, nil, nil, nil + a, b, c, d, e, f, g, h = nil, nil, nil, nil, nil, nil, nil, nil -- luacheck: ignore if prepare_for_collect then prepare_for_collect() prepare_for_collect = nil @@ -31,7 +29,7 @@ local function collectable(a, b, c, d, e, f, g, h, last) collectgarbage("collect") collectgarbage("collect") -- Check if the table is now empty - for k, v in pairs(objs) do + for _, v in pairs(objs) do print("Some object was not garbage collected!") error(v) end diff --git a/tests/test-spawn-snid.lua b/tests/test-spawn-snid.lua index 8438cd19f..27738fc29 100644 --- a/tests/test-spawn-snid.lua +++ b/tests/test-spawn-snid.lua @@ -16,7 +16,6 @@ local steps = { if count == 1 then ret, snid = spawn('urxvt', true) elseif manage_called then - local c = client.get()[1] assert(ret) assert(snid) assert(snid == c_snid) diff --git a/tests/test-urgent.lua b/tests/test-urgent.lua index 9e42727ff..d51e256e4 100644 --- a/tests/test-urgent.lua +++ b/tests/test-urgent.lua @@ -1,6 +1,10 @@ --- Tests for urgent property. -awful = require("awful") +local awful = require("awful") +local runner = require("_runner") + +-- This uses the global "tags" array set in the default config +-- luacheck: globals tags -- Some basic assertion that the tag is not marked "urgent" already. assert(awful.tag.getproperty(tags[1][2], "urgent") == nil) @@ -53,7 +57,7 @@ local steps = { elseif awful.tag.selectedlist()[1] == tags[1][2] then assert(#client.get() == 1) - c = client.get()[1] + local c = client.get()[1] assert(not c.urgent, "Client is not urgent anymore.") assert(c == client.focus, "Client is focused.") assert(awful.tag.getproperty(tags[1][2], "urgent") == false) @@ -106,6 +110,6 @@ local steps = { end, } -require("_runner").run_steps(steps) +runner.run_steps(steps) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80