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.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
|
||||||
import traceback
|
import traceback
|
||||||
import unittest
|
import unittest
|
||||||
from xml.sax import saxutils
|
from xml.sax import saxutils
|
||||||
@ -690,25 +690,28 @@ class HtmlOutput(unittest.TestResult):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 2:
|
parser = argparse.ArgumentParser()
|
||||||
print "Need at least one argument: path to subunit log."
|
parser.add_argument("subunit_file",
|
||||||
exit(1)
|
help="Path to input subunit file.")
|
||||||
subunit_file = sys.argv[1]
|
parser.add_argument("html_file",
|
||||||
if len(sys.argv) > 2:
|
help="Path to output html file.")
|
||||||
html_file = sys.argv[2]
|
parser.add_argument("-2", "--subunitv2", action="store_true",
|
||||||
else:
|
help="Input log file is in subunit version 2 format.")
|
||||||
html_file = 'results.html'
|
args = parser.parse_args()
|
||||||
|
|
||||||
result = HtmlOutput(html_file)
|
result = HtmlOutput(args.html_file)
|
||||||
stream = open(subunit_file, 'rb')
|
stream = open(args.subunit_file, 'rb')
|
||||||
try:
|
if args.subunitv2:
|
||||||
# Use subunit v2 if the library supports it.
|
try:
|
||||||
# NB: This trivial config will not passthrough non-test output
|
# Use subunit v2 if the library supports it.
|
||||||
# - a difference to subunit v1's default.
|
# NB: This trivial config will not passthrough non-test output
|
||||||
suite = subunit.ByteStreamToStreamResult(
|
# - a difference to subunit v1's default.
|
||||||
stream, non_subunit_input='stdout')
|
suite = subunit.ByteStreamToStreamResult(
|
||||||
result = testtools.StreamToExtendedDecorator(result)
|
stream, non_subunit_name='stdout')
|
||||||
except AttributeError:
|
result = testtools.StreamToExtendedDecorator(result)
|
||||||
|
except AttributeError:
|
||||||
|
suite = subunit.ProtocolTestCase(stream)
|
||||||
|
else:
|
||||||
suite = subunit.ProtocolTestCase(stream)
|
suite = subunit.ProtocolTestCase(stream)
|
||||||
result.startTestRun()
|
result.startTestRun()
|
||||||
suite.run(result)
|
suite.run(result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user