From 4dccfbb57b7ff05dacc9feb689391fabd510addc Mon Sep 17 00:00:00 2001 From: MisanthropicBit Date: Fri, 29 Nov 2024 22:45:16 +0100 Subject: [PATCH 1/3] Match top-level tests as well --- busted/modules/filter_loader.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/busted/modules/filter_loader.lua b/busted/modules/filter_loader.lua index e5c15182..5fb7fe7e 100644 --- a/busted/modules/filter_loader.lua +++ b/busted/modules/filter_loader.lua @@ -84,7 +84,7 @@ return function() if not (options.suppressPending and status == 'pending') then local fullname = getFullName() local trace = element.trace - if trace and trace.what == 'Lua' then + if trace and (trace.what == 'Lua' or trace.what == 'main') then fullname = trace.short_src .. ':' .. trace.currentline .. ': ' .. fullname end print(fullname) From 25ff938a7e69e91a357a7baf0710b0f4fa0fbe31 Mon Sep 17 00:00:00 2001 From: MisanthropicBit Date: Sun, 8 Dec 2024 09:46:54 +0100 Subject: [PATCH 2/3] Add test for top-level test --- spec/cl_list.lua | 3 +++ spec/cl_spec.lua | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/cl_list.lua b/spec/cl_list.lua index c376ce45..ca97686b 100644 --- a/spec/cl_list.lua +++ b/spec/cl_list.lua @@ -1,5 +1,8 @@ -- supporting testfile; belongs to 'cl_spec.lua' +it('top-level test', function() +end) + describe('Tests list', function() it('test 1', function() end) diff --git a/spec/cl_spec.lua b/spec/cl_spec.lua index d5a6df28..f614d78e 100644 --- a/spec/cl_spec.lua +++ b/spec/cl_spec.lua @@ -183,17 +183,19 @@ describe('Tests the busted command-line options', function() it('tests running with -l specified', function() local _, _, result = executeBusted('-l --pattern=cl_list.lua$') - local expected = 'spec/cl_list.lua:4: Tests list test 1\n' .. - 'spec/cl_list.lua:7: Tests list test 2\n' .. - 'spec/cl_list.lua:10: Tests list test 3\n' + local expected = 'spec/cl_list.lua:3: top-level test\n' .. + 'spec/cl_list.lua:6: Tests list test 1\n' .. + 'spec/cl_list.lua:10: Tests list test 2\n' .. + 'spec/cl_list.lua:13: Tests list test 3\n' assert.is_equal(normpath(expected), result) end) it('tests running with --list specified', function() local _, _, result = executeBusted('--list --pattern=cl_list.lua$') - local expected = 'spec/cl_list.lua:4: Tests list test 1\n' .. - 'spec/cl_list.lua:7: Tests list test 2\n' .. - 'spec/cl_list.lua:10: Tests list test 3\n' + local expected = 'spec/cl_list.lua:3: top-level test\n' .. + 'spec/cl_list.lua:6: Tests list test 1\n' .. + 'spec/cl_list.lua:10: Tests list test 2\n' .. + 'spec/cl_list.lua:13: Tests list test 3\n' assert.is_equal(normpath(expected), result) end) From 786f85941a7e8dec11aec44e5c88a8720e63fd66 Mon Sep 17 00:00:00 2001 From: MisanthropicBit Date: Tue, 10 Dec 2024 10:52:27 +0100 Subject: [PATCH 3/3] Fix line number --- spec/cl_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/cl_spec.lua b/spec/cl_spec.lua index f614d78e..a8ba62bc 100644 --- a/spec/cl_spec.lua +++ b/spec/cl_spec.lua @@ -184,7 +184,7 @@ describe('Tests the busted command-line options', function() it('tests running with -l specified', function() local _, _, result = executeBusted('-l --pattern=cl_list.lua$') local expected = 'spec/cl_list.lua:3: top-level test\n' .. - 'spec/cl_list.lua:6: Tests list test 1\n' .. + 'spec/cl_list.lua:7: Tests list test 1\n' .. 'spec/cl_list.lua:10: Tests list test 2\n' .. 'spec/cl_list.lua:13: Tests list test 3\n' assert.is_equal(normpath(expected), result) @@ -193,7 +193,7 @@ describe('Tests the busted command-line options', function() it('tests running with --list specified', function() local _, _, result = executeBusted('--list --pattern=cl_list.lua$') local expected = 'spec/cl_list.lua:3: top-level test\n' .. - 'spec/cl_list.lua:6: Tests list test 1\n' .. + 'spec/cl_list.lua:7: Tests list test 1\n' .. 'spec/cl_list.lua:10: Tests list test 2\n' .. 'spec/cl_list.lua:13: Tests list test 3\n' assert.is_equal(normpath(expected), result)