Merge lp:~statik/tarmac/testrunner into lp:tarmac

Proposed by Elliot Murphy
Status: Merged
Approved by: Paul Hummer
Approved revision: 51
Merged at revision: not available
Proposed branch: lp:~statik/tarmac/testrunner
Merge into: lp:tarmac
Diff against target: None lines
To merge this branch: bzr merge lp:~statik/tarmac/testrunner
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Review via email: mp+4175@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Elliot Murphy (statik) wrote :

This has one proposal for how to run tests before doing a commit. I don't have a good way to test it - in particular, I haven't tested the call to working_tree.revert().

lp:~statik/tarmac/testrunner updated
50. By Elliot Murphy

Run the test command in the root of the merge branch.

51. By Elliot Murphy

Merged from trunk and resolved conflict.

Revision history for this message
Paul Hummer (rockstar) wrote :

I can't thank you enough for working on this. Thanks a lot.

 vote approve
 status approved

> === modified file 'tarmac/bin.py'
> --- tarmac/bin.py 2009-03-05 00:29:19 +0000
> +++ tarmac/bin.py 2009-03-05 01:03:23 +0000
> @@ -2,6 +2,7 @@
> '''Code used by Tarmac scripts.'''
> from optparse import OptionParser
> import os
> +import subprocess
> import sys
>
> from bzrlib import branch, bzrdir
> @@ -22,11 +23,14 @@
> def __init__(self):
>
> parser = OptionParser("%prog [options] <projectname>")
> - parser.add_option('--dry-run', action='store_true', dest='dry_run',
> + parser.add_option('--dry-run', action='store_true',
> help='Print out the branches that would be merged and their '
> 'commit messages, but don\'t actually merge the branches.')
> + parser.add_option('--test-command', type='string', default='make test',
> + help='The test command to run after merging a branch.')
> options, args = parser.parse_args()
> self.dry_run = options.dry_run
> + self.test_command = options.test_command
>
> if len(args) != 1:
> # This code is merely a placeholder until I can get proper argument
> @@ -92,7 +96,12 @@
> candidate.source_branch.bzr_identity)
>
> target_tree.merge_from_branch(source_branch)
> - # TODO: Add hook code.
> - target_tree.commit(candidate.all_comments[0].message_body)
> + retcode = subprocess.call(self.test_command, shell=True)
> + if retcode == 0:
> + # TODO: It would be very nice if the commit message included
> + # some reference to the people who voted approve.
> + target_tree.commit(candidate.all_comments[0].message_body)
> + else:
> + target_tree.revert()
>
>
>

Other than this potential conflict, this is really good work, and I'm quite
happy to get it in.

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

review: Approve
Revision history for this message
Paul Hummer (rockstar) wrote :

Commit message: It's now possible to specify a command to run as a pre-commit hook (Elliot Murphy).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tarmac/bin.py'
2--- tarmac/bin.py 2009-03-05 00:29:19 +0000
3+++ tarmac/bin.py 2009-03-05 01:03:23 +0000
4@@ -2,6 +2,7 @@
5 '''Code used by Tarmac scripts.'''
6 from optparse import OptionParser
7 import os
8+import subprocess
9 import sys
10
11 from bzrlib import branch, bzrdir
12@@ -22,11 +23,14 @@
13 def __init__(self):
14
15 parser = OptionParser("%prog [options] <projectname>")
16- parser.add_option('--dry-run', action='store_true', dest='dry_run',
17+ parser.add_option('--dry-run', action='store_true',
18 help='Print out the branches that would be merged and their '
19 'commit messages, but don\'t actually merge the branches.')
20+ parser.add_option('--test-command', type='string', default='make test',
21+ help='The test command to run after merging a branch.')
22 options, args = parser.parse_args()
23 self.dry_run = options.dry_run
24+ self.test_command = options.test_command
25
26 if len(args) != 1:
27 # This code is merely a placeholder until I can get proper argument
28@@ -92,7 +96,12 @@
29 candidate.source_branch.bzr_identity)
30
31 target_tree.merge_from_branch(source_branch)
32- # TODO: Add hook code.
33- target_tree.commit(candidate.all_comments[0].message_body)
34+ retcode = subprocess.call(self.test_command, shell=True)
35+ if retcode == 0:
36+ # TODO: It would be very nice if the commit message included
37+ # some reference to the people who voted approve.
38+ target_tree.commit(candidate.all_comments[0].message_body)
39+ else:
40+ target_tree.revert()
41
42

Subscribers

People subscribed via source and target branches