Merge lp:~brian-murray/apport/package-hook-dist-upgrade into lp:~apport-hackers/apport/trunk

Proposed by Brian Murray
Status: Merged
Merged at revision: 2341
Proposed branch: lp:~brian-murray/apport/package-hook-dist-upgrade
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 52 lines (+25/-0)
2 files modified
data/package_hook (+8/-0)
test/test_hooks.py (+17/-0)
To merge this branch: bzr merge lp:~brian-murray/apport/package-hook-dist-upgrade
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+108214@code.launchpad.net

Description of the change

Not every bug that happens during a distribution upgrade are being tagged dist-upgrade. The update-manager apport package hook adds this tag and so does DistUpgradeApport.py in update-manager. However, when package_hook is called by DistUpgradeApport this tag is not added. This branch adds a -t swicht to package_hook so that one can add tags to bug reports.

To post a comment you must log in.
2341. By Brian Murray

want the tags to be space separated not comma

2342. By Brian Murray

fix test name

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks! Merged with grammar fix for the test description.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/package_hook'
2--- data/package_hook 2012-04-30 14:39:00 +0000
3+++ data/package_hook 2012-05-31 18:15:24 +0000
4@@ -36,6 +36,9 @@
5 optparser.add_option('-l', '--log',
6 help='Append given log file, or, if it is a directory, all files in it (can be specified multiple times)',
7 action='append', type='string', dest='logs')
8+optparser.add_option('-t', '--tags',
9+ help='Add the following tags to the bug report (comma separated)',
10+ type='string', dest='tags')
11 options = optparser.parse_args()[0]
12
13 if not options.package:
14@@ -47,6 +50,11 @@
15 pr['Package'] = options.package
16 pr['SourcePackage'] = apport.packaging.get_source(options.package)
17 pr['ErrorMessage'] = (sys.stdin, False)
18+
19+if options.tags:
20+ tags = options.tags.replace(',', '')
21+ pr['Tags'] = tags
22+
23 for l in (options.logs or []):
24 if os.path.isfile(l):
25 pr[mkattrname(l)] = (l,)
26
27=== modified file 'test/test_hooks.py'
28--- test/test_hooks.py 2012-05-04 07:34:16 +0000
29+++ test/test_hooks.py 2012-05-31 18:15:24 +0000
30@@ -119,6 +119,23 @@
31 self.assertEqual(r[log1key], 'Log 1\nbla')
32 self.assertEqual(r[log2key], 'Yet\nanother\nlog')
33
34+ def test_package_hook_tags(self):
35+ '''package_hook with can accept tags as an argument.'''
36+
37+ ph = subprocess.Popen(['%s/package_hook' % datadir, '-p', 'bash',
38+ '-t', 'dist-upgrade, verybad'], stdin=subprocess.PIPE)
39+ ph.communicate(b'something is wrong')
40+ self.assertEqual(ph.returncode, 0, 'package_hook finished successfully')
41+
42+ reps = apport.fileutils.get_new_reports()
43+ self.assertEqual(len(reps), 1, 'package_hook created a report')
44+
45+ r = apport.Report()
46+ with open(reps[0], 'rb') as f:
47+ r.load(f)
48+
49+ self.assertEqual(r['Tags'], 'dist-upgrade verybad')
50+
51 def test_kernel_crashdump(self):
52 '''kernel_crashdump.'''
53

Subscribers

People subscribed via source and target branches