aboutsummaryrefslogtreecommitdiff
path: root/test/functional/testutil.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-11 07:51:25 +0800
committerGitHub <noreply@github.com>2024-04-11 07:51:25 +0800
commit509c053161c0495ac41cf12343089059afb4e813 (patch)
treec565fa5ce892600cf7cd6cf51729fe44c5f96933 /test/functional/testutil.lua
parentd627497156162f03a36e889d316b68df66928193 (diff)
downloadrneovim-509c053161c0495ac41cf12343089059afb4e813.tar.gz
rneovim-509c053161c0495ac41cf12343089059afb4e813.tar.bz2
rneovim-509c053161c0495ac41cf12343089059afb4e813.zip
test: fix off-by-one test IDs in logs (#28269)
Run the global before_each() before all other before_each(), so that clear() uses the test ID of the current test, not the previous one. Don't skip generating test IDs for skipped tests, as that'll make a skipped test have the same test ID as the previous one.
Diffstat (limited to 'test/functional/testutil.lua')
-rw-r--r--test/functional/testutil.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/testutil.lua b/test/functional/testutil.lua
index efd7790764..1ab15053db 100644
--- a/test/functional/testutil.lua
+++ b/test/functional/testutil.lua
@@ -1022,12 +1022,30 @@ function module.mkdir_p(path)
return os.execute((is_os('win') and 'mkdir ' .. path or 'mkdir -p ' .. path))
end
+local testid = (function()
+ local id = 0
+ return function()
+ id = id + 1
+ return id
+ end
+end)()
+
return function()
local g = getfenv(2)
--- @type function?
+ local before_each = g.before_each
+ --- @type function?
local after_each = g.after_each
+ if before_each then
+ before_each(function()
+ local id = ('T%d'):format(testid())
+ _G._nvim_test_id = id
+ return nil, true
+ end)
+ end
+
if after_each then
after_each(function()
check_logs()