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 |
| 16 MSTEST_NAMESPACE = 'http://microsoft.com/schemas/VisualStudio/TeamTest/2010' |
| 17 |
| 18 def main(): |
| 19 if len(sys.argv) < 2: |
| 20 print 'Must provide path to the Results.trx file' |
| 21 return 1 |
| 22 |
| 23 # Parse the xml results file |
| 24 tree = xml.etree.ElementTree.parse(sys.argv[1]) |
| 25 root = tree.getroot() |
| 26 results_node = root.find('{%s}Results' % MSTEST_NAMESPACE) |
| 27 results = results_node.findall('{%s}UnitTestResult' % MSTEST_NAMESPACE) |
| 28 test_run_name = root.attrib['name'] |
| 29 |
| 30 exit_code = 0 |
| 31 |
| 32 # Print the results, note any failures by setting exit_code to 1 |
| 33 print test_run_name |
| 34 for result in results: |
| 35 if result.attrib['outcome'] != 'Passed': |
| 36 exit_code = 1 |
| 37 print 'Test: %s, Duration: %s, Outcome: %s\n' % ( |
| 38 result.attrib['testName'], result.attrib['duration'], |
| 39 result.attrib['outcome']) |
| 40 |
| 41 return exit_code |
| 42 |
| 43 if __name__ == '__main__': |
| 44 sys.exit(main()) |
OLD | NEW |