Review feedback.
[third_party/subunit] / filters / subunit-stats
1 #!/usr/bin/env python
2 #  subunit: extensions to python unittest to get test results from subprocesses.
3 #  Copyright (C) 2009  Robert Collins <robertc@robertcollins.net>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
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.
14 #
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 #
19
20 """Filter a subunit stream to get aggregate statistics."""
21
22 import sys
23 import unittest
24
25 from subunit import ProtocolTestCase, TestResultStats
26
27 result = TestResultStats(sys.stdout)
28 test = ProtocolTestCase(sys.stdin)
29 test.run(result)
30 result.formatStats()
31 if result.wasSuccessful():
32     exit_code = 0
33 else:
34     exit_code = 1
35 sys.exit(exit_code)