pax_global_header00006660000000000000000000000064135447155750014532gustar00rootroot0000000000000052 comment=d551984cceee8927289b5463aaf21bf003cfd8b0 colcon-test-result-0.3.8/000077500000000000000000000000001354471557500153105ustar00rootroot00000000000000colcon-test-result-0.3.8/.travis.yml000066400000000000000000000007561354471557500174310ustar00rootroot00000000000000language: python python: "3.5" dist: trusty sudo: true install: - pip install -U setuptools # install_requires - pip install -U git+https://github.com/colcon/colcon-core # tests_require - pip install -U flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-quotes pep8-naming pylint pytest pytest-cov scspell3k script: # invoke pytest - pytest --cov=colcon_test_result --cov-branch notifications: email: false colcon-test-result-0.3.8/LICENSE000066400000000000000000000261361354471557500163250ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. colcon-test-result-0.3.8/README.rst000066400000000000000000000002361354471557500170000ustar00rootroot00000000000000colcon-test-result ================== An extension for `colcon-core `_ to provide information about the test results. colcon-test-result-0.3.8/appveyor.yml000066400000000000000000000011341354471557500176770ustar00rootroot00000000000000version: '{build}' environment: matrix: - PYTHON: "C:\\Python36-x64" install: - "%PYTHON%\\python.exe -m pip install -U setuptools" # install_requires - "%PYTHON%\\python.exe -m pip install -U git+https://github.com/colcon/colcon-core" # tests_require - "%PYTHON%\\python.exe -m pip install -U flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-quotes pep8-naming pylint pytest pytest-cov scspell3k" build: off test_script: # invoke pytest - "%PYTHON%\\python.exe -m pytest --cov=colcon_test_result --cov-branch" colcon-test-result-0.3.8/colcon_test_result/000077500000000000000000000000001354471557500212225ustar00rootroot00000000000000colcon-test-result-0.3.8/colcon_test_result/__init__.py000066400000000000000000000001521354471557500233310ustar00rootroot00000000000000# Copyright 2016-2018 Dirk Thomas # Licensed under the Apache License, Version 2.0 __version__ = '0.3.8' colcon-test-result-0.3.8/colcon_test_result/test_result/000077500000000000000000000000001354471557500235775ustar00rootroot00000000000000colcon-test-result-0.3.8/colcon_test_result/test_result/__init__.py000066400000000000000000000111751354471557500257150ustar00rootroot00000000000000# Copyright 2016-2019 Dirk Thomas # Licensed under the Apache License, Version 2.0 import inspect from pathlib import Path import traceback from colcon_core.logging import colcon_logger from colcon_core.plugin_system import instantiate_extensions from colcon_core.plugin_system import order_extensions_by_name logger = colcon_logger.getChild(__name__) class Result: """Statistics from a set of tests.""" __slots__ = ( 'path', 'test_count', 'error_count', 'failure_count', 'skipped_count', 'details', ) def __init__(self, path): # noqa: D107 self.path = path self.test_count = 0 self.error_count = 0 self.failure_count = 0 self.skipped_count = 0 self.details = [] def add_result(self, result): """ Add the statistics from another result to this one. The `path` is not changed. :param result: The other result """ self.test_count += result.test_count self.error_count += result.error_count self.failure_count += result.failure_count self.skipped_count += result.skipped_count self.details += result.details def __str__(self): # noqa: D105 data = {} for slot in self.__slots__: data[slot] = getattr(self, slot) if slot in ('test_count', 'error_count', 'failure_count'): data[slot + '_plural'] = 's' if data[slot] != 1 else '' return \ '{path}: ' \ '{test_count} test{test_count_plural}, ' \ '{error_count} error{error_count_plural}, ' \ '{failure_count} failure{failure_count_plural}, ' \ '{skipped_count} skipped' \ .format(**data) class TestResultExtensionPoint: """ The interface for test result extensions. A test result extension provides information about previously run tests. For each instance the attribute `TEST_RESULT_NAME` is being set to the basename of the entry point registering the extension. """ """The version of the test result extension interface.""" EXTENSION_POINT_VERSION = '1.0' def get_test_results(self, basepath, *, collect_details, files=None): """ Get all test results under the given basepath. This method must be overridden in a subclass. :param basepath: The basepath to crawl for test results :param collect_details: A flag if details for errors and failures should be collected :param files: If passed the argument must be a set and it is being populated with all files providing result information :returns: A set of Result instances """ raise NotImplementedError() def get_test_result_extensions(*, exclude_names=None): """ Get the available test result extensions. The extensions are ordered by their entry point name. :rtype: OrderedDict """ extensions = instantiate_extensions(__name__, exclude_names=exclude_names) for name, extension in extensions.items(): extension.TEST_RESULT_NAME = name return order_extensions_by_name(extensions) def get_test_results(basepath, *, collect_details, files=None): """ Get the test results. :param basepath: The basepath to collect test results from :param collect_details: A flag if details for errors and failures should be collected :param files: If passed the argument must be a set and it is being populated with all files providing result information :returns: A set of Result instances """ extensions = get_test_result_extensions() all_test_results = set() for extension in extensions.values(): logger.log(1, 'get_test_results(%s)', extension.TEST_RESULT_NAME) func = extension.get_test_results signature = inspect.signature(func) kwargs = {'collect_details': collect_details} if 'files' in signature.parameters: kwargs['files'] = files try: test_results = func( Path(basepath), **kwargs) assert isinstance(test_results, set), \ 'get_test_results() should return a set' except Exception as e: # noqa: F841 # catch exceptions raised in test result extension exc = traceback.format_exc() logger.error( 'Exception in test result extension ' "'{extension.TEST_RESULT_NAME}': {e}\n{exc}" .format_map(locals())) # skip failing extension, continue with next one continue all_test_results |= test_results return all_test_results colcon-test-result-0.3.8/colcon_test_result/test_result/xunit.py000066400000000000000000000200331354471557500253160ustar00rootroot00000000000000# Copyright 2016-2019 Dirk Thomas # Licensed under the Apache License, Version 2.0 import os import traceback from xml.etree.ElementTree import ElementTree from xml.etree.ElementTree import ParseError from colcon_core.logging import colcon_logger from colcon_core.plugin_system import satisfies_version from colcon_test_result.test_result import Result from colcon_test_result.test_result import TestResultExtensionPoint logger = colcon_logger.getChild(__name__) class XunitTestResult(TestResultExtensionPoint): """ Collect the xUnit results generated when testing a set of packages. It recursively crawls for XML files under the passed build base. Each XML file is being parsed and if it has the structure of a xUnit result file the statistics are being extracted. """ def __init__(self): # noqa: D107 super().__init__() satisfies_version( TestResultExtensionPoint.EXTENSION_POINT_VERSION, '^1.0') def get_test_results( self, basepath, *, collect_details, files=None ): # noqa: D102 results = set() for dirpath, dirnames, filenames in os.walk(str(basepath)): # skip subdirectories starting with a dot dirnames[:] = filter(lambda d: not d.startswith('.'), dirnames) dirnames.sort() for filename in sorted(filenames): if not filename.endswith('.xml'): continue path = os.path.join(dirpath, filename) try: result = parse_xunit_xml( path, get_testcases=collect_details) except ParseError as e: # noqa: F841 logger.warning( "Skipping '{path}': {e}".format_map(locals())) continue except ValueError as e: # noqa: F841 logger.debug("Skipping '{path}': {e}".format_map(locals())) continue except Exception as e: # noqa: F841 exc = traceback.format_exc() logger.error( "Skipping '{path}': {e}\n{exc}".format_map(locals())) continue results.add(result) if files is not None: files.add(path) return results def parse_xunit_xml(path, *, get_testcases=False): """ Parse an XML file and interpret it as a xUnit result file. See https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#generating-an-xml-report for an example of the format. :param str path: the path of the XML file :param parse_testcases: the flag if more information from each test case should be extracted :type parse_testcases: bool :returns: a result containing the stats :rtype: :py:class:`colcon_core.verb.test_results.Result` :raises ParseError: if the XML is not well-formed :raises TypeError: if the root node is neither named 'testsuite' nor 'testsuites' """ tree = ElementTree() root = tree.parse(path) result = Result(path) if root.tag == 'testsuites': for child in root: if child.tag == 'testsuite': result.add_result( _get_testsuite_result(child, get_testcases=get_testcases)) elif root.tag == 'testsuite': result.add_result( _get_testsuite_result(root, get_testcases=get_testcases)) else: raise ValueError( "the root tag is neither 'testsuite' nor 'testsuites'") return result def _get_testsuite_result(node, *, get_testcases=False): # extract the integer values from various attributes result = Result('') for slot, attribute, default in ( ('test_count', 'tests', None), ('error_count', 'errors', 0), ('failure_count', 'failures', None), ('skipped_count', 'skip', 0), ('skipped_count', 'skipped', 0), ('skipped_count', 'disabled', 0), ): try: value = node.attrib[attribute] except KeyError: if default is None: raise ValueError( "the '{attribute}' attribute is required" .format_map(locals())) value = default try: value = int(value) except ValueError: raise ValueError( "the '{attribute}' attribute should be an integer" .format_map(locals())) if value < 0: raise ValueError( "the '{attribute}' attribute should be a positive integer" .format_map(locals())) setattr(result, slot, getattr(result, slot) + value) if get_testcases: result.details += parse_testcases(node) return result def parse_testcases(node): """ Parse information about testcases with errors and failures. :param node: The XML node :returns: A string for each testcase :rtype: list """ testcases = [] # recursively process test suites if node.tag == 'testsuites': for child in node: testcases += parse_testcases(child) return testcases if node.tag != 'testsuite': return testcases # extract information for child in node: if child.tag != 'testcase': continue # extract information from test case testcase = Testcase( classname=child.attrib.get('classname'), file_=child.attrib.get('file'), line=child.attrib.get('line'), name=child.attrib.get('name'), time=child.attrib.get('time')) for child2 in child: if child2.tag == 'error': testcase.error_messages.append( child2.attrib.get('message', '')) elif child2.tag == 'failure': testcase.failure_messages.append( child2.attrib.get('message', '')) elif child2.tag == 'system-out': testcase.system_outs.append(child2.text) elif child2.tag == 'system-err': testcase.system_errs.append(child2.text) if testcase.error_messages or testcase.failure_messages: testcases.append(str(testcase)) return testcases class Testcase: """Information from a `testcase` tag.""" __slots__ = ( 'classname', 'file', 'line', 'name', 'time', 'error_messages', 'failure_messages', 'system_outs', 'system_errs', ) __test__ = False # prevent the class to falsely be identified as a test def __init__( self, *, classname=None, file_=None, line=None, name=None, time=None ): # noqa: D107 self.classname = classname self.file = file_ self.line = line self.name = name self.time = float(time) if time is not None else None self.error_messages = [] self.failure_messages = [] self.system_outs = [] self.system_errs = [] def __str__(self): # noqa: D105 # label of testcase msg_parts = [] if self.classname: msg_parts.append(self.classname) if self.name: msg_parts.append(self.name) if self.file: suffix = ':' + self.line if self.line else '' msg_parts.append( '({self.file}{suffix})'.format_map(locals())) msg_parts = [' '.join(msg_parts)] # more information msg_parts += _get_messages('error message', self.error_messages) msg_parts += _get_messages( 'failure message', self.failure_messages) msg_parts += _get_messages('stdout output', self.system_outs) msg_parts += _get_messages('stderr output', self.system_errs) return '\n'.join(msg_parts) def _get_messages(label, messages): lines = [] if messages: lines.append('<<< ' + label) for message in messages: for line in message.strip('\n\r').splitlines(): lines.append(' ' + line) lines.append('>>>') return lines colcon-test-result-0.3.8/colcon_test_result/verb/000077500000000000000000000000001354471557500221605ustar00rootroot00000000000000colcon-test-result-0.3.8/colcon_test_result/verb/__init__.py000066400000000000000000000000001354471557500242570ustar00rootroot00000000000000colcon-test-result-0.3.8/colcon_test_result/verb/test_result.py000066400000000000000000000107411354471557500251120ustar00rootroot00000000000000# Copyright 2016-2019 Dirk Thomas # Licensed under the Apache License, Version 2.0 import argparse import os import sys from colcon_core.logging import colcon_logger from colcon_core.plugin_system import satisfies_version from colcon_core.verb import VerbExtensionPoint from colcon_test_result.test_result import get_test_results from colcon_test_result.test_result import Result logger = colcon_logger.getChild(__name__) class TestResultVerb(VerbExtensionPoint): """Show the test results generated when testing a set of packages.""" __test__ = False # prevent the class to falsely be identified as a test def __init__(self): # noqa: D107 super().__init__() satisfies_version(VerbExtensionPoint.EXTENSION_POINT_VERSION, '^1.0') def add_arguments(self, *, parser): # noqa: D102 parser.add_argument( '--test-result-base', type=_argparse_existing_dir, default='build', help='The base path for all test results (default: build)') parser.add_argument( '--all', action='store_true', help='Show all test result files (even without errors / failures)') parser.add_argument( '--result-files-only', action='store_true', help='Print only the paths of the result files. ' 'Use with --all to include files without errors / failures') parser.add_argument( '--verbose', action='store_true', help='Show additional information for errors / failures') parser.add_argument( '--delete', action='store_true', help='Delete all result files. This might include additional ' 'files beside what is listed by --result-files-only. An ' 'interactive prompt will ask for confirmation') parser.add_argument( '--delete-yes', action='store_true', help='Same as --delete without an interactive confirmation') def main(self, *, context): # noqa: D102 all_files = set() \ if (context.args.delete or context.args.delete_yes) else None all_results = list(get_test_results( context.args.test_result_base, collect_details=context.args.verbose, files=all_files)) if context.args.delete or context.args.delete_yes: if not all_files: print('No result files found to delete') return 0 for path in sorted(all_files): print('-', path) while not context.args.delete_yes: response = _safe_input( 'Delete these %d files? [y/n] ' % len(all_files)) if response.lower() == 'y': break if response.lower() == 'n': print('Aborted') return 0 for path in sorted(all_files): os.remove(path) print('Deleted %d files' % len(all_files)) return 0 results = [ r for r in all_results if r.error_count or r.failure_count or context.args.all] results.sort(key=lambda r: r.path) if context.args.result_files_only: for result in results: print(result.path) else: for result in results: print(result) if context.args.verbose: for detail in result.details: for i, line in enumerate(detail.splitlines()): print('-' if i == 0 else ' ', line) summary = Result('Summary') for result in all_results: summary.add_result(result) if not context.args.result_files_only: if results: print() print(summary) return 1 if summary.error_count or summary.failure_count else 0 def _argparse_existing_dir(path): if not os.path.exists(path): raise argparse.ArgumentTypeError("Path '%s' does not exist" % path) if not os.path.isdir(path): raise argparse.ArgumentTypeError("Path '%s' is not a directory" % path) return path def _safe_input(prompt=None): # flush stdin before checking for input try: from termios import tcflush from termios import TCIFLUSH tcflush(sys.stdin, TCIFLUSH) except ImportError: # fallback if not supported on some platforms pass return input(prompt) colcon-test-result-0.3.8/setup.cfg000066400000000000000000000033131354471557500171310ustar00rootroot00000000000000[metadata] name = colcon-test-result version = attr: colcon_test_result.__version__ url = https://colcon.readthedocs.io project_urls = Changelog = https://github.com/colcon/colcon-test-result/milestones?direction=desc&sort=due_date&state=closed GitHub = https://github.com/colcon/colcon-test-result/ author = Dirk Thomas author_email = web@dirk-thomas.net maintainer = Dirk Thomas maintainer_email = web@dirk-thomas.net classifiers = Development Status :: 3 - Alpha Environment :: Plugins Intended Audience :: Developers License :: OSI Approved :: Apache Software License Operating System :: MacOS Operating System :: Microsoft :: Windows Operating System :: POSIX Programming Language :: Python Topic :: Software Development :: Build Tools license = Apache License, Version 2.0 description = Extension for colcon to provide information about the test results. long_description = file: README.rst keywords = colcon [options] install_requires = colcon-core packages = find: tests_require = flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes pep8-naming pylint pytest pytest-cov scspell3k>=2.2 zip_safe = true [tool:pytest] filterwarnings = error junit_suite_name = colcon-test-result [options.entry_points] colcon_core.extension_point = colcon_test_result.test_result = colcon_test_result.test_result:TestResultExtensionPoint colcon_core.verb = test-result = colcon_test_result.verb.test_result:TestResultVerb colcon_test_result.test_result = xunit = colcon_test_result.test_result.xunit:XunitTestResult [flake8] import-order-style = google colcon-test-result-0.3.8/setup.py000066400000000000000000000001721354471557500170220ustar00rootroot00000000000000# Copyright 2016-2018 Dirk Thomas # Licensed under the Apache License, Version 2.0 from setuptools import setup setup() colcon-test-result-0.3.8/stdeb.cfg000066400000000000000000000001751354471557500170750ustar00rootroot00000000000000[colcon-test-result] No-Python2: Depends3: python3-colcon-core Suite: xenial bionic stretch buster X-Python3-Version: >= 3.5 colcon-test-result-0.3.8/test/000077500000000000000000000000001354471557500162675ustar00rootroot00000000000000colcon-test-result-0.3.8/test/spell_check.words000066400000000000000000000003331354471557500216220ustar00rootroot00000000000000apache argparse basepath classname colcon etree github google googletest https iterdir noqa pathlib plugin pytest rtype scspell setuptools tcflush tciflush testcase testcases testsuite testsuites thomas traceback xunit colcon-test-result-0.3.8/test/test_copyright_license.py000066400000000000000000000024161354471557500234150ustar00rootroot00000000000000# Copyright 2016-2018 Dirk Thomas # Licensed under the Apache License, Version 2.0 from pathlib import Path import sys def test_copyright_license(): missing = check_files([Path(__file__).parents[1]]) assert not len(missing), \ 'In some files no copyright / license line was found' def check_files(paths): missing = [] for path in paths: if path.is_dir(): for p in sorted(path.iterdir()): if p.name.startswith('.'): continue if p.name.endswith('.py') or p.is_dir(): missing += check_files([p]) if path.is_file(): content = path.read_text() if not content: continue lines = content.splitlines() has_copyright = \ any(l for l in lines if l.startswith('# Copyright')) has_license = \ '# Licensed under the Apache License, Version 2.0' in lines if not has_copyright or not has_license: print( 'Could not find copyright / license in:', path, file=sys.stderr) missing .append(path) else: print('Found copyright / license in:', path) return missing colcon-test-result-0.3.8/test/test_flake8.py000066400000000000000000000030051354471557500210500ustar00rootroot00000000000000# Copyright 2016-2018 Dirk Thomas # Licensed under the Apache License, Version 2.0 import logging from pathlib import Path import sys from flake8 import LOG from flake8.api.legacy import get_style_guide # avoid debug and info messages from flake8 internals LOG.setLevel(logging.WARN) def test_flake8(): style_guide = get_style_guide( extend_ignore=['D100', 'D104'], show_source=True, ) style_guide_tests = get_style_guide( extend_ignore=['D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D107'], show_source=True, ) stdout = sys.stdout sys.stdout = sys.stderr # implicitly calls report_errors() report = style_guide.check_files([ str(Path(__file__).parents[1] / 'colcon_test_result'), ]) report_tests = style_guide_tests.check_files([ str(Path(__file__).parents[1] / 'test'), ]) sys.stdout = stdout total_errors = report.total_errors + report_tests.total_errors if total_errors: # pragma: no cover # output summary with per-category counts print() if report.total_errors: report._application.formatter.show_statistics(report._stats) if report_tests.total_errors: report_tests._application.formatter.show_statistics( report_tests._stats) print( 'flake8 reported {total_errors} errors' .format_map(locals()), file=sys.stderr) assert not total_errors, \ 'flake8 reported {total_errors} errors'.format_map(locals()) colcon-test-result-0.3.8/test/test_spell_check.py000066400000000000000000000035601354471557500221600ustar00rootroot00000000000000# Copyright 2016-2019 Dirk Thomas # Licensed under the Apache License, Version 2.0 from pathlib import Path import pytest from scspell import Report from scspell import SCSPELL_BUILTIN_DICT from scspell import spell_check spell_check_words_path = Path(__file__).parent / 'spell_check.words' @pytest.fixture(scope='module') def known_words(): global spell_check_words_path return spell_check_words_path.read_text().splitlines() def test_spell_check(known_words): source_filenames = [Path(__file__).parents[1] / 'setup.py'] + \ list( (Path(__file__).parents[1] / 'colcon_test_result') .glob('**/*.py')) + \ list((Path(__file__).parents[1] / 'test').glob('**/*.py')) for source_filename in sorted(source_filenames): print('Spell checking:', source_filename) # check all files report = Report(known_words) spell_check( [str(p) for p in source_filenames], base_dicts=[SCSPELL_BUILTIN_DICT], report_only=report, additional_extensions=[('', 'Python')]) unknown_word_count = len(report.unknown_words) assert unknown_word_count == 0, \ 'Found {unknown_word_count} unknown words: '.format_map(locals()) + \ ', '.join(sorted(report.unknown_words)) unused_known_words = set(known_words) - report.found_known_words unused_known_word_count = len(unused_known_words) assert unused_known_word_count == 0, \ '{unused_known_word_count} words in the word list are not used: ' \ .format_map(locals()) + ', '.join(sorted(unused_known_words)) def test_spell_check_word_list_order(known_words): assert known_words == sorted(known_words), \ 'The word list should be ordered alphabetically' def test_spell_check_word_list_duplicates(known_words): assert len(known_words) == len(set(known_words)), \ 'The word list should not contain duplicates'