diff --git a/busted/modules/cli.lua b/busted/modules/cli.lua index 753205c8..0cca3e2b 100644 --- a/busted/modules/cli.lua +++ b/busted/modules/cli.lua @@ -129,6 +129,7 @@ return function(options) cli:option('-t, --tags=TAGS', 'only run tests with these #tags', {}, processList) cli:option('--exclude-tags=TAGS', 'do not run tests with these #tags, takes precedence over --tags', {}, processList) cli:option('--filter=PATTERN', 'only run test names matching the Lua pattern', {}, processMultiOption) + cli:option('--name=NAME', 'run test with the given full name', {}, processMultiOption) cli:option('--filter-out=PATTERN', 'do not run test names matching the Lua pattern, takes precedence over --filter', {}, processMultiOption) cli:option('--exclude-names-file=FILE', 'do not run the tests with names listed in the given file, takes precedence over --filter', nil, processOption) cli:option('--log-success=FILE', 'append the name of each successful test to the given file', nil, processOption) diff --git a/busted/modules/filter_loader.lua b/busted/modules/filter_loader.lua index 9210f721..e5c15182 100644 --- a/busted/modules/filter_loader.lua +++ b/busted/modules/filter_loader.lua @@ -62,6 +62,15 @@ return function() return nil, true end + local name = function(name) + for _, candidate in pairs(options.name) do + if string.find(candidate, getFullName(name), 1, true) then + return nil, true + end + end + return nil, (#options.name == 0) + end + local filterNames = function(name) for _, filter in pairs(options.filter) do if getFullName(name):find(filter) ~= nil then @@ -139,8 +148,9 @@ return function() -- The following filters are applied in reverse order applyFilter({ 'it', 'pending' } , 'filter' , filterNames ) + applyFilter({ 'describe', 'it', 'pending' }, 'name' , name ) applyFilter({ 'describe', 'it', 'pending' }, 'filterOut' , filterOutNames ) - applyFilter({ 'describe', 'it', 'pending' }, 'excludeNamesFile', excludeNamesFile) + applyFilter({ 'describe', 'it', 'pending' }, 'excludeNamesFile', excludeNamesFile ) applyFilter({ 'it', 'pending' } , 'tags' , filterTags ) applyFilter({ 'describe', 'it', 'pending' }, 'excludeTags' , filterExcludeTags ) end diff --git a/busted/runner.lua b/busted/runner.lua index 0caf28b2..8d2c557e 100644 --- a/busted/runner.lua +++ b/busted/runner.lua @@ -181,6 +181,7 @@ return function(options) tags = cliArgs.tags, excludeTags = cliArgs['exclude-tags'], filter = cliArgs.filter, + name = cliArgs.name, filterOut = cliArgs['filter-out'], excludeNamesFile = cliArgs['exclude-names-file'], list = cliArgs.list, diff --git a/completions/bash/busted.bash b/completions/bash/busted.bash index b8652e56..7c32dafb 100644 --- a/completions/bash/busted.bash +++ b/completions/bash/busted.bash @@ -136,7 +136,7 @@ _busted() { # no completion available return 0 ;; - --filter|--filter-out) + --filter|--filter-out|--name) # no completion available return 0 ;; @@ -179,6 +179,7 @@ _busted() { --lua= --ignore-lua --filter= --filter-out= + --name= --exclude-names-file= --repeat= --seed= diff --git a/completions/zsh/_busted b/completions/zsh/_busted index 66d03a0b..d74d7794 100644 --- a/completions/zsh/_busted +++ b/completions/zsh/_busted @@ -57,6 +57,7 @@ _busted_args=( "--filter=[Only run test names matching the Lua pattern]: :" "--filter-out=[Do not run test names matching the Lua pattern, takes precedence over --filter]: :" "--exclude-names-file=[Do not run the tests with names listed in the given file, takes precedence over --filter]:files:_files" +"--name=[Run test with the given full name]:files:_files" "--log-success=[Append the name of each successful test to the given file]:file:_files" "-e[Execute Lua statement]: :" "(-v --verbose --no-verbose)"{-v,--verbose}"[Verbose output of errors]"