Merge lp:~jelmer/subunit/notify into lp:~subunit/subunit/trunk

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jelmer/subunit/notify
Merge into: lp:~subunit/subunit/trunk
Diff against target: 62 lines (+58/-0)
1 file modified
filters/subunit-notify (+58/-0)
To merge this branch: bzr merge lp:~jelmer/subunit/notify
Reviewer Review Type Date Requested Status
Robert Collins Approve
Review via email: mp+17365@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This adds a simple script that will show a notify window with the test results when a test run finishes. It's simple but I've found it really useful when I was running a test in the background.

Revision history for this message
Robert Collins (lifeless) wrote :

On Thu, 2010-01-14 at 11:12 +0000, Jelmer Vernooij wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/subunit/notify into lp:subunit.
>
> Requested reviews:
> Subunit Developers (subunit)
>
>
> This adds a simple script that will show a notify window with the test results when a test run finishes. It's simple but I've found it really useful when I was running a test in the background.

This looks nice. Can I suggest that it probably wants the --forward
option so that it can be used in a chain?

Please add a news entry for this too.

 review: +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'filters/subunit-notify'
2--- filters/subunit-notify 1970-01-01 00:00:00 +0000
3+++ filters/subunit-notify 2010-01-14 11:12:15 +0000
4@@ -0,0 +1,58 @@
5+#!/usr/bin/env python
6+# subunit: extensions to python unittest to get test results from subprocesses.
7+# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
8+#
9+# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
10+# license at the users choice. A copy of both licenses are available in the
11+# project source as Apache-2.0 and BSD. You may not use this file except in
12+# compliance with one of these two licences.
13+#
14+# Unless required by applicable law or agreed to in writing, software
15+# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
16+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17+# license you chose for the specific language governing permissions and
18+# limitations under that license.
19+#
20+
21+"""Notify the user of a finished test run."""
22+
23+from optparse import OptionParser
24+import sys
25+
26+import pygtk
27+pygtk.require('2.0')
28+import pynotify
29+
30+from subunit import DiscardStream, ProtocolTestCase, TestResultStats
31+
32+if not pynotify.init("Subunit-notify"):
33+ sys.exit(1)
34+
35+parser = OptionParser(description=__doc__)
36+parser.add_option("--no-passthrough", action="store_true",
37+ help="Hide all non subunit input.", default=False, dest="no_passthrough")
38+(options, args) = parser.parse_args()
39+result = TestResultStats(sys.stdout)
40+if options.no_passthrough:
41+ passthrough_stream = DiscardStream()
42+else:
43+ passthrough_stream = None
44+test = ProtocolTestCase(sys.stdin, passthrough=passthrough_stream)
45+test.run(result)
46+if result.failed_tests > 0:
47+ summary = "Test run failed"
48+else:
49+ summary = "Test run successful"
50+body = "Total tests: %d; Passed: %d; Failed: %d" % (
51+ result.total_tests,
52+ result.passed_tests,
53+ result.failed_tests,
54+ )
55+nw = pynotify.Notification(summary, body)
56+nw.show()
57+
58+if result.wasSuccessful():
59+ exit_code = 0
60+else:
61+ exit_code = 1
62+sys.exit(exit_code)

Subscribers

People subscribed via source and target branches