summaryrefslogtreecommitdiff
path: root/tests.branching
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-20 17:20:16 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-21 16:06:08 +0100
commit4e99430709842dccd014410d5edf67aae39c519e (patch)
tree11aa2ab9ce9bdb2ac66d24d9a445189c61dee6c2 /tests.branching
parentd473e869cb2ad2fa54696f0336ade1c1fbb0ec84 (diff)
downloadmorph-4e99430709842dccd014410d5edf67aae39c519e.tar.gz
Add petrify/unpetrify workflow test
Split out the external strata scripts to share between workflow tests.
Diffstat (limited to 'tests.branching')
-rw-r--r--tests.branching/setup-3rd-party-strata134
-rwxr-xr-xtests.branching/workflow-petrify.script67
-rw-r--r--tests.branching/workflow-petrify.stdout152
-rwxr-xr-xtests.branching/workflow-separate-stratum-repos.script114
4 files changed, 355 insertions, 112 deletions
diff --git a/tests.branching/setup-3rd-party-strata b/tests.branching/setup-3rd-party-strata
new file mode 100644
index 00000000..e82d5aeb
--- /dev/null
+++ b/tests.branching/setup-3rd-party-strata
@@ -0,0 +1,134 @@
+#!/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.
+
+
+# Create strata outside the main morphologies repository, which is useful
+# for the more complex workflow tests.
+
+
+. "$SRCDIR/scripts/fix-committer-info"
+
+create_chunk() {
+ REPO="$1"
+ NAME="$2"
+
+ mkdir "$1"
+ ln -s "$1" "$1.git"
+ cd "$1"
+
+ cat <<EOF > "$1/$2.morph"
+{
+ "name": "$2",
+ "kind": "chunk",
+ "build-system": "dummy"
+}
+EOF
+
+ git init --quiet
+ git add .
+ git commit --quiet -m "Initial commit"
+}
+
+write_stratum_morph() {
+ REPO="$1"
+ NAME="$2"
+
+cat <<EOF > "$1/$2.morph"
+{
+ "name": "$2",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "baserock:$2-hello",
+ "ref": "master",
+ "build-depends": []
+ }
+ ]
+}
+EOF
+}
+
+# Create two more strata outside the baserock:morphs repository
+
+EXTERNAL_STRATA_REPO="$DATADIR/external-strata"
+mkdir "$EXTERNAL_STRATA_REPO"
+ln -s "$EXTERNAL_STRATA_REPO" "$EXTERNAL_STRATA_REPO".git
+cd "$EXTERNAL_STRATA_REPO"
+
+git init --quiet .
+
+write_stratum_morph "$EXTERNAL_STRATA_REPO" "stratum2"
+write_stratum_morph "$EXTERNAL_STRATA_REPO" "stratum3"
+
+git add .
+git commit --quiet -m "Initial commit"
+
+# To make life harder, both chunks have the same name too
+
+create_chunk "$DATADIR/stratum2-hello" "hello"
+create_chunk "$DATADIR/stratum3-hello" "hello"
+
+# Update hello-system to include them ... using a system branch! Since the
+# strata refs are 'master' not 'me/add-external-strata' this does not cause
+# problems with merging.
+
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init
+"$SRCDIR/scripts/test-morph" branch baserock:morphs me/add-external-strata
+
+cd "$DATADIR/workspace/me/add-external-strata/baserock:morphs"
+
+cat <<EOF > "hello-system.morph"
+{
+ "name": "hello-system",
+ "kind": "system",
+ "system-kind": "syslinux-disk",
+ "arch": "x86_64",
+ "disk-size": "1G",
+ "strata": [
+ {
+ "morph": "hello-stratum",
+ "repo": "baserock:morphs",
+ "ref": "master"
+ },
+ {
+ "morph": "stratum2",
+ "repo": "baserock:external-strata",
+ "ref": "master"
+ },
+ {
+ "morph": "stratum3",
+ "repo": "baserock:external-strata",
+ "ref": "master"
+ }
+ ]
+}
+EOF
+git commit --quiet --all -m "Add two more external strata"
+
+# Merge to master
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
+cd master/baserock:morphs
+"$SRCDIR/scripts/test-morph" merge me/add-external-strata
+
+# In reality the user would do: 'git push origin master' here,
+# but since our remote repo is non-bare we must cheat a bit.
+# We should consider a separate fixture for the workflow tests.
+cd "$DATADIR/morphs"
+git pull -q \
+ "file://$DATADIR/workspace/master/baserock:morphs" master
diff --git a/tests.branching/workflow-petrify.script b/tests.branching/workflow-petrify.script
new file mode 100755
index 00000000..887de622
--- /dev/null
+++ b/tests.branching/workflow-petrify.script
@@ -0,0 +1,67 @@
+#!/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 strata outside the main morphologies
+# repository.
+
+
+set -eu
+
+. "$SRCDIR/tests.branching/setup-3rd-party-strata"
+
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" branch baserock:morphs test/petrify
+
+cd test/petrify
+"$SRCDIR/scripts/test-morph" petrify
+
+echo "test/petrify after petrifying:"
+cat baserock:morphs/hello-system.morph
+cat baserock:external-strata/stratum2.morph
+cat baserock:external-strata/stratum3.morph
+
+"$SRCDIR/scripts/test-morph" edit hello-system stratum2 hello
+
+echo
+echo "test/petrify after editing a chunk:"
+cat baserock:morphs/hello-system.morph
+cat baserock:external-strata/stratum2.morph
+cat baserock:external-strata/stratum3.morph
+
+# me/readme-fixes in baserock:stratum2-hello should be 'master', but
+# that's the only ref upstream so we can infer that it is if we got here
+
+cd baserock:morphs
+git commit --quiet --all -m "Petrify branch test/petrify"
+git push --quiet origin test/petrify
+cd ../baserock:external-strata
+git commit --quiet --all -m "Petrify branch test/petrify"
+git push --quiet origin test/petrify
+
+# unpetrify is easy enough. Let's try unpetrifying a different branch that
+# was forked off the original while it was petrified, instead.
+cd "$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" branch baserock:morphs test/unpetrify test/petrify
+
+cd test/unpetrify
+"$SRCDIR/scripts/test-morph" unpetrify
+
+echo
+echo "test/unpetrify after unpetrifying:"
+cat baserock:morphs/hello-system.morph
+cat baserock:external-strata/stratum2.morph
+cat baserock:external-strata/stratum3.morph
diff --git a/tests.branching/workflow-petrify.stdout b/tests.branching/workflow-petrify.stdout
new file mode 100644
index 00000000..2c50db9c
--- /dev/null
+++ b/tests.branching/workflow-petrify.stdout
@@ -0,0 +1,152 @@
+test/petrify after petrifying:
+{
+ "name": "hello-system",
+ "kind": "system",
+ "system-kind": "syslinux-disk",
+ "arch": "x86_64",
+ "disk-size": "1G",
+ "strata": [
+ {
+ "morph": "hello-stratum",
+ "repo": "baserock:morphs",
+ "ref": "test/petrify"
+ },
+ {
+ "morph": "stratum2",
+ "repo": "baserock:external-strata",
+ "ref": "test/petrify"
+ },
+ {
+ "morph": "stratum3",
+ "repo": "baserock:external-strata",
+ "ref": "test/petrify"
+ }
+ ]
+}
+{
+ "name": "stratum2",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "baserock:stratum2-hello",
+ "ref": "f4730636e429149bb923fa16be3aa9802d484b23",
+ "build-depends": [],
+ "unpetrify-ref": "master"
+ }
+ ]
+}
+{
+ "name": "stratum3",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "baserock:stratum3-hello",
+ "ref": "f4730636e429149bb923fa16be3aa9802d484b23",
+ "build-depends": [],
+ "unpetrify-ref": "master"
+ }
+ ]
+}
+
+test/petrify after editing a chunk:
+{
+ "name": "hello-system",
+ "kind": "system",
+ "system-kind": "syslinux-disk",
+ "arch": "x86_64",
+ "disk-size": "1G",
+ "strata": [
+ {
+ "morph": "hello-stratum",
+ "repo": "baserock:morphs",
+ "ref": "test/petrify"
+ },
+ {
+ "morph": "stratum2",
+ "repo": "baserock:external-strata",
+ "ref": "test/petrify"
+ },
+ {
+ "morph": "stratum3",
+ "repo": "baserock:external-strata",
+ "ref": "test/petrify"
+ }
+ ]
+}
+{
+ "name": "stratum2",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "baserock:stratum2-hello",
+ "ref": "test/petrify",
+ "build-depends": []
+ }
+ ]
+}
+{
+ "name": "stratum3",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "baserock:stratum3-hello",
+ "ref": "f4730636e429149bb923fa16be3aa9802d484b23",
+ "build-depends": [],
+ "unpetrify-ref": "master"
+ }
+ ]
+}
+
+test/unpetrify after unpetrifying:
+{
+ "name": "hello-system",
+ "kind": "system",
+ "system-kind": "syslinux-disk",
+ "arch": "x86_64",
+ "disk-size": "1G",
+ "strata": [
+ {
+ "morph": "hello-stratum",
+ "repo": "baserock:morphs",
+ "ref": "test/unpetrify"
+ },
+ {
+ "morph": "stratum2",
+ "repo": "baserock:external-strata",
+ "ref": "test/unpetrify"
+ },
+ {
+ "morph": "stratum3",
+ "repo": "baserock:external-strata",
+ "ref": "test/unpetrify"
+ }
+ ]
+}
+{
+ "name": "stratum2",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "baserock:stratum2-hello",
+ "ref": "test/petrify",
+ "build-depends": []
+ }
+ ]
+}
+{
+ "name": "stratum3",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "hello",
+ "repo": "baserock:stratum3-hello",
+ "ref": "master",
+ "build-depends": []
+ }
+ ]
+}
diff --git a/tests.branching/workflow-separate-stratum-repos.script b/tests.branching/workflow-separate-stratum-repos.script
index 06c4f3b8..d8be404c 100755
--- a/tests.branching/workflow-separate-stratum-repos.script
+++ b/tests.branching/workflow-separate-stratum-repos.script
@@ -22,119 +22,9 @@
set -eu
-create_chunk() {
- REPO="$1"
- NAME="$2"
+. "$SRCDIR/tests.branching/setup-3rd-party-strata"
- mkdir "$1"
- ln -s "$1" "$1.git"
- cd "$1"
-
- cat <<EOF > "$1/$2.morph"
-{
- "name": "$2",
- "kind": "chunk",
- "build-system": "dummy"
-}
-EOF
-
- git init --quiet
- git add .
- git commit --quiet -m "Initial commit"
-}
-
-write_stratum_morph() {
- REPO="$1"
- NAME="$2"
-
-cat <<EOF > "$1/$2.morph"
-{
- "name": "$2",
- "kind": "stratum",
- "chunks": [
- {
- "name": "hello",
- "repo": "baserock:$2-hello",
- "ref": "master",
- "build-depends": []
- }
- ]
-}
-EOF
-}
-
-# Create two more strata outside the baserock:morphs repository
-
-EXTERNAL_STRATA_REPO="$DATADIR/external-strata"
-mkdir "$EXTERNAL_STRATA_REPO"
-ln -s "$EXTERNAL_STRATA_REPO" "$EXTERNAL_STRATA_REPO".git
-cd "$EXTERNAL_STRATA_REPO"
-
-git init --quiet .
-
-write_stratum_morph "$EXTERNAL_STRATA_REPO" "stratum2"
-write_stratum_morph "$EXTERNAL_STRATA_REPO" "stratum3"
-
-git add .
-git commit --quiet -m "Initial commit"
-
-# To make life harder, both chunks have the same name too
-
-create_chunk "$DATADIR/stratum2-hello" "hello"
-create_chunk "$DATADIR/stratum3-hello" "hello"
-
-# Update hello-system to include them ... using a system branch! Since the
-# strata refs are 'master' not 'me/add-external-strata' this does not cause
-# problems with merging.
-
-cd "$DATADIR/workspace"
-"$SRCDIR/scripts/test-morph" init
-"$SRCDIR/scripts/test-morph" branch baserock:morphs me/add-external-strata
-
-cd "$DATADIR/workspace/me/add-external-strata/baserock:morphs"
-
-cat <<EOF > "hello-system.morph"
-{
- "name": "hello-system",
- "kind": "system",
- "system-kind": "syslinux-disk",
- "arch": "x86_64",
- "disk-size": "1G",
- "strata": [
- {
- "morph": "hello-stratum",
- "repo": "baserock:morphs",
- "ref": "master"
- },
- {
- "morph": "stratum2",
- "repo": "baserock:external-strata",
- "ref": "master"
- },
- {
- "morph": "stratum3",
- "repo": "baserock:external-strata",
- "ref": "master"
- }
- ]
-}
-EOF
-git commit --quiet --all -m "Add two more external strata"
-
-# Merge to master
-cd "$DATADIR/workspace"
-"$SRCDIR/scripts/test-morph" checkout baserock:morphs master
-cd master/baserock:morphs
-"$SRCDIR/scripts/test-morph" merge me/add-external-strata
-
-# In reality the user would do: 'git push origin master' here,
-# but since our remote repo is non-bare we must cheat a bit.
-# We should consider a separate fixture for the workflow tests.
-cd "$DATADIR/morphs"
-git pull -q \
- "file://$DATADIR/workspace/master/baserock:morphs" master
-
-# Now make another change to the system
+# Make a change to the system
# FIXME: we should try and build it, too
cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" branch baserock:morphs me/readme-fixes