From a7fcb2df5522b2714194e7c290414f2a25688b74 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Thu, 9 Aug 2012 22:32:56 -0500 Subject: [PATCH] Move shared code to replay-lib.sh * tests/replay-lib.sh (init_replay_repo): Move duplicated code from t01??*.sh scripts to create an empty repo for svnreplay to this shared function. * tests/t010?*.sh: Use replay-lib.sh and init_replay_repo(). * tests/t010?*.sh: Respect $TEST_DIRECTORY shell variable rather than hard-coding `pwd`. --- tests/replay-lib.sh | 12 ++++++++++++ tests/t0100-replay-all.sh | 15 +++++---------- tests/t0101-replay-trunk.sh | 15 +++++---------- tests/t0102-replay-branch.sh | 15 +++++---------- 4 files changed, 27 insertions(+), 30 deletions(-) create mode 100755 tests/replay-lib.sh diff --git a/tests/replay-lib.sh b/tests/replay-lib.sh new file mode 100755 index 0000000..bcb0750 --- /dev/null +++ b/tests/replay-lib.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Setup a brand-new repo ready for svnreplay +init_replay_repo () { + REPO=$1 + # Init repo + rm -rf "$REPO" + svnadmin create "$REPO" + # Add pre-revprop-change hook script + cp ../hook-examples/pre-revprop-change_example.txt "$REPO/hooks/pre-revprop-change" + chmod 755 "$REPO/hooks/pre-revprop-change" +} diff --git a/tests/t0100-replay-all.sh b/tests/t0100-replay-all.sh index e822c09..3fe3ff2 100755 --- a/tests/t0100-replay-all.sh +++ b/tests/t0100-replay-all.sh @@ -3,22 +3,16 @@ test_description='Use svnreplay to create a full copy of the ref repo ' . ./test-lib.sh +. ./replay-lib.sh SVNREPLAY="../svnreplay.py" -PWD=$(pwd) +PWD=${TEST_DIRECTORY:-.} PWDURL=$(echo "file://$PWD" | sed 's/\ /%20/g') REPO="$PWD/_repo_replay" REPOURL=$(echo "file://$REPO" | sed 's/\ /%20/g') -# Clean-up -rm -rf "$REPO" _wc_target - -# Init repo -svnadmin create "$REPO" -# Add pre-revprop-change hook script -cp ../hook-examples/pre-revprop-change_example.txt "$REPO/hooks/pre-revprop-change" -chmod 755 "$REPO/hooks/pre-revprop-change" - +init_replay_repo "$REPO" +rm -rf _wc_target ################################################################ OFFSET="/" @@ -31,4 +25,5 @@ test_expect_success \ "diff-repo _repo_ref$OFFSET _repo_replay$OFFSET" \ "./diff-repo.sh \"$PWDURL/_repo_ref$OFFSET\" \"$PWDURL/_repo_replay$OFFSET\"" +rm -rf "$REPO" _wc_target test_done diff --git a/tests/t0101-replay-trunk.sh b/tests/t0101-replay-trunk.sh index 5d877bc..be0de42 100755 --- a/tests/t0101-replay-trunk.sh +++ b/tests/t0101-replay-trunk.sh @@ -3,22 +3,16 @@ test_description='Use svnreplay to create a filtered repo with only /trunk history ' . ./test-lib.sh +. ./replay-lib.sh SVNREPLAY="../svnreplay.py" -PWD=$(pwd) +PWD=${TEST_DIRECTORY:-.} PWDURL=$(echo "file://$PWD" | sed 's/\ /%20/g') REPO="$PWD/_repo_replay" REPOURL=$(echo "file://$REPO" | sed 's/\ /%20/g') -# Clean-up -rm -rf "$REPO" _wc_target - -# Init repo -svnadmin create "$REPO" -# Add pre-revprop-change hook script -cp ../hook-examples/pre-revprop-change_example.txt "$REPO/hooks/pre-revprop-change" -chmod 755 "$REPO/hooks/pre-revprop-change" - +init_replay_repo "$REPO" +rm -rf _wc_target ################################################################ OFFSET="/trunk" @@ -32,4 +26,5 @@ test_expect_success \ "diff-repo _repo_ref$OFFSET _repo_replay$OFFSET" \ "./diff-repo.sh \"$PWDURL/_repo_ref$OFFSET\" \"$PWDURL/_repo_replay$OFFSET\"" +rm -rf "$REPO" _wc_target test_done diff --git a/tests/t0102-replay-branch.sh b/tests/t0102-replay-branch.sh index 4ab2ccf..8c35c24 100755 --- a/tests/t0102-replay-branch.sh +++ b/tests/t0102-replay-branch.sh @@ -3,22 +3,16 @@ test_description='Use svnreplay to create a filtered repo with only /trunk/Module2/ProjectB history ' . ./test-lib.sh +. ./replay-lib.sh SVNREPLAY="../svnreplay.py" -PWD=$(pwd) +PWD=${TEST_DIRECTORY:-.} PWDURL=$(echo "file://$PWD" | sed 's/\ /%20/g') REPO="$PWD/_repo_replay" REPOURL=$(echo "file://$REPO" | sed 's/\ /%20/g') -# Clean-up -rm -rf "$REPO" _wc_target - -# Init repo -svnadmin create "$REPO" -# Add pre-revprop-change hook script -cp ../hook-examples/pre-revprop-change_example.txt "$REPO/hooks/pre-revprop-change" -chmod 755 "$REPO/hooks/pre-revprop-change" - +init_replay_repo "$REPO" +rm -rf _wc_target ################################################################ OFFSET="/trunk/Module2/ProjectB" @@ -33,4 +27,5 @@ test_expect_success \ "diff-repo _repo_ref$OFFSET _repo_replay$OFFSET" \ "./diff-repo.sh \"$PWDURL/_repo_ref$OFFSET\" \"$PWDURL/_repo_replay$OFFSET\"" +rm -rf "$REPO" _wc_target test_done -- 2.45.2