Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dynamic-schedule
Browse files Browse the repository at this point in the history
Conflicts:
	stestr/commands/run.py
	stestr/output.py
	stestr/test_processor.py
	stestr/tests/test_return_codes.py
  • Loading branch information
mtreinish committed Aug 9, 2020
2 parents e68b506 + 7a5cee7 commit e47ad6e
Show file tree
Hide file tree
Showing 36 changed files with 208 additions and 214 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ matrix:
env: TOXENV=pep8
- python: "3.6"
env: TOXENV=docs
- python: "2.7"
env: TOXENV=py27
- if: tag IS present
python: "3.6"
env:
- TWINE_USERNAME=stestr-release
install: pip install -U twine
script:
- python3 setup.py sdist bdist_wheel --universal
- python3 setup.py sdist bdist_wheel
- twine upload dist/stestr*

cache:
Expand Down
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ stestr
.. _日本語: https://github.com/mtreinish/stestr/blob/master/README_ja.rst

.. note:: stestr v2.x.x release series will be the last series that supports
Python 2. Support for Python 2.7 will be dropped in stestr release 3.0.0
which is being planned for early 2020.
Python 2. Support for Python 2.7 was dropped in stestr release 3.0.0.

Overview
--------
Expand Down
4 changes: 2 additions & 2 deletions README_ja.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ stestr(日本語訳)
.. _日本語: https://github.com/mtreinish/stestr/blob/master/README_ja.rst

.. note:: stestr v2.x.x リリースシリーズは、Python 2 をサポートする最後のシリ
ーズとなります。Python 2.7のサポートは、2020年の早い時期に予定されている、
「stestr リリース 3.0.0」にて打ち切られる予定です
ーズとなります。Python 2.7のサポートは「stestr リリース 3.0.0」
にて打ち切られました

概要
----
Expand Down
4 changes: 0 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
pool: {vmImage: 'vs2017-win2016'}
strategy:
matrix:
Python27:
python.version: '2.7'
Python35:
python.version: '3.5'
Python36:
Expand Down Expand Up @@ -42,8 +40,6 @@ jobs:
pool: {vmImage: 'macOS-10.14'}
strategy:
matrix:
Python27:
python.version: '2.7'
Python35:
python.version: '3.5'
Python36:
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
future
pbr!=2.1.0,>=2.0.0,!=4.0.0,!=4.0.1,!=4.0.2,!=4.0.3 # Apache-2.0
cliff>=2.8.0 # Apache-2.0
python-subunit>=1.3.0 # Apache-2.0/BSD
python-subunit>=1.4.0 # Apache-2.0/BSD
fixtures>=3.0.0 # Apache-2.0/BSD
six>=1.10.0 # MIT
testtools>=2.2.0 # MIT
PyYAML>=3.10.0 # MIT
voluptuous>=0.8.9 # BSD License
7 changes: 1 addition & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ classifier =
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Expand All @@ -27,7 +25,7 @@ project_urls =
Documentation = https://stestr.readthedocs.io
Source Code = https://github.com/mtreinish/stestr
Bug Tracker = https://github.com/mtreinish/stestr/issues
requires-python = >=2.7
python-requires = >=3.5

[files]
packages =
Expand All @@ -49,9 +47,6 @@ stestr.cm =
sql =
subunit2sql>=1.8.0

[bdist_wheel]
universal=1

[build_sphinx]
source-dir = doc/source
build-dir = doc/build
Expand Down
7 changes: 0 additions & 7 deletions stestr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# under the License.

import sys
import warnings

from cliff import app
from cliff import commandmanager
Expand Down Expand Up @@ -108,12 +107,6 @@ def _set_common_opts(self, parser):


def main(argv=sys.argv[1:]):
if sys.version_info[:2] == (2, 7):
msg = (
"Python 2.7 will reach the end of its life on January 1st, 2020. "
"Support for using python 2.7 with stestr will be removed in the "
"3.0.0 release in early 2020")
warnings.warn(msg, DeprecationWarning, stacklevel=2)
cli = StestrCLI()
return cli.run(argv)

