From b6f4c85ba6c0ab0ae740d4c072a44a88f3e7d851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Lepage=20Vall=C3=A9e?= Date: Thu, 28 Oct 2021 12:24:37 -0700 Subject: [PATCH] tests: Restructure the wibar test to work better on luajit. (#3487) There were too many references to the original wibar and the GC cannot resolve them 50% of the time. As shown in test-leak, GCing the wibar does work. Just not the way the test was strutured. --- tests/test-struts.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/test-struts.lua b/tests/test-struts.lua index 90cd9053..b3277942 100644 --- a/tests/test-struts.lua +++ b/tests/test-struts.lua @@ -7,10 +7,18 @@ local steps = {} local parent, small -local twibar, bwibar, lwibar, rwibar = screen.primary.mywibox +local twibar, bwibar, lwibar, rwibar + +-- Remove the original wibar. +screen.primary.mywibox:remove() +screen.primary.mywibox = nil + +for _=1, 3 do + collectgarbage("collect") +end -- Track garbage collection. -local wibars = setmetatable({screen.primary.mywibox}, {__mode="v"}) +local wibars = setmetatable({}, {__mode="v"}) -- Pretty print issues local function print_expected() @@ -55,8 +63,17 @@ local function validate_wibar_geometry() end end +-- Replace the original wibar. +table.insert(steps, function() + twibar = wibar {position = "top", bg = "#ff0000"} + + return true +end) + -- Test the struts without using wibars table.insert(steps, function() + if screen[1].workarea.y == 0 then return end + local sgeo = screen.primary.geometry -- Manually place at the bottom right @@ -392,7 +409,7 @@ table.insert(steps, function() bwibar.visible = false lwibar.visible = false rwibar.visible = false - screen.primary.mywibox.visible = false + twibar.visible = false -- Spawn a client to test things with assert(#client.get() == 0) @@ -481,7 +498,6 @@ table.insert(steps, function() -- Make sure the placement doesn't hold a reference. bwibar, lwibar, rwibar, twibar = nil, nil, nil, nil - screen.primary.mywibox = nil return true end)