Chromium Code Reviews| Index: visual_studio/NativeClientVSAddIn/check_test_results.py |
| diff --git a/visual_studio/NativeClientVSAddIn/check_test_results.py b/visual_studio/NativeClientVSAddIn/check_test_results.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c7b49106f1cf63f45a1231353f5cdcde9a3f80a0 |
| --- /dev/null |
| +++ b/visual_studio/NativeClientVSAddIn/check_test_results.py |
| @@ -0,0 +1,40 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +""" This script will parse the results file produced by MSTest. |
| + |
| +The script takes a single argument containing the path to the Results.trx |
| +file to parse. It will log relevant test run information, and exit with code 0 |
| +if all tests passed, or code 1 if some test failed. |
| +""" |
| + |
| +import sys |
| +import xml.etree.ElementTree |
| + |
|
binji
2012/07/17 00:05:58
Use main function here as well.
tysand
2012/07/17 01:18:18
Done.
|
| +if (len(sys.argv) < 2): |
|
binji
2012/07/17 00:05:58
remove parens around if
tysand
2012/07/17 01:18:18
Done.
|
| + 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.
|
| + exit(1) |
| + |
| +# Parse the xml results file |
| +namespace = 'http://microsoft.com/schemas/VisualStudio/TeamTest/2010' |
| +tree = xml.etree.ElementTree.parse(sys.argv[1]) |
| +root = tree.getroot() |
| +results_node = root.find('{%s}Results' % namespace) |
| +results = results_node.findall('{%s}UnitTestResult' % namespace) |
| +test_run_name = root.attrib['name'] |
| + |
| +exit_code = 0 |
| + |
| +# Print the results, note any failures by setting exit_code to 1 |
| +print test_run_name |
| +for result in results: |
| + if (result.attrib['outcome'] != 'Passed'): |
|
binji
2012/07/17 00:05:58
remove parens around if
tysand
2012/07/17 01:18:18
Done.
|
| + exit_code = 1 |
| + 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.
|
| + print result.attrib['duration'] |
| + print result.attrib['outcome'] |
| + |
| +exit(exit_code) |