Expand Down
2 changes: 1 addition & 1 deletion stestr/colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def write(self, text, color):
@param color: A string label for a color. e.g. 'red', 'white'.
"""
color = self._colors[color]
self.stream.write('\x1b[%s;1m%s\x1b[0m' % (color, text))
self.stream.write('\x1b[{};1m{}\x1b[0m'.format(color, text))


class NullColorizer(object):
Expand Down
20 changes: 14 additions & 6 deletions stestr/commands/last.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def get_parser(self, prog_name):
dest='all_attachments',
help='If set print all text attachment contents on'
' a successful test execution')
parser.add_argument('--show-binary-attachments', action='store_true',
dest='show_binary_attachments',
help='If set, show non-text attachments. This is '
'generally only useful for debug purposes.')
return parser

def take_action(self, parsed_args):
Expand Down Expand Up @@ -108,12 +112,13 @@ def take_action(self, parsed_args):
repo_url=self.app_args.repo_url,
subunit_out=args.subunit, pretty_out=pretty_out,
color=color, suppress_attachments=suppress_attachments,
all_attachments=all_attachments)
all_attachments=all_attachments,
show_binary_attachments=args.show_binary_attachments)


def last(repo_type='file', repo_url=None, subunit_out=False, pretty_out=True,
color=False, stdout=sys.stdout, suppress_attachments=False,
all_attachments=False):
all_attachments=False, show_binary_attachments=False):
"""Show the last run loaded into a a repository
This function will print the results from the last run in the repository
Expand All @@ -137,6 +142,8 @@ def last(repo_type='file', repo_url=None, subunit_out=False, pretty_out=True,
will not print attachments on successful test execution.
:param bool all_attachments: When set true subunit_trace will print all
text attachments on successful test execution.
:param bool show_binary_attachments: When set to true, subunit_trace will
print binary attachments in addition to text attachments.
:return return_code: The exit code for the command. 0 for success and > 0
for failures.
Expand Down Expand Up @@ -182,10 +189,11 @@ def last(repo_type='file', repo_url=None, subunit_out=False, pretty_out=True,
failed = not results.wasSuccessful(summary)
else:
stream = latest_run.get_subunit_stream()
failed = subunit_trace.trace(stream, stdout, post_fails=True,
color=color,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments)
failed = subunit_trace.trace(
stream, stdout, post_fails=True, color=color,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments,
show_binary_attachments=show_binary_attachments)
if failed:
return 1
else:
Expand Down
21 changes: 15 additions & 6 deletions stestr/commands/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def get_parser(self, prog_name):
dest='all_attachments',
help='If set print all text attachment contents on'
' a successful test execution')
parser.add_argument('--show-binary-attachments', action='store_true',
dest='show_binary_attachments',
help='If set, show non-text attachments. This is '
'generally only useful for debug purposes.')
return parser

def take_action(self, parsed_args):
Expand Down Expand Up @@ -134,14 +138,15 @@ def take_action(self, parsed_args):
pretty_out=pretty_out, color=color,
stdout=stdout, abbreviate=abbreviate,
suppress_attachments=suppress_attachments, serial=True,
all_attachments=all_attachments)
all_attachments=all_attachments,
show_binary_attachments=args.show_binary_attachments)


def load(force_init=False, in_streams=None,
partial=False, subunit_out=False, repo_type='file', repo_url=None,
run_id=None, streams=None, pretty_out=False, color=False,
stdout=sys.stdout, abbreviate=False, suppress_attachments=False,
serial=False, all_attachments=False):
serial=False, all_attachments=False, show_binary_attachments=False):
"""Load subunit streams into a repository
This function will load subunit streams into the repository. It will
Expand Down Expand Up @@ -172,6 +177,8 @@ def load(force_init=False, in_streams=None,
will not print attachments on successful test execution.
:param bool all_attachments: When set true subunit_trace will print all
text attachments on successful test execution.
:param bool show_binary_attachments: When set to true, subunit_trace will
print binary attachments in addition to text attachments.
:return return_code: The exit code for the command. 0 for success and > 0
for failures.
Expand Down Expand Up @@ -233,7 +240,8 @@ def make_tests():
stream, non_subunit_name='stdout')
result = _load_case(inserter, repo, case, subunit_out, pretty_out,
color, stdout, abbreviate,
suppress_attachments, all_attachments)
suppress_attachments, all_attachments,
show_binary_attachments)
if result or retval:
retval = 1
else:
Expand All @@ -242,14 +250,14 @@ def make_tests():
case = testtools.ConcurrentStreamTestSuite(make_tests)
retval = _load_case(inserter, repo, case, subunit_out, pretty_out,
color, stdout, abbreviate, suppress_attachments,
all_attachments)
all_attachments, show_binary_attachments)

return retval


def _load_case(inserter, repo, case, subunit_out, pretty_out,
color, stdout, abbreviate, suppress_attachments,
all_attachments):
all_attachments, show_binary_attachments):
if subunit_out:
output_result, summary_result = output.make_result(inserter.get_id,
output=stdout)
Expand All @@ -258,7 +266,8 @@ def _load_case(inserter, repo, case, subunit_out, pretty_out,
functools.partial(subunit_trace.show_outcome, stdout,
enable_color=color, abbreviate=abbreviate,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments))
all_attachments=all_attachments,
show_binary_attachments=show_binary_attachments))
summary_result = testtools.StreamSummary()
output_result = testtools.CopyStreamResult([outcomes, summary_result])
output_result = testtools.StreamResultRouter(output_result)
Expand Down
37 changes: 25 additions & 12 deletions stestr/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import warnings

from cliff import command
import six
import subunit
import testtools

Expand All @@ -46,7 +45,7 @@ def _to_int(possible, default=0, out=sys.stderr):
i = default
msg = ('Unable to convert "%s" to an integer. Using %d.\n' %
(possible, default))
out.write(six.text_type(msg))
out.write(str(msg))
return i


Expand Down Expand Up @@ -170,6 +169,10 @@ def get_parser(self, prog_name):
' a successful test execution')
parser.add_argument('--dynamic', action='store_true', default=False,
help='Enable the EXPERIMENTAL dynamic scheduler')
parser.add_argument('--show-binary-attachments', action='store_true',
dest='show_binary_attachments',
help='If set, show non-text attachments. This is '
'generally only useful for debug purposes.')
return parser

def take_action(self, parsed_args):
Expand Down Expand Up @@ -246,8 +249,9 @@ def take_action(self, parsed_args):
filters=filters, pretty_out=pretty_out, color=color,
stdout=stdout, abbreviate=abbreviate,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments, pdb=args.pdb,
dynamic=args.dynamic)
all_attachments=all_attachments,
show_binary_attachments=args.show_binary_attachments,
pdb=args.pdb, dynamic=args.dynamic)

# Always output slowest test info if requested, regardless of other
# test run options
Expand Down Expand Up @@ -288,7 +292,8 @@ def run_command(config='.stestr.conf', repo_type='file',
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, pdb=False, dynamic=False):
all_attachments=False, show_binary_attachments=True,
pdb=False, dynamic=False):
"""Function to execute the run command
This function implements the run command. It will run the tests specified
Expand Down Expand Up @@ -351,6 +356,8 @@ def run_command(config='.stestr.conf', repo_type='file',
will not print attachments on successful test execution.
:param bool all_attachments: When set true subunit_trace will print all
text attachments on successful test execution.
:param bool show_binary_attachments: When set to true, subunit_trace will
print binary attachments in addition to text attachments.
:param str pdb: Takes in a single test_id to bypasses test
discover and just execute the test specified without launching any
additional processes. A file name may be used in place of a test name.
Expand Down Expand Up @@ -401,7 +408,7 @@ def run_command(config='.stestr.conf', repo_type='file',
"You might encounter issues while using it")
if combine:
latest_id = repo.latest_id()
combine_id = six.text_type(latest_id)
combine_id = str(latest_id)
if no_discover and pdb:
msg = ("--no-discover and --pdb are mutually exclusive options, "
"only specify one at a time")
Expand Down Expand Up @@ -443,7 +450,8 @@ def run_tests():
pretty_out=pretty_out,
color=color, stdout=stdout, abbreviate=abbreviate,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments)
all_attachments=all_attachments,
show_binary_attachments=show_binary_attachments)

