How do I automatically svn merge when automated tests pass?
After each commit into 'trunk', we automatically run a bunch of tests against trunk. When those tests pass, I'd like an automated merge into a branch called 'tests-passed'. When the tests fail, no merge should happen, but once the problem is fixed on 'trunk' at the next or a later commit, all the changes should be merged.
The point is to have a branch that has the same content as trunk, but that is just a tad more sane than 'trunk' because at least the automated tests have passed.
I have a script that tries to do that manually but it's a hack using custom properties开发者_开发知识库 that doesn't always work correctly -- as I just found out. How do I best make Subversion do this?
Run these commands at the root of a working copy of tests-passed whenever you have determined that a new trunk revision <somerev>
has passed the tests:
svn update
svn merge http://example.com/svn/myproject/trunk -r 0:<somerev>
svn commit -m "merged trunk revisions up to <somerev> into tests-passed"
Whenever you use the merge command, SVN will record the merges in the svn:mergeinfo
property. So the above command should automatically determine which revisions in the range 0:<somerev>
are eligible for merging, excluding any merges that have already been done.
Like you said in a comment, conflicts are not expected. But sometimes I've seen unexpected conflicts occur anyway when merging a range of SVN revisions containing renames. To get rid of these conflicts, you can use the --accept theirs-full
option with the merge command to always accept the trunk state.
You can use a Continuous Integration Tool for that. One pretty popular: Hudson
http://hudson-ci.org/
You can script that kind of behaviour there.
I would imagine using the test suite to do it.
In my experience I would run an ANT script to test my code, and have a final conditional to execute the branch if the tests were successful.
精彩评论