diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-26 15:15:25 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-26 15:15:25 +0100 |
commit | ca7900299dc32c7b59e896f5f4b9a38978f226a0 (patch) | |
tree | d1f15db7c51c83c1eb1fa11565adc2a295c48eec /tests.branching | |
parent | 7d7d597afd0a562916f106d259f4ff78383f9631 (diff) | |
parent | 9e18d7cc163ab95524349567fc8c4205cd0f11ce (diff) | |
download | morph-ca7900299dc32c7b59e896f5f4b9a38978f226a0.tar.gz |
Add rudimentary branch+merge support
Diffstat (limited to 'tests.branching')
35 files changed, 676 insertions, 0 deletions
diff --git a/tests.branching/branch-creates-new-system-branch.script b/tests.branching/branch-creates-new-system-branch.script new file mode 100755 index 00000000..61e9daf4 --- /dev/null +++ b/tests.branching/branch-creates-new-system-branch.script @@ -0,0 +1,35 @@ +#!/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. + +# Make sure "morph branch" creates a new system branch. + +set -eu + +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init + +"$SRCDIR/scripts/test-morph" branch newbranch + +echo "File tree:" +"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' | + sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,' + +echo "Current branches:" +"$SRCDIR/scripts/run-git-in" newbranch/morphs branch + +echo "Current origin:" +"$SRCDIR/scripts/run-git-in" newbranch/morphs remote show origin | + sed 's,\(TMP/mine/\.morph/cache/gits/file_\).*_,\1,g' diff --git a/tests.branching/branch-creates-new-system-branch.stdout b/tests.branching/branch-creates-new-system-branch.stdout new file mode 100644 index 00000000..6a3a9b98 --- /dev/null +++ b/tests.branching/branch-creates-new-system-branch.stdout @@ -0,0 +1,29 @@ +File tree: +d . +d ./.morph +d ./.morph/cache +d ./.morph/cache/gits +d ./.morph/cache/gits/file_morphs +d ./.morph/cache/gits/file_morphs/.git +d ./newbranch +d ./newbranch/morphs +d ./newbranch/morphs/.git +f ./newbranch/morphs/hello-stratum.chunk +f ./newbranch/morphs/hello-system.chunk +Current branches: + master +* newbranch +Current origin: +* remote origin + Fetch URL: file://TMP/morphs + Push URL: file://TMP/morphs + HEAD branch (remote HEAD is ambiguous, may be one of the following): + alfred + master + Remote branches: + alfred tracked + master tracked + Local branch configured for 'git pull': + master merges with remote master + Local ref configured for 'git push': + master pushes to master (up to date) diff --git a/tests.branching/branch-when-branchdir-exists-locally.exit b/tests.branching/branch-when-branchdir-exists-locally.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.branching/branch-when-branchdir-exists-locally.exit @@ -0,0 +1 @@ +1 diff --git a/tests.branching/branch-when-branchdir-exists-locally.script b/tests.branching/branch-when-branchdir-exists-locally.script new file mode 100755 index 00000000..4692b5f6 --- /dev/null +++ b/tests.branching/branch-when-branchdir-exists-locally.script @@ -0,0 +1,27 @@ +#!/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. + +# Make sure "morph branch" fails when the system branch directory already +# exists. + +set -eu + +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init + +mkdir newbranch +"$SRCDIR/scripts/test-morph" branch newbranch + diff --git a/tests.branching/branch-when-branchdir-exists-locally.stderr b/tests.branching/branch-when-branchdir-exists-locally.stderr new file mode 100644 index 00000000..6c56c250 --- /dev/null +++ b/tests.branching/branch-when-branchdir-exists-locally.stderr @@ -0,0 +1 @@ +ERROR: newbranch: File exists diff --git a/tests.branching/checkout-existing-branch.script b/tests.branching/checkout-existing-branch.script new file mode 100755 index 00000000..74941e18 --- /dev/null +++ b/tests.branching/checkout-existing-branch.script @@ -0,0 +1,33 @@ +#!/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. + + +# Verify that "morph checkout master" works. + + +set -eu + + +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" checkout master + +echo "File tree:" +"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' | + sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,' + +echo "Current branches:" +"$SRCDIR/scripts/run-git-in" master/morphs branch diff --git a/tests.branching/checkout-existing-branch.stdout b/tests.branching/checkout-existing-branch.stdout new file mode 100644 index 00000000..4b29db80 --- /dev/null +++ b/tests.branching/checkout-existing-branch.stdout @@ -0,0 +1,12 @@ +File tree: +d . +d ./.morph +d ./.morph/cache +d ./.morph/cache/gits +d ./.morph/cache/gits/file_morphs +d ./.morph/cache/gits/file_morphs/.git +d ./master +d ./master/morphs +d ./master/morphs/.git +Current branches: +* master diff --git a/tests.branching/edit-checkouts-existing-chunk.script b/tests.branching/edit-checkouts-existing-chunk.script new file mode 100755 index 00000000..583f19e1 --- /dev/null +++ b/tests.branching/edit-checkouts-existing-chunk.script @@ -0,0 +1,39 @@ +#!/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. + + +# Verify that "morph edit" clones a chunk repository into a system branch. + + +set -eu + +# Checkout the master system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" checkout alfred + +# Edit the hello chunk in alfred. +cd alfred/morphs +"$SRCDIR/scripts/test-morph" edit hello alfred + +echo "Current branches, morphs:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/alfred/morphs" branch + +echo "Current branches, hello:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/alfred/hello" branch + +echo "Files in hello:" +ls "$DATADIR/mine/alfred/hello" diff --git a/tests.branching/edit-checkouts-existing-chunk.stdout b/tests.branching/edit-checkouts-existing-chunk.stdout new file mode 100644 index 00000000..a06832c2 --- /dev/null +++ b/tests.branching/edit-checkouts-existing-chunk.stdout @@ -0,0 +1,7 @@ +Current branches, morphs: +* master +Current branches, hello: +* alfred + master +Files in hello: +hello.chunk diff --git a/tests.branching/edit-clones-chunk.script b/tests.branching/edit-clones-chunk.script new file mode 100755 index 00000000..f6f4e5e8 --- /dev/null +++ b/tests.branching/edit-clones-chunk.script @@ -0,0 +1,44 @@ +#!/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. + + +# Verify that "morph edit" clones a chunk repository into a system branch. + + +set -eu + +# Create system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" branch newbranch + +# Edit chunk. +cd newbranch/morphs +"$SRCDIR/scripts/test-morph" edit hello master + +echo "Current branches, morphs:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/morphs" branch + +echo "Current origin, morphs:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/morphs" \ + remote show origin | sed 's,\(TMP/mine/\.morph/cache/gits/file_\).*_,\1,g' + +echo "Current branches, hello:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/hello" branch + +echo "Current origin, hello:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/newbranch/hello" \ + remote show origin | sed 's,\(TMP/mine/\.morph/cache/gits/file_\).*_,\1,g' diff --git a/tests.branching/edit-clones-chunk.stdout b/tests.branching/edit-clones-chunk.stdout new file mode 100644 index 00000000..4bbf909e --- /dev/null +++ b/tests.branching/edit-clones-chunk.stdout @@ -0,0 +1,34 @@ +Current branches, morphs: + master +* newbranch +Current origin, morphs: +* remote origin + Fetch URL: file://TMP/morphs + Push URL: file://TMP/morphs + HEAD branch (remote HEAD is ambiguous, may be one of the following): + alfred + master + Remote branches: + alfred tracked + master tracked + Local branch configured for 'git pull': + master merges with remote master + Local ref configured for 'git push': + master pushes to master (up to date) +Current branches, hello: + master +* newbranch +Current origin, hello: +* remote origin + Fetch URL: file://TMP/hello + Push URL: file://TMP/hello + HEAD branch (remote HEAD is ambiguous, may be one of the following): + alfred + master + Remote branches: + alfred tracked + master tracked + Local branch configured for 'git pull': + master merges with remote master + Local ref configured for 'git push': + master pushes to master (up to date) diff --git a/tests.branching/init-cwd.script b/tests.branching/init-cwd.script new file mode 100755 index 00000000..91c23506 --- /dev/null +++ b/tests.branching/init-cwd.script @@ -0,0 +1,25 @@ +#!/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. + + +set -eu + +# Test that "morph init" works for the current working directory. + +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init . +"$SRCDIR/scripts/list-tree" "$DATADIR/mine" + diff --git a/tests.branching/init-cwd.stdout b/tests.branching/init-cwd.stdout new file mode 100644 index 00000000..e7922ee1 --- /dev/null +++ b/tests.branching/init-cwd.stdout @@ -0,0 +1,2 @@ +d . +d ./.morph diff --git a/tests.branching/init-default.script b/tests.branching/init-default.script new file mode 100755 index 00000000..5ec5148d --- /dev/null +++ b/tests.branching/init-default.script @@ -0,0 +1,24 @@ +#!/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. + + +set -eu + +# Test that "morph init" works without an explicit argument. + +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/list-tree" "$DATADIR/mine" diff --git a/tests.branching/init-default.stdout b/tests.branching/init-default.stdout new file mode 100644 index 00000000..e7922ee1 --- /dev/null +++ b/tests.branching/init-default.stdout @@ -0,0 +1,2 @@ +d . +d ./.morph diff --git a/tests.branching/init-existing.script b/tests.branching/init-existing.script new file mode 100755 index 00000000..59b658aa --- /dev/null +++ b/tests.branching/init-existing.script @@ -0,0 +1,24 @@ +#!/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. + + +set -eu + +# Test that "morph init" works when given the name of an existing, +# empty directory. + +"$SRCDIR/scripts/test-morph" init "$DATADIR/mine" +"$SRCDIR/scripts/list-tree" "$DATADIR/mine" diff --git a/tests.branching/init-existing.stdout b/tests.branching/init-existing.stdout new file mode 100644 index 00000000..e7922ee1 --- /dev/null +++ b/tests.branching/init-existing.stdout @@ -0,0 +1,2 @@ +d . +d ./.morph diff --git a/tests.branching/init-newdir.exit b/tests.branching/init-newdir.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.branching/init-newdir.exit @@ -0,0 +1 @@ +1 diff --git a/tests.branching/init-newdir.script b/tests.branching/init-newdir.script new file mode 100755 index 00000000..3bb4a1ba --- /dev/null +++ b/tests.branching/init-newdir.script @@ -0,0 +1,24 @@ +#!/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. + + +set -eu + +# Test that "morph init" gives an error when given the name of a +# directory that does not exist yet. + +"$SRCDIR/scripts/test-morph" init "$DATADIR/foo" + diff --git a/tests.branching/init-newdir.stderr b/tests.branching/init-newdir.stderr new file mode 100644 index 00000000..066d69c0 --- /dev/null +++ b/tests.branching/init-newdir.stderr @@ -0,0 +1 @@ +ERROR: can only initialize an existing empty directory: TMP/foo diff --git a/tests.branching/init-nonempty.exit b/tests.branching/init-nonempty.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.branching/init-nonempty.exit @@ -0,0 +1 @@ +1 diff --git a/tests.branching/init-nonempty.script b/tests.branching/init-nonempty.script new file mode 100755 index 00000000..28762d08 --- /dev/null +++ b/tests.branching/init-nonempty.script @@ -0,0 +1,24 @@ +#!/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. + + +set -eu + +# Test that "morph init" fails when given the name of an existing, +# non-empty directory. + +touch "$DATADIR/mine/foo" +"$SRCDIR/scripts/test-morph" init "$DATADIR/mine" diff --git a/tests.branching/init-nonempty.stderr b/tests.branching/init-nonempty.stderr new file mode 100644 index 00000000..4ed4bba8 --- /dev/null +++ b/tests.branching/init-nonempty.stderr @@ -0,0 +1 @@ +ERROR: can only initialize empty directory: TMP/mine diff --git a/tests.branching/merge-explicitly-named-repos.script b/tests.branching/merge-explicitly-named-repos.script new file mode 100755 index 00000000..de6ecebc --- /dev/null +++ b/tests.branching/merge-explicitly-named-repos.script @@ -0,0 +1,48 @@ +#!/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 explicitly named repositories. + + +set -eu + + +# Create system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" branch newbranch + +# Make a change to a chunk. +cd newbranch/morphs +"$SRCDIR/scripts/test-morph" edit hello master +cd ../hello +touch newfile.txt +git add newfile.txt +git commit -m foo --quiet + +# Merge changes to a new system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" branch otherbranch +cd otherbranch/morphs +"$SRCDIR/scripts/test-morph" edit hello master +"$SRCDIR/scripts/test-morph" merge newbranch hello + +# Check results. +cd ../hello +git status --short # make sure all changes are committed +ls newfile.txt # make sure the new file is there + diff --git a/tests.branching/merge-explicitly-named-repos.stdout b/tests.branching/merge-explicitly-named-repos.stdout new file mode 100644 index 00000000..cd2122c4 --- /dev/null +++ b/tests.branching/merge-explicitly-named-repos.stdout @@ -0,0 +1 @@ +newfile.txt diff --git a/tests.branching/minedir-not-found.exit b/tests.branching/minedir-not-found.exit new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests.branching/minedir-not-found.exit @@ -0,0 +1 @@ +1 diff --git a/tests.branching/minedir-not-found.script b/tests.branching/minedir-not-found.script new file mode 100755 index 00000000..eb8c9d51 --- /dev/null +++ b/tests.branching/minedir-not-found.script @@ -0,0 +1,19 @@ +#!/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. + +scripts/test-morph init "$DATADIR/mine" +cd "$DATADIR" +"$SRCDIR/scripts/test-morph" minedir diff --git a/tests.branching/minedir-not-found.stderr b/tests.branching/minedir-not-found.stderr new file mode 100644 index 00000000..46dbd84b --- /dev/null +++ b/tests.branching/minedir-not-found.stderr @@ -0,0 +1 @@ +ERROR: Can't find the mine directory diff --git a/tests.branching/minedir.script b/tests.branching/minedir.script new file mode 100755 index 00000000..5f3574b7 --- /dev/null +++ b/tests.branching/minedir.script @@ -0,0 +1,20 @@ +#!/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. + +scripts/test-morph init "$DATADIR/mine" +mkdir -p "$DATADIR/mine/a/b/c" +cd "$DATADIR/mine/a/b/c" +"$SRCDIR/scripts/test-morph" minedir diff --git a/tests.branching/minedir.stdout b/tests.branching/minedir.stdout new file mode 100644 index 00000000..0fc25ee9 --- /dev/null +++ b/tests.branching/minedir.stdout @@ -0,0 +1 @@ +TMP/mine diff --git a/tests.branching/setup b/tests.branching/setup new file mode 100755 index 00000000..68117fa3 --- /dev/null +++ b/tests.branching/setup @@ -0,0 +1,99 @@ +#!/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. + + +# Set up $DATADIR. +# +# - a morph.conf configuration file +# - an empty morph mine directory +# - a git repository called "morphs" for fake system, stratum morphologies +# - a git repository calle "hello" for a dummy chunk + +set -eu + + +# Create a morph configuration file +cat <<EOF > "$DATADIR/morph.conf" +[config] +git-base-url = file://$DATADIR/ +cachedir = $DATADIR/mine/.morph/cache +log = $DATADIR/morph.log +keep-path = true +no-distcc = true +EOF + + +# Create an empty directory to be used as a morph mine +mkdir "$DATADIR/mine" + + +# Create a fake morphs repository +mkdir "$DATADIR/morphs" + +cat <<EOF > "$DATADIR/morphs/hello-system.chunk" +{ + "name": "hello-system", + "kind": "system", + "disk-size": "1G", + "strata": [ + "hello-stratum" + ] +} +EOF + +cat <<EOF > "$DATADIR/morphs/hello-stratum.chunk" +{ + "name": "hello-stratum", + "kind": "stratum", + "sources": [ + { + "name": "hello", + "ref": "master" + } + ] +} +EOF + +scripts/run-git-in "$DATADIR/morphs" init +scripts/run-git-in "$DATADIR/morphs" add . +scripts/run-git-in "$DATADIR/morphs" commit -m initial + + +# Add an extra branch to the morphs repo. +scripts/run-git-in "$DATADIR/morphs" checkout -b alfred +scripts/run-git-in "$DATADIR/morphs" checkout master + + +# Create a dummy chunk repository +mkdir "$DATADIR/hello" + +cat <<EOF > "$DATADIR/hello/hello.chunk" +{ + "name": "hello", + "kind": "chunk", + "build-system": "dummy" +} +EOF + +scripts/run-git-in "$DATADIR/hello" init +scripts/run-git-in "$DATADIR/hello" add . +scripts/run-git-in "$DATADIR/hello" commit -m initial + + +# Add an extra branch to the hello repo. +scripts/run-git-in "$DATADIR/hello" checkout -b alfred +scripts/run-git-in "$DATADIR/hello" checkout master + diff --git a/tests.branching/show-system-branch-shows-name-correctly.script b/tests.branching/show-system-branch-shows-name-correctly.script new file mode 100755 index 00000000..38b2aa14 --- /dev/null +++ b/tests.branching/show-system-branch-shows-name-correctly.script @@ -0,0 +1,31 @@ +#!/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 show-system-branch' shows the name of the current system +# branch correctly. + + +set -eu + +# Create system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" branch newbranch + +cd newbranch/morphs +"$SRCDIR/scripts/test-morph" show-system-branch + diff --git a/tests.branching/show-system-branch-shows-name-correctly.stdout b/tests.branching/show-system-branch-shows-name-correctly.stdout new file mode 100644 index 00000000..467e4889 --- /dev/null +++ b/tests.branching/show-system-branch-shows-name-correctly.stdout @@ -0,0 +1 @@ +newbranch diff --git a/tests.branching/teardown b/tests.branching/teardown new file mode 100755 index 00000000..94928416 --- /dev/null +++ b/tests.branching/teardown @@ -0,0 +1,22 @@ +#!/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. + + +# Clean up $DATADIR. + +set -eu + +find "$DATADIR" -mindepth 1 -delete diff --git a/tests.branching/workflow.script b/tests.branching/workflow.script new file mode 100755 index 00000000..d2ce374f --- /dev/null +++ b/tests.branching/workflow.script @@ -0,0 +1,39 @@ +#!/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. + + +# Do a complete workflow test with Morph branching and merging. + + +set -eu + + +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" branch me/readme-fix +cd me/readme-fix/morphs +"$SRCDIR/scripts/test-morph" edit hello master +cd ../hello +echo > README yoyoyo +git add README +git commit -m "Fix README, yo!" --quiet + +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" checkout master +cd master/morphs +"$SRCDIR/scripts/test-morph" edit hello master +"$SRCDIR/scripts/test-morph" merge me/readme-fix hello + |