OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [scripts/] [prefix-junit] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
#!/usr/bin/env python
2
 
3
# Copyright Jamie Iles, 2017
4
#
5
# This file is part of s80x86.
6
#
7
# s80x86 is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# s80x86 is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with s80x86.  If not, see .
19
 
20
"""
21
Add a prefix to all test/class names in a junit xml file.
22
 
23
Used when the test program is run multiple times with the same test names but
24
different global environments and all of the xml files will be reported
25
together.  For example, with s8086, the instruction unit tests are run once
26
with the software simulator and once with the RTL simulation.  Because google
27
test isn't great at type *and* value parameterized tests, the tests are run
28
twice with a different EmulateFixture.
29
"""
30
import argparse
31
import lxml.etree as ET
32
 
33
PREFIX = "Simulation."
34
 
35
TRANSFORM_TEMPLATE = """\
36
37
38
 
39
40
41
42
43
44
 
45
46
47
48
49
50
 
51
52
53
54
55
56
 
57
58
"""
59
 
60
if __name__ == '__main__':
61
    parser = argparse.ArgumentParser()
62
    parser.add_argument('prefix')
63
    parser.add_argument('input')
64
    parser.add_argument('output')
65
    args = parser.parse_args()
66
 
67
    with open(args.input) as infile:
68
        xml = ET.parse(infile)
69
        xslt = ET.fromstring(TRANSFORM_TEMPLATE.format(PREFIX=args.prefix))
70
        transform = ET.XSLT(xslt)
71
 
72
    newdom = transform(xml)
73
 
74
    with open(args.output, 'w') as outfile:
75
        outfile.write(ET.tostring(newdom, pretty_print=True))

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.