From 040a7774c615fbfe1c39be0e72083c5c046ce46b Mon Sep 17 00:00:00 2001 From: cclauss Date: Sun, 27 Oct 2019 17:12:09 +0100 Subject: [PATCH 1/4] Update tap13 from upstream, reapply py3 compat again --- .travis.yml | 2 +- setup.py | 3 ++- tap2junit/tap13.py | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2551482..10a6be6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: python python: - 2.7 - - 3.7 + - 3.8 env: - FILENAME=test-eslint1 - FILENAME=test-eslint2 diff --git a/setup.py b/setup.py index 30ad1c4..b9953c1 100644 --- a/setup.py +++ b/setup.py @@ -20,13 +20,14 @@ classifiers=[ "Development Status :: 4 - Beta", "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "License :: OSI Approved :: Apache License, Version 2.0", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Build Tools", ], keywords="tap13 junit", diff --git a/tap2junit/tap13.py b/tap2junit/tap13.py index b1a08e2..47395f7 100644 --- a/tap2junit/tap13.py +++ b/tap2junit/tap13.py @@ -61,7 +61,7 @@ def __init__(self, result, id, description=None, directive=None, comment=None): self.directive = directive self.comment = comment self.yaml = {} - self.yaml_buffer = [] + self._yaml_buffer = [] self.diagnostics = [] @@ -92,11 +92,11 @@ def _parse(self, source): if in_yaml: if RE_YAMLISH_END.match(line): - self.tests[-1].yaml_buffer.append(line.strip()) + self.tests[-1]._yaml_buffer.append(line.strip()) in_yaml = False - self.tests[-1].yaml = yamlish.load(self.tests[-1].yaml_buffer) + self.tests[-1].yaml = yamlish.load(self.tests[-1]._yaml_buffer) else: - self.tests[-1].yaml_buffer.append(line.rstrip()) + self.tests[-1]._yaml_buffer.append(line.rstrip()) continue line = line.strip() @@ -106,7 +106,7 @@ def _parse(self, source): self.tests[-1].diagnostics.append(line) continue if RE_YAMLISH_START.match(line): - self.tests[-1].yaml_buffer = [line.strip()] + self.tests[-1]._yaml_buffer = [line.strip()] in_yaml = True continue @@ -218,5 +218,5 @@ def parse(self, source): for test in t.tests: print(test.result, test.id, test.description, "#", test.directive, test.comment) - pprint.pprint(test.yaml_buffer) + pprint.pprint(test._yaml_buffer) pprint.pprint(test.yaml) From a947a8e909eb00a5b50b6519c640342d111eec60 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sun, 27 Oct 2019 18:32:54 +0100 Subject: [PATCH 2/4] fixup: Resync --- tap2junit/tap13.py | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/tap2junit/tap13.py b/tap2junit/tap13.py index 47395f7..1a8f3ac 100644 --- a/tap2junit/tap13.py +++ b/tap2junit/tap13.py @@ -1,18 +1,18 @@ -# Copyright 2013, Red Hat, Inc. +from __future__ import print_function + +# Copyright 2019, Red Hat, Inc. # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# 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 # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# http://www.apache.org/licenses/LICENSE-2.0 # -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# 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. # # Author: Josef Skladanka @@ -39,10 +39,7 @@ r"^\s*(?P\d+)\.\.(?P\d+)\s*(#\s*(?P.*))?\s*$" ) RE_TEST_LINE = re.compile( - ( - r"^\s*(?P(not\s+)?ok)\s*(?P\d+)?\s*(?P[^#]+)" - r"?\s*(#\s*(?PTODO|SKIP)?\s*(?P.+)?)?\s*$" - ), + r"^\s*(?P(not\s+)?ok)\s*(?P\d+)?\s*(?P[^#]+)?\s*(#\s*(?PTODO|SKIP)?\s*(?P.+)?)?\s*$", re.IGNORECASE, ) RE_EXPLANATION = re.compile(r"^\s*#\s*(?P.+)?\s*$") @@ -60,8 +57,8 @@ def __init__(self, result, id, description=None, directive=None, comment=None): except AttributeError: self.directive = directive self.comment = comment - self.yaml = {} - self._yaml_buffer = [] + self.yaml = None + self._yaml_buffer = None self.diagnostics = [] @@ -79,7 +76,6 @@ def _parse(self, source): in_test = False in_yaml = False for line in source: - if not seek_version and RE_VERSION.match(line): # refack: breaking TAP13 spec, to allow multiple TAP headers seek_version = True @@ -128,7 +124,7 @@ def _parse(self, source): seek_plan = False # Stop processing if tests were found before the plan - # if plan is at the end, it must be last line -> stop processing + # if plan is at the end, it must be the last line -> stop processing if self.__tests_counter > 0: break @@ -142,8 +138,8 @@ def _parse(self, source): t_attrs["id"] = int(t_attrs["id"]) if t_attrs["id"] < self.__tests_counter: raise ValueError("Descending test id on line: %r" % line) - # according to TAP13 specs, missing tests must be handled as - # 'not ok'. Here we add the missing tests in sequence + # according to TAP13 specs, missing tests must be handled as 'not ok' + # here we add the missing tests in sequence while t_attrs["id"] > self.__tests_counter: self.tests.append( Test( From 8fdee1f93746aea5fb7d80884e0393d56ab2c29a Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 28 Oct 2019 18:15:49 +0100 Subject: [PATCH 3/4] README.md: Add URL of upstream --- .travis.yml | 2 +- tap2junit/tap13.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10a6be6..e6c1210 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - FILENAME=test2 - FILENAME=test3 install: pip install flake8 junit-xml yamlish -before_script: flake8 . --count --select=E9,F --show-source --statistics +before_script: flake8 . --max-line-length=88 script: - python tap2junit/tap13.py - python -m tap2junit -i test/fixtures/${FILENAME}.tap -o test/output/${FILENAME}.xml diff --git a/tap2junit/tap13.py b/tap2junit/tap13.py index 1a8f3ac..e05b710 100644 --- a/tap2junit/tap13.py +++ b/tap2junit/tap13.py @@ -1,5 +1,3 @@ -from __future__ import print_function - # Copyright 2019, Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +37,10 @@ r"^\s*(?P\d+)\.\.(?P\d+)\s*(#\s*(?P.*))?\s*$" ) RE_TEST_LINE = re.compile( - r"^\s*(?P(not\s+)?ok)\s*(?P\d+)?\s*(?P[^#]+)?\s*(#\s*(?PTODO|SKIP)?\s*(?P.+)?)?\s*$", + ( + r"^\s*(?P(not\s+)?ok)\s*(?P\d+)?\s*(?P[^#]+)" + r"?\s*(#\s*(?PTODO|SKIP)?\s*(?P.+)?)?\s*$" + ), re.IGNORECASE, ) RE_EXPLANATION = re.compile(r"^\s*#\s*(?P.+)?\s*$") @@ -124,7 +125,7 @@ def _parse(self, source): seek_plan = False # Stop processing if tests were found before the plan - # if plan is at the end, it must be the last line -> stop processing + # if plan is at the end, it must be last line -> stop processing if self.__tests_counter > 0: break @@ -138,8 +139,8 @@ def _parse(self, source): t_attrs["id"] = int(t_attrs["id"]) if t_attrs["id"] < self.__tests_counter: raise ValueError("Descending test id on line: %r" % line) - # according to TAP13 specs, missing tests must be handled as 'not ok' - # here we add the missing tests in sequence + # according to TAP13 specs, missing tests must be handled as + # 'not ok' so here we add the missing tests in sequence while t_attrs["id"] > self.__tests_counter: self.tests.append( Test( @@ -173,7 +174,7 @@ def parse(self, source): if __name__ == "__main__": - input = """ + text = """ TAP version 13 ok 1 - Input file opened not ok 2 - First line of the input valid @@ -208,7 +209,7 @@ def parse(self, source): 1..6 """ t = TAP13() - t.parse(input) + t.parse(text) import pprint From 51b2db81f5100c1cbcb9b303452650ced5991216 Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 28 Oct 2019 19:16:02 +0100 Subject: [PATCH 4/4] README.md: Add URL of upstream --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 387b83d..3f45273 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ A utility that converts [TAP version 13](https://testanything.org/) to [JUnit](https://junit.org/junit5/). That's it. -The syntax expected is currently pretty custom-tailored for use at https://ci.nodejs.org. +Upstream is currently unmaintained at https://bitbucket.org/fedoraqa/pytap13/src/develop/ + +The syntax expected is currently pretty custom-tailored for use at https://ci.nodejs.org Improvements welcome.