Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tap13 from upstream, reapply py3 compat again #19

Merged
merged 4 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python
python:
- 2.7
- 3.7
- 3.8
env:
- FILENAME=test-eslint1
- FILENAME=test-eslint2
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
43 changes: 20 additions & 23 deletions tap2junit/tap13.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Copyright 2013, Red Hat, Inc.
# 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 <jskladan@redhat.com>

Expand Down Expand Up @@ -60,8 +58,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 = []


Expand All @@ -79,7 +77,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
Expand All @@ -92,11 +89,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()
Expand All @@ -106,7 +103,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

Expand Down Expand Up @@ -143,7 +140,7 @@ def _parse(self, source):
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
# 'not ok' so here we add the missing tests in sequence
while t_attrs["id"] > self.__tests_counter:
self.tests.append(
Test(
Expand Down Expand Up @@ -177,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
Expand Down Expand Up @@ -212,11 +209,11 @@ def parse(self, source):
1..6
"""
t = TAP13()
t.parse(input)
t.parse(text)

import pprint

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)