summaryrefslogtreecommitdiff
path: root/yarns/implementations.yarn
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-08-27 16:39:53 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2014-08-28 13:48:26 +0100
commit1edbc9f5c08daafb3e13131dfc8df656b2a02edc (patch)
tree5ea1ba505bb50ee616567f74551aadb2b51fa0d3 /yarns/implementations.yarn
parent8c31c741a0d4341a536c7bf612a95b136795c8a2 (diff)
downloadmorph-1edbc9f5c08daafb3e13131dfc8df656b2a02edc.tar.gz
yarns: Use a more realistic simulation of a git serverbaserock/richardmaw/yarn-git-daemon
Previously we would use file: URIs to point to the git repositories. This was fast and simple, but had the drawback that it bypassed all the git cache logic, so changes to the git cache weren't adequately covered by the test suite. Now we spool up a simulated git server per scenario, and shut it down at the end.
Diffstat (limited to 'yarns/implementations.yarn')
-rw-r--r--yarns/implementations.yarn24
1 files changed, 23 insertions, 1 deletions
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 477849eb..422c2eea 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -258,12 +258,25 @@ another to hold a chunk.
run_in "$DATADIR/gits/morphs" git commit -m Initial.
run_in "$DATADIR/gits/morphs" git tag -a "test-tag" -m "Tagging test-tag"
+ # Start a git daemon to serve our git repositories
+ port_file="$DATADIR/git-daemon-port"
+ pid_file="$DATADIR/git-daemon-pid"
+ mkfifo "$port_file"
+ # git-daemon needs --foo=bar style arguments so we do that for consistency
+ start-stop-daemon --start --pidfile="$pid_file" --background \
+ --make-pidfile --verbose \
+ --startas="$SRCDIR/scripts/git-daemon-wrap" -- \
+ --port-file="$port_file" \
+ --export-all --verbose --base-path="$DATADIR/gits" \
+ --enable=receive-pack #allow push
+ GIT_DAEMON_PORT="$(cat "$port_file")"
+
# Create the Morph configuration file so we can access the repos
# using test:foo URL aliases.
cat << EOF > "$DATADIR/morph.conf"
[config]
- repo-alias = test=file://$DATADIR/gits/%s#file://$DATADIR/gits/%s
+ repo-alias = test=git://127.0.0.1:$GIT_DAEMON_PORT/%s#git://127.0.0.1:$GIT_DAEMON_PORT/%s
cachedir = $DATADIR/cache
tempdir = $DATADIR/tmp
trove-host= []
@@ -272,6 +285,15 @@ another to hold a chunk.
mkdir "$DATADIR/cache"
mkdir "$DATADIR/tmp"
+Some resources are cleaned up by yarn, forked processes aren't one of
+these, so need to shut down the git daemon after we finish.
+
+ IMPLEMENTS FINALLY the git server is shut down
+ pid_file="$DATADIR/git-daemon-pid"
+ if [ -e "$pid_file" ]; then
+ start-stop-daemon --stop --pidfile "$pid_file" --oknodo
+ fi
+
We need a consistent value for the architecture in some tests, so we
have a morphology using the test architecture.