3 # Copyright (C) 2014 Intel Corporation
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # Nicolas Zingile <n.zingile@gmail.com>
23 from testkitmerge.merger import *
26 argparser = argparse.ArgumentParser(description='Tool to merge testkit result xml files')
27 argparser.add_argument('-f', '--files', help='list of testkit xml result files', nargs='+')
28 argparser.add_argument('-o', '--outdir', help='output directory of final result file', required=True)
29 argparser.add_argument('-n', '--name', help ='name of the final result file', default='result.xml')
30 args = argparser.parse_args()
33 parser = etree.XMLParser(strip_cdata=False)
37 for resultxml in args.files:
38 if not os.path.isfile(resultxml):
39 print "Error: the file '" + resultxml + "'doesn't exist !"
41 if not resultxml.endswith('.xml'):
42 print "Error: '" + resultxml + "' is not an xml file !"
44 for index in range(len(args.files)):
45 sourcexmltree = etree.parse(args.files[index], parser)
46 resultxmltree = merge_testkitxml(sourcexmltree, resultxmltree)
48 resultxmltree.write(os.path.join(args.outdir, args.name), pretty_print=True, encoding='utf8', method='xml', xml_declaration=True)
50 if __name__ == "__main__":