summaryrefslogtreecommitdiff
path: root/tests.branching
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-13 13:57:45 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-17 13:50:20 +0100
commit3319a8469eafa15eda5e16bea71c0fcdff23a92c (patch)
tree06c7d0857922fd72d310d15c642a6d884a7dff3e /tests.branching
parentf7e02d76ec22bda2a0dfcd24f44a4df8544fae02 (diff)
downloadmorph-3319a8469eafa15eda5e16bea71c0fcdff23a92c.tar.gz
tests.branching: Add complex merge tests
* Spot completely unmergable cases * Make sure that changes in a chunk repo are merged to the back to that chunk's original ref, which is not necessarily the same as the TO system branch. * Test renaming a chunk (works fine if repo is the same) * Try adding a new chunk or stratum and editing it too.
Diffstat (limited to 'tests.branching')
-rw-r--r--tests.branching/merge-handles-unmergable-cases.exit1
-rwxr-xr-xtests.branching/merge-handles-unmergable-cases.script30
-rw-r--r--tests.branching/merge-handles-unmergable-cases.stderr1
-rwxr-xr-xtests.branching/merge-not-to-master.script69
-rwxr-xr-xtests.branching/merge-with-chunk-renamed.script56
-rw-r--r--tests.branching/merge-with-chunk-repo-moved.exit1
-rwxr-xr-xtests.branching/merge-with-chunk-repo-moved.script53
-rw-r--r--tests.branching/merge-with-chunk-repo-moved.stderr1
-rw-r--r--tests.branching/merge-with-stratum-renamed.exit1
-rwxr-xr-xtests.branching/merge-with-stratum-renamed.script51
-rw-r--r--tests.branching/merge-with-stratum-renamed.stderr1
11 files changed, 265 insertions, 0 deletions
diff --git a/tests.branching/merge-handles-unmergable-cases.exit b/tests.branching/merge-handles-unmergable-cases.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.branching/merge-handles-unmergable-cases.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.branching/merge-handles-unmergable-cases.script b/tests.branching/merge-handles-unmergable-cases.script
new file mode 100755
index 00000000..fd7f1478
--- /dev/null
+++ b/tests.branching/merge-handles-unmergable-cases.script
@@ -0,0 +1,30 @@
+#!/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.
+
+# Things that "morph merge" isn't expected to handle (but shouldn't crash)
+
+set -eu
+
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
+"$SRCDIR/scripts/test-morph" branch baserock:morphs test/unmergable
+
+cd "$DATADIR/workspace/test/unmergable/baserock:morphs"
+sed -ie 's/"kind": "stratum"/"kind": "chunk"/' hello-stratum.morph
+git commit --quiet --all -m "Unmergeable because kind has changed"
+cd "$DATADIR/workspace/master/baserock:morphs"
+"$SRCDIR/scripts/test-morph" merge test/unmergable
diff --git a/tests.branching/merge-handles-unmergable-cases.stderr b/tests.branching/merge-handles-unmergable-cases.stderr
new file mode 100644
index 00000000..513db2b8
--- /dev/null
+++ b/tests.branching/merge-handles-unmergable-cases.stderr
@@ -0,0 +1 @@
+ERROR: merge conflict: "kind" of morphology hello-stratum
diff --git a/tests.branching/merge-not-to-master.script b/tests.branching/merge-not-to-master.script
new file mode 100755
index 00000000..3758ce3e
--- /dev/null
+++ b/tests.branching/merge-not-to-master.script
@@ -0,0 +1,69 @@
+#!/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.
+
+# Check that "morph merge" merges a system branch into a newly created
+# system branch
+
+set -eu
+
+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
+cd "$DATADIR/workspace/test/feature"
+
+# Edit hello in FROM
+"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum hello
+cd baserock:hello
+touch newfile.txt
+git add newfile.txt
+git commit -m foo --quiet
+
+# Commit in morphs repo
+# FIXME: this should become unnecessary since only the refs have
+# changed.
+cd ../baserock:morphs
+git commit --all --quiet -m "Update morph refs for test/feature"
+
+# Merge changes back to test/stable
+cd "$DATADIR/workspace"
+cd 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-with-chunk-renamed.script b/tests.branching/merge-with-chunk-renamed.script
new file mode 100755
index 00000000..1ca2ee48
--- /dev/null
+++ b/tests.branching/merge-with-chunk-renamed.script
@@ -0,0 +1,56 @@
+#!/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.
+
+# "morph merge" should pull changes from a chunk even if its name was changed
+# in the branch
+
+set -eu
+
+# Create system branch.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" branch baserock:morphs baserock/newbranch
+
+# Rename the chunk, and then commit a seperate change
+"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum hello
+cd baserock/newbranch/baserock:hello
+
+cat hello.morph | sed -e 's/"name": "hello"/"name": "goodbye"/' > goodbye.morph
+git rm -q hello.morph
+git add goodbye.morph
+git commit -m "Rename chunk" --quiet
+
+touch newfile.txt
+git add newfile.txt
+git commit -m "Add new file" --quiet
+
+# Update stratum to point at the renamed chunk
+cd ../baserock:morphs
+sed -ie 's/"name": "hello"/"name": "goodbye"/' hello-stratum.morph
+git commit --all --quiet -m "Update morph refs for baserock/newbranch"
+
+# Merge changes back to master
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
+cd master
+"$SRCDIR/scripts/test-morph" merge baserock/newbranch
+
+# Morph should have realised that 'goodbye' is not a new chunk,
+# and pulled in the changes from 'hello' in the old branch
+cd baserock:hello
+[ ! -e hello.morph ]
+[ -e goodbye.morph ]
+[ -e newfile.txt ]
diff --git a/tests.branching/merge-with-chunk-repo-moved.exit b/tests.branching/merge-with-chunk-repo-moved.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.branching/merge-with-chunk-repo-moved.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.branching/merge-with-chunk-repo-moved.script b/tests.branching/merge-with-chunk-repo-moved.script
new file mode 100755
index 00000000..c67ccc6d
--- /dev/null
+++ b/tests.branching/merge-with-chunk-repo-moved.script
@@ -0,0 +1,53 @@
+#!/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.
+
+# "morph merge" should detect changes in a repo that was added as part of the
+# branch and warn the user that the changes will not be merged automatically
+
+set -eu
+
+# Create system branch.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" branch baserock:morphs baserock/newbranch
+
+"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum hello
+
+# Chunk moves to a new location (we manually update the ref back to master
+# here, so 'morph edit' can create a system branch in the new repo from it).
+git clone -q "$DATADIR/hello" "$DATADIR/hello-lorried"
+cd "$DATADIR/workspace/baserock/newbranch/baserock:morphs"
+sed -e 's/"repo": "baserock:hello"/"repo": "baserock:hello-lorried"/' \
+ -e 's/"ref": "baserock\/newbranch"/"ref": "master"/' \
+ -i hello-stratum.morph
+git commit -q --all -m "'hello' repository has moved"
+
+# Now we further edit the chunk, just for fun.
+"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum hello
+cd "$DATADIR/workspace/baserock/newbranch/baserock:hello-lorried"
+touch newfile.txt
+git add newfile.txt
+git commit -m "Add new file" --quiet
+
+cd "$DATADIR/workspace/baserock/newbranch/baserock:morphs"
+git commit -q --all -m "Update system branch refs"
+
+# Try to merge changes back to master (should fail, because we don't support
+# adding chunks inside branches yet).
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
+cd master
+"$SRCDIR/scripts/test-morph" merge baserock/newbranch
diff --git a/tests.branching/merge-with-chunk-repo-moved.stderr b/tests.branching/merge-with-chunk-repo-moved.stderr
new file mode 100644
index 00000000..95fe61e6
--- /dev/null
+++ b/tests.branching/merge-with-chunk-repo-moved.stderr
@@ -0,0 +1 @@
+ERROR: chunk hello was added within this branch and subsequently edited. This is not yet supported: refusing to merge.
diff --git a/tests.branching/merge-with-stratum-renamed.exit b/tests.branching/merge-with-stratum-renamed.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/tests.branching/merge-with-stratum-renamed.exit
@@ -0,0 +1 @@
+1
diff --git a/tests.branching/merge-with-stratum-renamed.script b/tests.branching/merge-with-stratum-renamed.script
new file mode 100755
index 00000000..8df2cd18
--- /dev/null
+++ b/tests.branching/merge-with-stratum-renamed.script
@@ -0,0 +1,51 @@
+#!/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.
+
+# "morph merge" should deal with stratum renames; currently it doesn't deal
+# very well, but at least we don't crash.
+
+set -eu
+
+# Create system branch.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" branch baserock:morphs baserock/newbranch
+
+# The user may 'morph edit hello-system hello-stratum hello' and commit here:
+# we currently silently ignore her changes on merge, because we don't
+# associate hello-stratum and goodbye-stratum at all.
+
+# Rename the stratum
+"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum
+cd baserock/newbranch/baserock:morphs
+
+sed -e 's/"morph": "hello-stratum"/"morph": "goodbye-stratum"/'\
+ -i hello-system.morph
+sed -e 's/"name": "hello-stratum"/"name": "goodbye-stratum"/' \
+ hello-stratum.morph > goodbye-stratum.morph
+git rm -q hello-stratum.morph
+git add goodbye-stratum.morph
+git commit -q --all -m "Rename hello-stratum to goodbye-stratum"
+
+# The user may 'morph edit hello-system goodbye-stratum hello' and commit
+# here, too: same problem.
+
+# Merge changes back to master (this should fail, because we don't support
+# adding strata inside branches yet).
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
+cd master
+"$SRCDIR/scripts/test-morph" merge baserock/newbranch
diff --git a/tests.branching/merge-with-stratum-renamed.stderr b/tests.branching/merge-with-stratum-renamed.stderr
new file mode 100644
index 00000000..ad144f93
--- /dev/null
+++ b/tests.branching/merge-with-stratum-renamed.stderr
@@ -0,0 +1 @@
+ERROR: stratum goodbye-stratum was added within this branch and subsequently edited. This is not yet supported: refusing to merge.