Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit 1b17985

Browse files
committed
Do not execute describe if it is filtered out
This prevents describes that have been filtered out, with the --exclude-tags or --filter-out options, from running any setup or teardown functions.
1 parent c84abb8 commit 1b17985

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

busted/runner.lua

+5-6
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,8 @@ return function(options)
248248
end
249249

250250
local filterExcludeTags = function(name)
251-
local fullname = getFullName(name)
252251
for i, tag in pairs(excludeTags) do
253-
if hasTag(fullname, tag) then
252+
if hasTag(name, tag) then
254253
return nil, false
255254
end
256255
end
@@ -307,10 +306,10 @@ return function(options)
307306
end
308307

309308
-- The following filters are applied in reverse order
310-
applyFilter({ 'it', 'pending' }, 'filter' , filterNames )
311-
applyFilter({ 'it', 'pending' }, 'filter-out' , filterOutNames )
312-
applyFilter({ 'it', 'pending' }, 'tags' , filterTags )
313-
applyFilter({ 'it', 'pending' }, 'exclude-tags', filterExcludeTags)
309+
applyFilter({ 'it', 'pending' } , 'filter' , filterNames )
310+
applyFilter({ 'describe', 'it', 'pending' }, 'filter-out' , filterOutNames )
311+
applyFilter({ 'it', 'pending' } , 'tags' , filterTags )
312+
applyFilter({ 'describe', 'it', 'pending' }, 'exclude-tags', filterExcludeTags)
314313

315314
-- Load test directory
316315
local rootFile = cliArgs.ROOT and normpath(path.join(fpath, cliArgs.ROOT)) or fileName

spec/cl_filter.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Tests describe with patt1', function()
4343
end)
4444

4545
context('Tests context with patt2', function()
46-
it('is a test inside context', function()
47-
error('error on patt2')
46+
setup(function()
47+
error('error in setup on patt2')
4848
end)
4949
end)

spec/cl_spec.lua

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ describe('Tests the busted command-line options', function()
6767
assert.is_equal(8, exitcode)
6868
success, exitcode = execute('bin/busted --pattern=_tags.lua$ --tags=tag1')
6969
assert.is_false(success)
70-
assert.is_equal(2, exitcode)
70+
assert.is_equal(3, exitcode)
7171
success, exitcode = execute('bin/busted --pattern=_tags.lua$ --tags=tag1,tag2')
7272
assert.is_false(success)
73-
assert.is_equal(3, exitcode)
73+
assert.is_equal(4, exitcode)
7474
error_end()
7575
end)
7676

@@ -93,8 +93,8 @@ describe('Tests the busted command-line options', function()
9393
assert.is_false(success)
9494
assert.is_equal(1, exitcode)
9595
success, exitcode = execute('bin/busted --pattern=_tags.lua$ --tags=tag3 --exclude-tags=tag4')
96-
assert.is_true(success)
97-
assert.is_equal(0, exitcode)
96+
assert.is_false(success)
97+
assert.is_equal(1, exitcode)
9898
error_end()
9999
end)
100100

@@ -103,7 +103,7 @@ describe('Tests the busted command-line options', function()
103103
error_start()
104104
success, exitcode = execute('bin/busted --pattern=_tags.lua$ --tags=dtag1')
105105
assert.is_false(success)
106-
assert.is_equal(4, exitcode)
106+
assert.is_equal(5, exitcode)
107107
success, exitcode = execute('bin/busted --pattern=_tags.lua$ --tags=dtag2')
108108
assert.is_false(success)
109109
assert.is_equal(1, exitcode)
@@ -118,10 +118,10 @@ describe('Tests the busted command-line options', function()
118118
assert.is_equal(8, exitcode)
119119
success, exitcode = execute('bin/busted --pattern=_filter.lua$ --filter="pattern1"')
120120
assert.is_false(success)
121-
assert.is_equal(2, exitcode)
121+
assert.is_equal(3, exitcode)
122122
success, exitcode = execute('bin/busted --pattern=_filter.lua$ --filter="pattern2"')
123123
assert.is_false(success)
124-
assert.is_equal(1, exitcode)
124+
assert.is_equal(2, exitcode)
125125
error_end()
126126
end)
127127

@@ -152,7 +152,7 @@ describe('Tests the busted command-line options', function()
152152
error_start()
153153
success, exitcode = execute('bin/busted --pattern=_filter.lua$ --filter="patt1"')
154154
assert.is_false(success)
155-
assert.is_equal(4, exitcode)
155+
assert.is_equal(5, exitcode)
156156
success, exitcode = execute('bin/busted --pattern=_filter.lua$ --filter="patt2"')
157157
assert.is_false(success)
158158
assert.is_equal(1, exitcode)

spec/cl_tags.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Tests describe with a tag #dtag1', function()
4343
end)
4444

4545
context('Tests context with a tag #dtag2', function()
46-
it('is a test inside context', function()
47-
error('error on dtag2')
46+
setup(function()
47+
error('error in setup on dtag2')
4848
end)
4949
end)

0 commit comments

Comments
 (0)