summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/build-chunk.script2
-rwxr-xr-xtests/build-stratum.script2
-rwxr-xr-xtests/build-system.script2
-rwxr-xr-xtests/missing-ref.script2
-rwxr-xr-xtests/rebuild-cached-stratum.script64
-rw-r--r--tests/rebuild-cached-stratum.stdout8
-rwxr-xr-xtests/setup_once36
7 files changed, 102 insertions, 14 deletions
diff --git a/tests/build-chunk.script b/tests/build-chunk.script
index a4e1fef6..01fbf8f5 100755
--- a/tests/build-chunk.script
+++ b/tests/build-chunk.script
@@ -21,7 +21,7 @@ set -e
cache="$DATADIR/build-chunk-cache"
log="$DATADIR/build-chunk-morph.log"
-./morph --no-default-configs build repo farrokh hello.morph \
+./morph --no-default-configs build chunk-repo farrokh hello.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path --no-distcc \
--log="$log" || cat "$log" 1>&2
diff --git a/tests/build-stratum.script b/tests/build-stratum.script
index bd938860..dadda81f 100755
--- a/tests/build-stratum.script
+++ b/tests/build-stratum.script
@@ -21,7 +21,7 @@ set -e
cache="$DATADIR/build-stratum-cache"
log="$DATADIR/build-stratum-morph.log"
-./morph --no-default-configs build repo farrokh hello-stratum.morph \
+./morph --no-default-configs build morphs-repo master hello-stratum.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path --no-distcc \
--log="$log" || cat "$log" 1>&2
diff --git a/tests/build-system.script b/tests/build-system.script
index c96662cc..1553b85a 100755
--- a/tests/build-system.script
+++ b/tests/build-system.script
@@ -21,7 +21,7 @@ set -e
cache="$DATADIR/build-system-cache"
log="$DATADIR/build-system-morph.log"
-./morph --no-default-configs build repo farrokh hello-system.morph \
+./morph --no-default-configs build morphs-repo master hello-system.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path --no-distcc \
--log="$log" || cat "$log" 1>&2
diff --git a/tests/missing-ref.script b/tests/missing-ref.script
index 978f50fa..0c4f29f7 100755
--- a/tests/missing-ref.script
+++ b/tests/missing-ref.script
@@ -20,7 +20,7 @@
set -e
cache="$DATADIR/build-chunk-cache"
-./morph --no-default-configs build repo non-existent-branch hello.morph \
+./morph --no-default-configs build chunk-repo non-existent-branch hello.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path --no-distcc
diff --git a/tests/rebuild-cached-stratum.script b/tests/rebuild-cached-stratum.script
new file mode 100755
index 00000000..2802dd54
--- /dev/null
+++ b/tests/rebuild-cached-stratum.script
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# Does a cached stratum get rebuilt if its chunk changes?
+# This tests a bug that is currently in morph, where the stratum does
+# not get rebuilt in that case. Later on, the test will guard against
+# regressions.
+#
+# Copyright (C) 2011 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 -e
+
+cache="$DATADIR/rebuild-cached-stratum-cache"
+log="$DATADIR/rebuild-cached-stratum-morph.log"
+
+# Make a branch in the chunk repo where we can make our own modifications.
+(cd "$DATADIR/chunk-repo" &&
+ git checkout --quiet farrokh &&
+ git checkout --quiet -b rebuild-cached-stratum)
+
+# Make a branch in the morphs repo and modify the stratum to refer to
+# the new chunk branch.
+(cd "$DATADIR/morphs-repo" &&
+ git checkout --quiet -b rebuild-cached-stratum &&
+ sed -i 's/farrokh/rebuild-cached-stratum/' hello-stratum.morph &&
+ git commit --quiet -m "rebuild-cached-stratum" -a)
+
+# Build the first time.
+./morph --no-default-configs \
+ build morphs-repo rebuild-cached-stratum hello-stratum.morph \
+ --git-base-url="file://$DATADIR" \
+ --cachedir="$cache" --keep-path --no-distcc \
+ --log="$log" || cat "$log" 1>&2
+echo "first build:"
+(cd "$cache" && ls *.chunk.* *.stratum.* | sed 's/^[^.]*\./ /' |
+ LC_ALL=C sort)
+
+# Change the chunk.
+(cd "$DATADIR/chunk-repo" &&
+ echo >> hello.c &&
+ git commit --quiet -am change)
+
+# Rebuild.
+./morph --no-default-configs \
+ build morphs-repo rebuild-cached-stratum hello-stratum.morph \
+ --git-base-url="file://$DATADIR" \
+ --cachedir="$cache" --keep-path --no-distcc \
+ --log="$log" || cat "$log" 1>&2
+echo "second build:"
+(cd "$cache" && ls *.chunk.* *.stratum.* | sed 's/^[^.]*\./ /' |
+ LC_ALL=C sort)
+
diff --git a/tests/rebuild-cached-stratum.stdout b/tests/rebuild-cached-stratum.stdout
new file mode 100644
index 00000000..eee106f5
--- /dev/null
+++ b/tests/rebuild-cached-stratum.stdout
@@ -0,0 +1,8 @@
+first build:
+ chunk.hello
+ stratum.hello-stratum
+second build:
+ chunk.hello
+ chunk.hello
+ stratum.hello-stratum
+ stratum.hello-stratum
diff --git a/tests/setup_once b/tests/setup_once
index e969c1a3..0fa19fc4 100755
--- a/tests/setup_once
+++ b/tests/setup_once
@@ -1,12 +1,15 @@
#!/bin/sh
#
-# Create a git repository for tests. The repository will contain a simple
-# "hello, world" C program, and two branches ("master", "farrokh"), with
-# the master branch containing just a README. The two branches are there
+# Create git repositories for tests. The chunk repository will contain a
+# simple "hello, world" C program, and two branches ("master", "farrokh"),
+# with the master branch containing just a README. The two branches are there
# so that we can test building a branch that hasn't been checked out.
# The branches are different so that we know that if the wrong branch
# is uses, the build will fail.
#
+# The stratum repository contains a single branch, "master", with a
+# stratum and a system morphology that include the chunk above.
+#
# Copyright (C) 2011 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
@@ -25,9 +28,11 @@
set -e
-repo="$DATADIR/repo"
-mkdir "$repo"
-cd "$repo"
+# Create chunk repository.
+
+chunkrepo="$DATADIR/chunk-repo"
+mkdir "$chunkrepo"
+cd "$chunkrepo"
git init --quiet
cat <<EOF > README
@@ -64,6 +69,19 @@ cat <<EOF > hello.morph
EOF
git add hello.morph
+git commit --quiet -m "add a hello world program and morph"
+
+git checkout --quiet master
+
+
+
+# Create morph repository.
+
+morphsrepo="$DATADIR/morphs-repo"
+mkdir "$morphsrepo"
+cd "$morphsrepo"
+git init --quiet
+
cat <<EOF > hello-stratum.morph
{
"name": "hello-stratum",
@@ -71,7 +89,7 @@ cat <<EOF > hello-stratum.morph
"sources": [
{
"name": "hello",
- "repo": "repo",
+ "repo": "chunk-repo",
"ref": "farrokh"
}
]
@@ -91,7 +109,5 @@ cat <<EOF > hello-system.morph
EOF
git add hello-system.morph
-git commit --quiet -m "add a hello world program and morphs"
-
-git checkout --quiet master
+git commit --quiet -m "add morphs"