@@ -8,6 +8,7 @@ local function get_trace(element, level, msg)
88 info .traceback = info .traceback :sub (1 , index )
99 return info
1010 end
11+
1112 level = level or 3
1213
1314 local thisdir = dirname (debug.getinfo (1 , " Sl" ).source , " :h" )
@@ -170,7 +171,20 @@ local run_each = function(tbl)
170171 end
171172end
172173
174+ local matches_filter = function (desc )
175+ if not _PlenaryBustedOpts .filter then
176+ return true
177+ end
178+
179+ local desc_stack = table.concat (current_description , " " ) .. desc
180+ return desc_stack :match (_PlenaryBustedOpts .filter )
181+ end
182+
173183mod .it = function (desc , func )
184+ if not matches_filter (desc ) then
185+ return
186+ end
187+
174188 run_each (current_before_each )
175189 local ok , msg , desc_stack = call_inner (desc , func )
176190 run_each (current_after_each )
@@ -199,12 +213,17 @@ mod.it = function(desc, func)
199213end
200214
201215mod .pending = function (desc , func )
216+ if not matches_filter (desc ) then
217+ return
218+ end
219+
202220 local curr_stack = vim .deepcopy (current_description )
203221 table.insert (curr_stack , desc )
204222 print (PENDING , " ||" , table.concat (curr_stack , " " ))
205223end
206224
207225_PlenaryBustedOldAssert = _PlenaryBustedOldAssert or assert
226+ _PlenaryBustedOpts = {} -- TODO: check if this should be here?
208227
209228describe = mod .describe
210229it = mod .it
@@ -214,7 +233,9 @@ after_each = mod.after_each
214233clear = mod .clear
215234assert = require " luassert"
216235
217- mod .run = function (file )
236+ mod .run = function (file , opts )
237+ _PlenaryBustedOpts = vim .tbl_deep_extend (" force" , {}, opts or {})
238+
218239 print (" \n " .. HEADER )
219240 print (" Testing: " , file )
220241
0 commit comments