@@ -8,6 +8,7 @@ local function get_trace(element, level, msg)
8
8
info .traceback = info .traceback :sub (1 , index )
9
9
return info
10
10
end
11
+
11
12
level = level or 3
12
13
13
14
local thisdir = dirname (debug.getinfo (1 , " Sl" ).source , " :h" )
@@ -170,7 +171,20 @@ local run_each = function(tbl)
170
171
end
171
172
end
172
173
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
+
173
183
mod .it = function (desc , func )
184
+ if not matches_filter (desc ) then
185
+ return
186
+ end
187
+
174
188
run_each (current_before_each )
175
189
local ok , msg , desc_stack = call_inner (desc , func )
176
190
run_each (current_after_each )
@@ -199,12 +213,17 @@ mod.it = function(desc, func)
199
213
end
200
214
201
215
mod .pending = function (desc , func )
216
+ if not matches_filter (desc ) then
217
+ return
218
+ end
219
+
202
220
local curr_stack = vim .deepcopy (current_description )
203
221
table.insert (curr_stack , desc )
204
222
print (PENDING , " ||" , table.concat (curr_stack , " " ))
205
223
end
206
224
207
225
_PlenaryBustedOldAssert = _PlenaryBustedOldAssert or assert
226
+ _PlenaryBustedOpts = {} -- TODO: check if this should be here?
208
227
209
228
describe = mod .describe
210
229
it = mod .it
@@ -214,7 +233,9 @@ after_each = mod.after_each
214
233
clear = mod .clear
215
234
assert = require " luassert"
216
235
217
- mod .run = function (file )
236
+ mod .run = function (file , opts )
237
+ _PlenaryBustedOpts = vim .tbl_deep_extend (" force" , {}, opts or {})
238
+
218
239
print (" \n " .. HEADER )
219
240
print (" Testing: " , file )
220
241
0 commit comments