OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """ This script will parse the results file produced by MSTest. | |
7 | |
8 The script takes a single argument containing the path to the Results.trx | |
9 file to parse. It will log relevant test run information, and exit with code 0 | |
10 if all tests passed, or code 1 if some test failed. | |
11 """ | |
12 | |
13 import sys | |
14 import xml.etree.ElementTree | |
15 | |
binji
2012/07/17 00:05:58
Use main function here as well.
tysand
2012/07/17 01:18:18
Done.
| |
16 if (len(sys.argv) < 2): | |
binji
2012/07/17 00:05:58
remove parens around if
tysand
2012/07/17 01:18:18
Done.
| |
17 print 'Must provide path to the Results.trx file' | |
binji
2012/07/17 00:05:58
indent 2 spaces, here and elsewhere
tysand
2012/07/17 01:18:18
Done.
| |
18 exit(1) | |
19 | |
20 # Parse the xml results file | |
21 namespace = 'http://microsoft.com/schemas/VisualStudio/TeamTest/2010' | |
22 tree = xml.etree.ElementTree.parse(sys.argv[1]) | |
23 root = tree.getroot() | |
24 results_node = root.find('{%s}Results' % namespace) | |
25 results = results_node.findall('{%s}UnitTestResult' % namespace) | |
26 test_run_name = root.attrib['name'] | |
27 | |
28 exit_code = 0 | |
29 | |
30 # Print the results, note any failures by setting exit_code to 1 | |
31 print test_run_name | |
32 for result in results: | |
33 if (result.attrib['outcome'] != 'Passed'): | |
binji
2012/07/17 00:05:58
remove parens around if
tysand
2012/07/17 01:18:18
Done.
| |
34 exit_code = 1 | |
35 print result.attrib['testName'] | |
binji
2012/07/17 00:05:58
What does this output look like? It seems like it
tysand
2012/07/17 01:18:18
Done.
| |
36 print result.attrib['duration'] | |
37 print result.attrib['outcome'] | |
38 print | |
39 | |
40 exit(exit_code) | |
OLD | NEW |