From 83e176fa32edecb5b99cda1182e1e5fd2e231355 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 10 Jan 2017 00:11:43 -0500 Subject: [PATCH] tests: Break wibox for multiscreen tests (on purpose) This commit add an option to shim the whole wibox module when running multi-screen tests. This is intended to lower the test runtime when coverage is enabled. In theory, most of that code is already covered by the test-screen-changes suit. This makes the coverage builds about twice as fast. This is necessary because there is a large number of timeouts due to limited resources on the Travis build system. --- tests/_multi_screen.lua | 23 +++++++++++++++++++++++ tests/test-awful-client.lua | 6 +++++- tests/test-awful-tag.lua | 4 +++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/_multi_screen.lua b/tests/_multi_screen.lua index bc42b1757..ddd578e5b 100644 --- a/tests/_multi_screen.lua +++ b/tests/_multi_screen.lua @@ -517,6 +517,29 @@ local function add_steps(real_steps, new_steps) end end +-- This is a very ugly hack to speed up the test. Luacov get exponentially +-- slower / more memory hungry when it has more work to do in a single test. +-- A lot of that work is building wibars and widgets for those screen. This +-- has value when tried once (already covered by the test-screen-changes suit), +-- but not done 180 times in a row. This code monkey-patch `wibox` with the +-- intent of breaking it without causing errors. This way it stops doing too +-- many things (resulting in a faster luacov execution) +function module.disable_wibox() + local awful = require("awful") + + setmetatable(wibox, { + __call = function() return { + geometry = function() + return{x=0, y=0, width=0, height=0} + end, + set_widget = function() end, + setup = function() return {} end + } + end }) + + awful.wibar = wibox +end + return setmetatable(module, { __call = function(_,...) return add_steps(...) end }) diff --git a/tests/test-awful-client.lua b/tests/test-awful-client.lua index 3cec2a0a0..70d7e040f 100644 --- a/tests/test-awful-client.lua +++ b/tests/test-awful-client.lua @@ -146,6 +146,8 @@ table.insert(steps, function() return true end) + + local multi_screen_steps = {} -- Add a test client on each screen. @@ -321,7 +323,9 @@ table.insert(multi_screen_steps, function() return true end) -require("_multi_screen")(steps, multi_screen_steps) +local ms = require("_multi_screen") +ms.disable_wibox() +ms(steps, multi_screen_steps) require("_runner").run_steps(steps) diff --git a/tests/test-awful-tag.lua b/tests/test-awful-tag.lua index 727359d04..9b99a91d2 100644 --- a/tests/test-awful-tag.lua +++ b/tests/test-awful-tag.lua @@ -239,7 +239,9 @@ table.insert(multi_screen_steps, function() return true end) -require("_multi_screen")(steps, multi_screen_steps) +local ms = require("_multi_screen") +ms.disable_wibox() +ms(steps, multi_screen_steps) require("_runner").run_steps(steps)