From 0e84f0a2f0675dfdad38c4995bd3b3d4a1f9613e Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Fri, 6 Jan 2012 21:06:20 -0600 Subject: [PATCH] Test scripts --- .gitignore | 3 + COPYING.txt => LICENSE.txt | 0 tests/make-ref-repo.sh | 138 +++++++++++++++++++++++++++++++++++++ tests/make-replay-repo.sh | 18 +++++ 4 files changed, 159 insertions(+) create mode 100644 .gitignore rename COPYING.txt => LICENSE.txt (100%) create mode 100755 tests/make-ref-repo.sh create mode 100755 tests/make-replay-repo.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..132393a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +tests/_repo* +tests/_wc* +tests/_dup_wc diff --git a/COPYING.txt b/LICENSE.txt similarity index 100% rename from COPYING.txt rename to LICENSE.txt diff --git a/tests/make-ref-repo.sh b/tests/make-ref-repo.sh new file mode 100755 index 0000000..f93b703 --- /dev/null +++ b/tests/make-ref-repo.sh @@ -0,0 +1,138 @@ +#!/bin/sh +# Create a reference repo with both /trunk and /branches history + +show_last_commit() { + LOG=$(svn log -l1 $REPOURL) + revision=$(echo "$LOG" | head -n 2 | tail -n 1| cut -d \| -f 1) + comment=$(echo "$LOG" | head -n 4 | tail -n 1) + _WC="${WC//\//\\/}" + if [ -x $WC ]; then + len=$(expr ${#REPOURL} + 7) + url=$(svn info $WC | grep "URL:" | cut -c$len-) + url="($url)" + fi + printf "%-6s%-18s%s\n" "$revision" "$url" "$comment" +} + +svn_commit() { + svn ci -q -m "$1" $2 + svn up -q + show_last_commit +} + + +PWD=$(pwd) +REPO="$PWD/_repo_ref" +REPOURL="file://$REPO" +WC="$PWD/_wc_ref" + +# Clean-up +echo "Cleaning-up..." +rm -rf $REPO $WC + +# Init repo +echo "Creating _repo_ref..." +svnadmin create $REPO +svn mkdir -q -m "Add /trunk" $REPOURL/trunk +show_last_commit +svn mkdir -q -m "Add /branches" $REPOURL/branches +show_last_commit +TRUNK="$REPOURL/trunk" +svn co -q $TRUNK $WC +cd $WC + +# Initial Population +mkdir -p $WC/Module/ProjectA +echo "Module/ProjectA/FileA1.txt" > $WC/Module/ProjectA/FileA1.txt +echo "Module/ProjectA/FileA2.txt" > $WC/Module/ProjectA/FileA2.txt +echo "Module/ProjectA/FileA3.txt" > $WC/Module/ProjectA/FileA3.txt +svn -q add $WC/Module +svn_commit "Initial population" + +# Add new file +# * Test simple copy-from branch +BRANCH="$REPOURL/branches/fix1" +svn copy -q -m "Create branch" $TRUNK $BRANCH +svn switch -q $BRANCH +show_last_commit +mkdir -p $WC/Module/ProjectB +echo "Module/ProjectB/FileB1.txt" > $WC/Module/ProjectB/FileB1.txt +echo "Module/ProjectB/FileB2.txt" > $WC/Module/ProjectB/FileB2.txt +svn add -q $WC/Module/ProjectB +svn_commit "Fix 1: Add Module/ProjectB" +svn switch -q $TRUNK +svn merge -q $BRANCH +svn_commit "Fix 1: Add Module/ProjectB" + +# Rename files +# * Test rename support +# * Test committing rename in two different branch commits: first deletion, then add +BRANCH="$REPOURL/branches/fix2" +svn copy -q -m "Create branch" $TRUNK $BRANCH +svn switch -q $BRANCH +show_last_commit +svn mv -q Module/ProjectA/FileA2.txt Module/ProjectB/FileB3.txt +svn_commit "Fix 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt (part 1 of 2)" Module/ProjectA +svn_commit "Fix 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt (part 2 of 2)" Module/ProjectB +svn switch -q $TRUNK +svn merge -q $BRANCH +svn_commit "Fix 2: Rename Module/ProjectA/FileA2.txt -> Module/ProjectB/FileB3.txt" + +# Verify rename +BRANCH="$REPOURL/branches/fix3" +svn copy -q -m "Create branch" $TRUNK $BRANCH +svn switch -q $BRANCH +show_last_commit +echo "Module/ProjectB/FileB3.txt (from Fix 3)" >> $WC/Module/ProjectB/FileB3.txt +svn_commit "Fix 3: Modify Module/ProjectB/FileB3.txt" +svn switch -q $TRUNK +svn merge -q $BRANCH +svn_commit "Fix 3: Modify Module/ProjectB/FileB3.txt" + +# Rename files + folders +# * Test rename support +# * Create complicated find-ancestors case, where files/folders are renamed multiple times on branch +BRANCH="$REPOURL/branches/fix4" +svn copy -q -m "Create branch" $TRUNK $BRANCH +svn switch -q $BRANCH +show_last_commit +svn mv -q Module/ProjectB Module/ProjectC +svn mv -q Module/ProjectC/FileB1.txt Module/ProjectC/FileC1.txt +echo "Module/ProjectC/FileC1.txt" >> $WC/Module/ProjectC/FileC1.txt +svn mv -q Module/ProjectC/FileB2.txt Module/ProjectC/FileC2.txt +echo "Module/ProjectC/FileC2.txt" >> $WC/Module/ProjectC/FileC2.txt +svn mv -q Module/ProjectC/FileB3.txt Module/ProjectC/FileC3.txt +echo "Module/ProjectC/FileC3.txt" >> $WC/Module/ProjectC/FileC3.txt +svn_commit "Fix 4: Rename Module/ProjectB -> Module/ProjectC" +svn switch -q $TRUNK +svn merge -q $BRANCH +svn_commit "Fix 4: Rename Module/ProjectB -> Module/ProjectC" + +# Verify rename +BRANCH="$REPOURL/branches/fix5" +svn copy -q -m "Create branch" $TRUNK $BRANCH +svn switch -q $BRANCH +show_last_commit +echo "Module/ProjectC/FileC1.txt (from Fix 5)" >> $WC/Module/ProjectC/FileC1.txt +echo "Module/ProjectC/FileC2.txt (from Fix 5)" >> $WC/Module/ProjectC/FileC2.txt +echo "Module/ProjectC/FileC3.txt (from Fix 5)" >> $WC/Module/ProjectC/FileC3.txt +svn_commit "Fix 5: Modify Module/ProjectC/FileC*.txt" +svn switch -q $TRUNK +svn merge -q $BRANCH +svn_commit "Fix 5: Modify Module/ProjectC/FileC*.txt" + +# Copy from older revision +svn copy -q -r 8 $TRUNK/Module/ProjectA/FileA2.txt@8 $WC/Module/ProjectA/FileA2.txt +svn_commit "Fix 6: Restore Module/ProjectA/FileA2.txt" + +# Verify copy +BRANCH="$REPOURL/branches/fix7" +svn copy -q -m "Create branch" $TRUNK $BRANCH +svn switch -q $BRANCH +show_last_commit +echo "Module/ProjectA/FileA2.txt (from Fix 7)" >> $WC/Module/ProjectA/FileA2.txt +svn_commit "Fix 7: Modify Module/ProjectA/FileA2.txt" +svn switch -q $TRUNK +svn merge -q $BRANCH +svn_commit "Fix 7: Modify Module/ProjectA/FileA2.txt" + diff --git a/tests/make-replay-repo.sh b/tests/make-replay-repo.sh new file mode 100755 index 0000000..2671b15 --- /dev/null +++ b/tests/make-replay-repo.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Use svn2svn.py to create a filtered repo with only /trunk history + +PWD=$(pwd) +REPO="$PWD/_repo_replay" +REPOURL="file://$REPO" + +# Clean-up +echo "Cleaning-up..." +rm -rf $REPO _dup_wc + +# Init repo +echo "Creating _repo_replay..." +svnadmin create $REPO +svn mkdir -q -m "Add /trunk" $REPOURL/trunk + +# svn2svn +../svn2svn.py -a file://$PWD/_repo_ref/trunk file://$PWD/_repo_replay/trunk -- 2.45.2