if not until_failure:
return run_tests()
Expand Down Expand Up @@ -488,7 +496,8 @@ def run_tests():
pretty_out=pretty_out,
color=color, stdout=stdout, abbreviate=abbreviate,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments)
all_attachments=all_attachments,
show_binary_attachments=show_binary_attachments)

if failing or analyze_isolation:
ids = _find_failing(repo)
Expand Down Expand Up @@ -539,8 +548,9 @@ def run_tests():
repo_type=repo_type, repo_url=repo_url,
pretty_out=pretty_out, color=color, abbreviate=abbreviate,
stdout=stdout, suppress_attachments=suppress_attachments,
all_attachments=all_attachments, dynamic=dynamic)

all_attachments=all_attachments,
show_binary_attachments=show_binary_attachments,
dynamic=dynamic)
if run_result > result:
result = run_result
return result
Expand All @@ -556,6 +566,7 @@ def run_tests():
abbreviate=abbreviate,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments,
show_binary_attachments=show_binary_attachments,
dynamic=dynamic)
else:
# Where do we source data about the cause of conflicts.
Expand Down Expand Up @@ -601,7 +612,8 @@ def _run_tests(cmd, until_failure,
subunit_out=False, combine_id=None, repo_type='file',
repo_url=None, pretty_out=True, color=False, stdout=sys.stdout,
abbreviate=False, suppress_attachments=False,
all_attachments=False, dynamic=False):
all_attachments=False, show_binary_attachments=False,
dynamic=False):
"""Run the tests cmd was parameterised with."""
cmd.setUp()
try:
Expand All @@ -626,7 +638,8 @@ def run_tests():
pretty_out=pretty_out, color=color, stdout=stdout,
abbreviate=abbreviate,
suppress_attachments=suppress_attachments,
all_attachments=all_attachments)
all_attachments=all_attachments,
show_binary_attachments=show_binary_attachments)

if not until_failure:
return run_tests()
Expand Down
4 changes: 2 additions & 2 deletions stestr/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import re
import sys

from six.moves import configparser
import configparser

from stestr.repository import util
from stestr import test_processor
Expand Down Expand Up @@ -108,7 +108,7 @@ def get_run_command(self, test_ids=None, regexes=None,
test_path = self.parser.get('DEFAULT', 'test_path')
elif not test_path:
sys.exit("No test_path can be found in either the command line "
"options nor in the specified config file {0}. Please "
"options nor in the specified config file {}. Please "
"specify a test path either in the config file or via "
"the --test-path argument".format(self.config_file))
if not top_dir and self.parser.has_option('DEFAULT', 'top_dir'):
Expand Down
Loading

0 comments on commit e47ad6e

Please sign in to comment.