Make subunit2html compatible with subunit>=0.0.11.
* modules/jenkins/files/slave_scripts/subunit2html.py: Python subunit ByteStreamToStreamResult takes an argument of non_subunit_name and not non_subunit_input. Correct the argument name. Use argparse to parse the command line arguments and add a new -2 options that specifies subunit version 2 format logs should be read in. Otherwise read in version 1 subunit format. This commit makes the second file name arg to subunit2html a required argument and it is no longer optional. run-tox.sh already supplies both file name arguments so this shouldn't break Jenkins. Change-Id: I90804d4d12d77a544451c1647a137dc4b3b38f17 Reviewed-on: https://review.openstack.org/26430 Reviewed-by: Jeremy Stanley <fungi@yuggoth.org> Reviewed-by: Monty Taylor <mordred@inaugust.com> Approved: James E. Blair <corvus@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
5149ffceec
commit
a0792fddc0
@ -39,8 +39,8 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import sys
|
||||
import traceback
|
||||
import unittest
|
||||
from xml.sax import saxutils
|
||||
@ -690,25 +690,28 @@ class HtmlOutput(unittest.TestResult):
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print "Need at least one argument: path to subunit log."
|
||||
exit(1)
|
||||
subunit_file = sys.argv[1]
|
||||
if len(sys.argv) > 2:
|
||||
html_file = sys.argv[2]
|
||||
else:
|
||||
html_file = 'results.html'
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("subunit_file",
|
||||
help="Path to input subunit file.")
|
||||
parser.add_argument("html_file",
|
||||
help="Path to output html file.")
|
||||
parser.add_argument("-2", "--subunitv2", action="store_true",
|
||||
help="Input log file is in subunit version 2 format.")
|
||||
args = parser.parse_args()
|
||||
|
||||
result = HtmlOutput(html_file)
|
||||
stream = open(subunit_file, 'rb')
|
||||
try:
|
||||
# Use subunit v2 if the library supports it.
|
||||
# NB: This trivial config will not passthrough non-test output
|
||||
# - a difference to subunit v1's default.
|
||||
suite = subunit.ByteStreamToStreamResult(
|
||||
stream, non_subunit_input='stdout')
|
||||
result = testtools.StreamToExtendedDecorator(result)
|
||||
except AttributeError:
|
||||
result = HtmlOutput(args.html_file)
|
||||
stream = open(args.subunit_file, 'rb')
|
||||
if args.subunitv2:
|
||||
try:
|
||||
# Use subunit v2 if the library supports it.
|
||||
# NB: This trivial config will not passthrough non-test output
|
||||
# - a difference to subunit v1's default.
|
||||
suite = subunit.ByteStreamToStreamResult(
|
||||
stream, non_subunit_name='stdout')
|
||||
result = testtools.StreamToExtendedDecorator(result)
|
||||
except AttributeError:
|
||||
suite = subunit.ProtocolTestCase(stream)
|
||||
else:
|
||||
suite = subunit.ProtocolTestCase(stream)
|
||||
result.startTestRun()
|
||||
suite.run(result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user