Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
- options and arg naming rationalizations
- deprecation warning additions
  • Loading branch information
an853e committed Oct 12, 2020
1 parent 719f963 commit d8361a6
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 137 deletions.
4 changes: 2 additions & 2 deletions doc/source/MANUAL.rst
Expand Up @@ -141,11 +141,11 @@ with bar.
stestr allows you do to do simple test exclusion via passing a
exclusion regexp::

$ stestr run --exclusion-regex 'slow_tests|bad_tests'
$ stestr run --exclude-regex 'slow_tests|bad_tests'

stestr also allow you to combine these arguments::

$ stestr run --exclusion-regex 'slow_tests|bad_tests' ui\.interface
$ stestr run --exclude-regex 'slow_tests|bad_tests' ui\.interface

Here first we selected all tests which matches to ``ui\.interface``, then we
are dropping all test which matches ``slow_tests|bad_tests`` from the final
Expand Down
60 changes: 38 additions & 22 deletions stestr/commands/list.py
Expand Up @@ -14,6 +14,7 @@

from io import BytesIO
import sys
import warnings

from cliff import command

Expand Down Expand Up @@ -41,7 +42,7 @@ def get_parser(self, prog_name):
'replaced by --exclude-list which is '
'functionally equivalent.')
parser.add_argument('--exclude-list', '-e',
default=None, dest='exclusion_list_file',
default=None, dest='exclude_list',
help='Path to an exclusion list file, this file '
'contains a separate regex exclude on each '
'newline')
Expand All @@ -51,16 +52,16 @@ def get_parser(self, prog_name):
'replaced by --include-list which is '
'functionally equivalent.')
parser.add_argument('--include-list', '-i',
default=None, dest='inclusion_list_file',
default=None, dest='include_list',
help='Path to an inclusion list file, this file '
'contains a separate regex on each newline.')
parser.add_argument('--black-regex', '-B',
default=None, dest='black_regex',
help='DEPRECATED: This option will soon be '
'replaced by --exclusion-regex which is '
'replaced by --exclude-regex which is '
'functionally equivalent.')
parser.add_argument('--exclusion-regex', '-E',
default=None, dest='exclusion_regex',
parser.add_argument('--exclude-regex', '-E',
default=None, dest='exclude_regex',
help='Test rejection regex. If a test cases name '
'matches on re.search() operation , '
'it will be removed from the final test list. '
Expand All @@ -81,19 +82,19 @@ def take_action(self, parsed_args):
test_path=self.app_args.test_path,
top_dir=self.app_args.top_dir,
blacklist_file=args.blacklist_file,
exclusion_list_file=args.exclusion_list_file,
exclude_list=args.exclude_list,
whitelist_file=args.whitelist_file,
inclusion_list_file=args.inclusion_list_file,
include_list=args.include_list,
black_regex=args.black_regex,
exclusion_regex=args.exclusion_regex,
exclude_regex=args.exclude_regex,
filters=filters)


def list_command(config='.stestr.conf', repo_type='file', repo_url=None,
test_path=None, top_dir=None, group_regex=None,
blacklist_file=None, exclusion_list_file=None,
whitelist_file=None, inclusion_list_file=None,
black_regex=None, exclusion_regex=None, filters=None,
blacklist_file=None, exclude_list=None,
whitelist_file=None, include_list=None,
black_regex=None, exclude_regex=None, filters=None,
stdout=sys.stdout):
"""Print a list of test_ids for a project
Expand All @@ -115,16 +116,16 @@ def list_command(config='.stestr.conf', repo_type='file', repo_url=None,
together in the stestr scheduler. If both this and the corresponding
config file option are set this value will be used.
:param str blacklist_file: DEPRECATED: soon to be replaced by the new
option exclusion_list_file below.
:param str exclusion_list_file: Path to an exclusion list file, this file
option exclude_list below.
:param str exclude_list: Path to an exclusion list file, this file
contains a separate regex exclude on each newline.
:param str whitelist_file: DEPRECATED: soon to be replaced by the new
option inclusion_list_file below.
:param str inclusion_list_file: Path to an inclusion list file, this file
option include_list below.
:param str include_list: Path to an inclusion list file, this file
contains a separate regex on each newline.
:param str black_regex: DEPRECATED: soon to be replaced by the new
option exclusion_regex below.
:param str exclusion_regex: Test rejection regex. If a test cases name
option exclude_regex below.
:param str exclude_regex: Test rejection regex. If a test cases name
matches on re.search() operation, it will be removed from the final
test list.
:param list filters: A list of string regex filters to initially apply on
Expand All @@ -134,19 +135,34 @@ def list_command(config='.stestr.conf', repo_type='file', repo_url=None,
this is sys.stdout
"""
if blacklist_file is not None:
warnings.warn("The blacklist-file argument is deprecated and will be "
"removed in a future release. Instead you should use "
"exclude-list which is functionally equivalent",
DeprecationWarning)
if whitelist_file is not None:
warnings.warn("The whitelist-file argument is deprecated and will be "
"removed in a future release. Instead you should use "
"include-list which is functionally equivalent",
DeprecationWarning)
if black_regex is not None:
warnings.warn("The black-regex argument is deprecated and will be "
"removed in a future release. Instead you should use "
"exclude-regex which is functionally equivalent",
DeprecationWarning)
ids = None
conf = config_file.TestrConf(config)
cmd = conf.get_run_command(
regexes=filters, repo_type=repo_type,
repo_url=repo_url, group_regex=group_regex,
blacklist_file=blacklist_file, exclusion_list_file=exclusion_list_file,
whitelist_file=whitelist_file, inclusion_list_file=inclusion_list_file,
black_regex=black_regex, exclusion_regex=exclusion_regex,
blacklist_file=blacklist_file, exclude_list=exclude_list,
whitelist_file=whitelist_file, include_list=include_list,
black_regex=black_regex, exclude_regex=exclude_regex,
test_path=test_path, top_dir=top_dir)
not_filtered = filters is None and blacklist_file is None\
and whitelist_file is None and black_regex is None\
and inclusion_list_file is None and exclusion_list_file is None\
and exclusion_regex is None
and include_list is None and exclude_list is None\
and exclude_regex is None
try:
cmd.setUp()
# List tests if the fixture has not already needed to to filter.
Expand Down
72 changes: 41 additions & 31 deletions stestr/commands/run.py
Expand Up @@ -107,7 +107,7 @@ def get_parser(self, prog_name):
'replaced by --exclude-list which is functionally '
'equivalent.')
parser.add_argument('--exclude-list', '-e',
default=None, dest='exclusion_list_file',
default=None, dest='exclude_list',
help='Path to an exclusion list file, this file '
'contains a separate regex exclude on each '
'newline')
Expand All @@ -117,16 +117,16 @@ def get_parser(self, prog_name):
'replaced by --include-list which is functionally '
'equivalent.')
parser.add_argument('--include-list', '-i',
default=None, dest='inclusion_list_file',
default=None, dest='include_list',
help='Path to an inclusion list file, this file '
'contains a separate regex on each newline.')
parser.add_argument('--black-regex', '-B', default=None,
dest='black_regex',
help='DEPRECATED: This option will soon be '
'replaced by --exclusion-regex which is '
'replaced by --exclude-regex which is '
'functionally equivalent.')
parser.add_argument('--exclusion-regex', '-E', default=None,
dest='exclusion_regex',
parser.add_argument('--exclude-regex', '-E', default=None,
dest='exclude_regex',
help='Test rejection regex. If a test cases name '
'matches on re.search() operation , '
'it will be removed from the final test list. '
Expand Down Expand Up @@ -256,10 +256,9 @@ def take_action(self, parsed_args):
subunit_out=args.subunit, until_failure=args.until_failure,
analyze_isolation=args.analyze_isolation, isolated=args.isolated,
worker_path=args.worker_path, blacklist_file=args.blacklist_file,
exclusion_list_file=args.exclusion_list_file,
whitelist_file=args.whitelist_file,
inclusion_list_file=args.inclusion_list_file,
black_regex=args.black_regex, exclusion_regex=args.exclusion_regex,
exclude_list=args.exclude_list, whitelist_file=args.whitelist_file,
include_list=args.include_list,
black_regex=args.black_regex, exclude_regex=args.exclude_regex,
no_discover=args.no_discover, random=random, combine=args.combine,
filters=filters, pretty_out=pretty_out, color=color,
stdout=stdout, abbreviate=abbreviate,
Expand Down Expand Up @@ -303,9 +302,9 @@ def run_command(config='.stestr.conf', repo_type='file',
failing=False, serial=False, concurrency=0, load_list=None,
partial=False, subunit_out=False, until_failure=False,
analyze_isolation=False, isolated=False, worker_path=None,
blacklist_file=None, exclusion_list_file=None,
whitelist_file=None, inclusion_list_file=None,
black_regex=None, exclusion_regex=None, no_discover=False,
blacklist_file=None, exclude_list=None,
whitelist_file=None, include_list=None,
black_regex=None, exclude_regex=None, no_discover=False,
random=False, combine=False, filters=None, pretty_out=True,
color=False, stdout=sys.stdout, abbreviate=False,
suppress_attachments=False, all_attachments=False,
Expand Down Expand Up @@ -348,16 +347,16 @@ def run_command(config='.stestr.conf', repo_type='file',
:param str worker_path: Optional path of a manual worker grouping file
to use for the run.
:param str blacklist_file: DEPRECATED: soon to be replaced by the new
option exclusion_list_file below.
:param str exclusion_list_file: Path to an exclusion list file, this file
option exclude_list below.
:param str exclude_list: Path to an exclusion list file, this file
contains a separate regex exclude on each newline.
:param str whitelist_file: DEPRECATED: soon to be replaced by the new
option inclusion_list_file below.
:param str inclusion_list_file: Path to a inclusion list file, this file
option include_list below.
:param str include_list: Path to a inclusion list file, this file
contains a separate regex on each newline.
:param str black_regex: DEPRECATED: soon to be replaced by the new
option exclusion_regex below.
:param str exclusion_regex: Test rejection regex. If a test cases name
option exclude_regex below.
:param str exclude_regex: Test rejection regex. If a test cases name
matches on re.search() operation, it will be removed from the final
test list.
:param str no_discover: Takes in a single test_id to bypasses test
Expand Down Expand Up @@ -392,6 +391,21 @@ def run_command(config='.stestr.conf', repo_type='file',
if partial:
warnings.warn('The partial flag is deprecated and has no effect '
'anymore')
if blacklist_file is not None:
warnings.warn("The blacklist-file argument is deprecated and will be "
"removed in a future release. Instead you should use "
"exclude-list which is functionally equivalent",
DeprecationWarning)
if whitelist_file is not None:
warnings.warn("The whitelist-file argument is deprecated and will be "
"removed in a future release. Instead you should use "
"include-list which is functionally equivalent",
DeprecationWarning)
if black_regex is not None:
warnings.warn("The black-regex argument is deprecated and will be "
"removed in a future release. Instead you should use "
"exclude-regex which is functionally equivalent",
DeprecationWarning)
try:
repo = util.get_repo_open(repo_type, repo_url)
# If a repo is not found, and there a testr config exists just create it
Expand Down Expand Up @@ -535,10 +549,9 @@ def run_tests():
ids, regexes=filters, group_regex=group_regex, repo_type=repo_type,
repo_url=repo_url, serial=serial, worker_path=worker_path,
concurrency=concurrency, blacklist_file=blacklist_file,
exclusion_list_file=exclusion_list_file,
whitelist_file=whitelist_file,
inclusion_list_file=inclusion_list_file, black_regex=black_regex,
exclusion_regex=exclusion_regex,
exclude_list=exclude_list, whitelist_file=whitelist_file,
include_list=include_list, black_regex=black_regex,
exclude_regex=exclude_regex,
top_dir=top_dir, test_path=test_path, randomize=random)
if isolated:
result = 0
Expand All @@ -553,11 +566,9 @@ def run_tests():
[test_id], filters, group_regex=group_regex,
repo_type=repo_type, repo_url=repo_url, serial=serial,
worker_path=worker_path, concurrency=concurrency,
blacklist_file=blacklist_file,
exclusion_list_file=exclusion_list_file,
whitelist_file=whitelist_file,
inclusion_list_file=inclusion_list_file,
black_regex=black_regex, exclusion_regex=exclusion_regex,
blacklist_file=blacklist_file, exclude_list=exclude_list,
whitelist_file=whitelist_file, include_list=include_list,
black_regex=black_regex, exclude_regex=exclude_regex,
randomize=random, test_path=test_path, top_dir=top_dir)

run_result = _run_tests(
Expand Down Expand Up @@ -596,10 +607,9 @@ def run_tests():
[test_id], group_regex=group_regex, repo_type=repo_type,
repo_url=repo_url, serial=serial, worker_path=worker_path,
concurrency=concurrency, blacklist_file=blacklist_file,
exclusion_list_file=exclusion_list_file,
whitelist_file=whitelist_file,
inclusion_list_file=inclusion_list_file,
black_regex=black_regex, exclusion_regex=exclusion_regex,
exclude_list=exclude_list, whitelist_file=whitelist_file,
include_list=include_list,
black_regex=black_regex, exclude_regex=exclude_regex,
randomize=random, test_path=test_path, top_dir=top_dir)
if not _run_tests(cmd, until_failure):
# If the test was filtered, it won't have been run.
Expand Down
30 changes: 15 additions & 15 deletions stestr/config_file.py
Expand Up @@ -48,9 +48,9 @@ def get_run_command(self, test_ids=None, regexes=None,
repo_type='file', repo_url=None,
serial=False, worker_path=None,
concurrency=0, blacklist_file=None,
exclusion_list_file=None, whitelist_file=None,
inclusion_list_file=None, black_regex=None,
exclusion_regex=None,
exclude_list=None, whitelist_file=None,
include_list=None, black_regex=None,
exclude_regex=None,
randomize=False, parallel_class=None):
"""Get a test_processor.TestProcessorFixture for this config file
Expand Down Expand Up @@ -85,17 +85,17 @@ def get_run_command(self, test_ids=None, regexes=None,
to use for the run.
:param int concurrency: How many processes to use. The default (0)
autodetects your CPU count and uses that.
:param str blacklist_file: DEPRECATED: soon to be replaced by the new
option exclusion_list_file below.
:param str exclusion_list_file: Path to an exclusion list file, this
:param str blacklist_file: Available now but soon to be replaced by the
new option exclude_list below.
:param str exclude_list: Path to an exclusion list file, this
file contains a separate regex exclude on each newline.
:param str whitelist_file: DEPRECATED: soon to be replaced by the new
option inclusion_list_file below.
:param str inclusion_list_file: Path to an inclusion list file, this
:param str whitelist_file: Available now but soon to be replaced by the
new option include_list below.
:param str include_list: Path to an inclusion list file, this
file contains a separate regex on each newline.
:param str black_regex: DEPRECATED: soon to be replaced by the new
option exclusion_regex below.
:param str exclusion_regex: Test rejection regex. If a test cases name
:param str black_regex: Available now but soon to be replaced by the
new option exclude_regex below.
:param str exclude_regex: Test rejection regex. If a test cases name
matches on re.search() operation, it will be removed from the final
test list.
:param bool randomize: Randomize the test order after they are
Expand Down Expand Up @@ -174,6 +174,6 @@ def group_callback(test_id, regex=re.compile(group_regex)):
test_filters=regexes, group_callback=group_callback, serial=serial,
worker_path=worker_path, concurrency=concurrency,
blacklist_file=blacklist_file,
exclusion_list_file=exclusion_list_file, black_regex=black_regex,
exclusion_regex=exclusion_regex, whitelist_file=whitelist_file,
inclusion_list_file=inclusion_list_file, randomize=randomize)
exclude_list=exclude_list, black_regex=black_regex,
exclude_regex=exclude_regex, whitelist_file=whitelist_file,
include_list=include_list, randomize=randomize)

0 comments on commit d8361a6

Please sign in to comment.