diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-25 15:55:16 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-25 19:03:37 +0100 |
commit | 11863d70955c86664466c03c1d194e6f56645050 (patch) | |
tree | 97581ab135fc9355c7295d3d5977eb6492fe6619 /tests.branching | |
parent | 6a85de8f3b427431d76db41e4e6925467fe1d868 (diff) | |
download | morph-11863d70955c86664466c03c1d194e6f56645050.tar.gz |
Add merge conflict tests
Diffstat (limited to 'tests.branching')
-rwxr-xr-x | tests.branching/merge-conflict-chunks.script | 95 | ||||
-rw-r--r-- | tests.branching/merge-conflict-chunks.stderr | 6 | ||||
-rw-r--r-- | tests.branching/merge-conflict-chunks.stdout | 10 | ||||
-rw-r--r-- | tests.branching/merge-conflict-stratum.exit | 1 | ||||
-rwxr-xr-x | tests.branching/merge-conflict-stratum.script | 117 | ||||
-rw-r--r-- | tests.branching/merge-conflict-stratum.stderr | 1 | ||||
-rw-r--r-- | tests.branching/merge-conflict-stratum.stdout | 7 | ||||
-rw-r--r-- | tests.branching/setup-3rd-party-strata | 2 |
8 files changed, 239 insertions, 0 deletions
diff --git a/tests.branching/merge-conflict-chunks.script b/tests.branching/merge-conflict-chunks.script new file mode 100755 index 00000000..f53edd82 --- /dev/null +++ b/tests.branching/merge-conflict-chunks.script @@ -0,0 +1,95 @@ +#!/bin/sh +# Copyright (C) 2012 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# When conflicts occur outside the root morphs repository, 'morph merge' +# should keep going until the end and report the list of failed repos. + +set -eu + +# Disable test on versions of Python before 2.7. +if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null +then + exit 0 +fi + +. "$SRCDIR/tests.branching/setup-3rd-party-strata" + +# Create stable branch to merge TO +"$SRCDIR/scripts/test-morph" branch baserock:morphs test/stable +cd test/stable/baserock:morphs +git push --quiet origin test/stable + +# Create feature branch to merge FROM +"$SRCDIR/scripts/test-morph" branch baserock:morphs test/feature test/stable + +add_text_in_repo() { + REPO="$1" + TEXT="$2" + + cd "$1" + echo $TEXT > conflict.txt + git add conflict.txt + git commit --quiet --message "Add some text" + cd - > /dev/null +} + +# Sow the seeds of conflict +cd "$DATADIR/workspace/test/stable" +"$SRCDIR/scripts/test-morph" edit hello-system stratum2 hello +"$SRCDIR/scripts/test-morph" edit hello-system stratum3 hello +add_text_in_repo "baserock:stratum2-hello" "xyzzy" +add_text_in_repo "baserock:stratum3-hello" "xyzzy" + +cd "$DATADIR/workspace/test/feature" +"$SRCDIR/scripts/test-morph" edit hello-system stratum2 hello +"$SRCDIR/scripts/test-morph" edit hello-system stratum3 hello +add_text_in_repo "baserock:stratum2-hello" "plugh" +add_text_in_repo "baserock:stratum3-hello" "plover" + +# This should not be necessary, one day +cd "$DATADIR/workspace/test/stable/baserock:morphs" +git commit --quiet --all --message "Commit refs for branch" +cd "$DATADIR/workspace/test/stable/baserock:external-strata" +git commit --quiet --all --message "Commit refs for branch" + +cd "$DATADIR/workspace/test/feature/baserock:morphs" +git commit --quiet --all --message "Commit refs for branch" +cd "$DATADIR/workspace/test/feature/baserock:external-strata" +git commit --quiet --all --message "Commit refs for branch" + +# Manually merge in baserock:morphs for now so we test that errors in other +# repos are collected instead of being immediately fatal. Morph should be able +# to deal with this merge automatically in the future because it's only the +# system branch refs that are conflicting. +cd "$DATADIR/workspace/test/feature/baserock:morphs" +git pull --quiet --strategy=ours \ + "file:///$DATADIR/workspace/test/stable/baserock:morphs" test/stable +cd "$DATADIR/workspace/test/feature/baserock:external-strata" +git pull --quiet --strategy=ours \ + "file:///$DATADIR/workspace/test/stable/baserock:external-strata" \ + test/stable + +# Merge changes from test/feature to test/stable +cd "$DATADIR/workspace/test/stable" +"$SRCDIR/scripts/test-morph" merge test/feature || true + +# Check that the repos are all clean +for repo in "baserock:morphs" "baserock:external-strata" \ + "baserock:stratum2-hello" "baserock:stratum3-hello"; do + cd "$DATADIR/workspace/test/stable/$repo" + git status --porcelain + [ $(git rev-parse HEAD) = $(git rev-parse test/stable) ] +done diff --git a/tests.branching/merge-conflict-chunks.stderr b/tests.branching/merge-conflict-chunks.stderr new file mode 100644 index 00000000..0bdc9475 --- /dev/null +++ b/tests.branching/merge-conflict-chunks.stderr @@ -0,0 +1,6 @@ +ERROR: merge errors were encountered in the following repositories: + + baserock:stratum2-hello + baserock:stratum3-hello + +Please manually merge the target ref into test/feature in each case, and then merge the system branch. diff --git a/tests.branching/merge-conflict-chunks.stdout b/tests.branching/merge-conflict-chunks.stdout new file mode 100644 index 00000000..cfb9949d --- /dev/null +++ b/tests.branching/merge-conflict-chunks.stdout @@ -0,0 +1,10 @@ +Merge errors encountered merging into test/stable in repo baserock:stratum2-hello: +Auto-merging conflict.txt +CONFLICT (add/add): Merge conflict in conflict.txt +Automatic merge failed; fix conflicts and then commit the result. + +Merge errors encountered merging into test/stable in repo baserock:stratum3-hello: +Auto-merging conflict.txt +CONFLICT (add/add): Merge conflict in conflict.txt +Automatic merge failed; fix conflicts and then commit the result. + diff --git a/tests.branching/merge-conflict-stratum.exit b/tests.branching/merge-conflict-stratum.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.branching/merge-conflict-stratum.exit @@ -0,0 +1 @@ +1 diff --git a/tests.branching/merge-conflict-stratum.script b/tests.branching/merge-conflict-stratum.script new file mode 100755 index 00000000..76e3309e --- /dev/null +++ b/tests.branching/merge-conflict-stratum.script @@ -0,0 +1,117 @@ +#!/bin/sh +# Copyright (C) 2012 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Simple merge conflict handling test. + +set -eu + +# Disable test on versions of Python before 2.7. +if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null +then + exit 0 +fi + +cd "$DATADIR/workspace" +"$SRCDIR/scripts/test-morph" init + +# Create stable branch to merge TO +"$SRCDIR/scripts/test-morph" branch baserock:morphs test/stable +cd test/stable/baserock:morphs +git push --quiet origin test/stable + +# Create feature branch to merge FROM +"$SRCDIR/scripts/test-morph" branch baserock:morphs test/feature test/stable + +# Need 2 chunks! + +# Make a change in TO +cd "$DATADIR/workspace/test/stable" +"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum +cd baserock:morphs +cat <<EOF > "hello-stratum.morph" +{ + "name": "hello-stratum", + "kind": "stratum", + "chunks": [ + { + "name": "hello-runtime", + "repo": "baserock:hello", + "ref": "master", + "morph": "hello", + "build-depends": [] + }, + { + "name": "hello-devel", + "repo": "baserock:hello", + "ref": "master", + "morph": "hello", + "build-depends": [] + } + ] +} +EOF +git commit --quiet --all -m "Split up 'hello' chunk into runtime and devel" + +# Make a change in FROM that isn't very mergable +cd "$DATADIR/workspace/test/feature" +"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum +cd baserock:morphs +cat <<EOF > "hello-stratum.morph" +{ + "name": "hello-stratum", + "kind": "stratum", + "chunks": [ + { + "name": "hello-devel", + "repo": "baserock:hello", + "ref": "master", + "morph": "hello", + "build-depends": [] + }, + { + "name": "hello-runtime", + "repo": "baserock:hello", + "ref": "master", + "morph": "hello", + "build-depends": [] + } + ] +} +EOF +git commit --quiet --all -m "Split up 'hello' chunk into devel and runtime" + +# Merge changes from test/feature to test/stable +cd "$DATADIR/workspace/test/stable" +"$SRCDIR/scripts/test-morph" merge test/feature + +# Check results: changes to 'hello' should have been merged back to +# test/stable. +cd baserock:hello +[ -e newfile.txt ] + +# Make sure all changes are committed and to the correct branch ('hello' +# was built from 'master' before branching, so the changes should be +# merged back to 'master'). +git status --short +[ $(git rev-parse master) = $(git rev-parse HEAD) ] + +# Changes here should be on test/stable. +cd ../baserock:morphs +git status --short +[ $(git rev-parse test/stable) = $(git rev-parse HEAD) ] + +# Make sure all refs to the merged branch have gone. +! grep "\"ref\": \"test/feature\"" *.morph diff --git a/tests.branching/merge-conflict-stratum.stderr b/tests.branching/merge-conflict-stratum.stderr new file mode 100644 index 00000000..36781ad7 --- /dev/null +++ b/tests.branching/merge-conflict-stratum.stderr @@ -0,0 +1 @@ +ERROR: Merging failed in baserock:morphs: please manually merge test/stable into test/feature in this repo and try again. diff --git a/tests.branching/merge-conflict-stratum.stdout b/tests.branching/merge-conflict-stratum.stdout new file mode 100644 index 00000000..a3bb4cc0 --- /dev/null +++ b/tests.branching/merge-conflict-stratum.stdout @@ -0,0 +1,7 @@ +Merge errors encountered merging into test/stable in repo baserock:morphs: +Auto-merging hello-system.morph +CONFLICT (content): Merge conflict in hello-system.morph +Auto-merging hello-stratum.morph +CONFLICT (content): Merge conflict in hello-stratum.morph +Automatic merge failed; fix conflicts and then commit the result. + diff --git a/tests.branching/setup-3rd-party-strata b/tests.branching/setup-3rd-party-strata index e82d5aeb..49eca394 100644 --- a/tests.branching/setup-3rd-party-strata +++ b/tests.branching/setup-3rd-party-strata @@ -132,3 +132,5 @@ cd master/baserock:morphs cd "$DATADIR/morphs" git pull -q \ "file://$DATADIR/workspace/master/baserock:morphs" master + +cd "$DATADIR/workspace" |