From 4bc4079e6d1495f47398a6b685f45fe40e304a0c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 16 Nov 2008 14:47:16 -0500 Subject: Added ./test_usage.sh as an example usage scenario. It is also a good integration test. --- test_usage.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 test_usage.sh (limited to 'test_usage.sh') diff --git a/test_usage.sh b/test_usage.sh new file mode 100755 index 0000000..e214e75 --- /dev/null +++ b/test_usage.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Run through some simple usage cases. This both tests that important +# features work, and gives an example of suggested usage to get people +# started. +# +# usage: test_usage.sh + +set -e # exit imediately on failed command +set -o pipefail # pipes fail if any stage fails +set -v # verbose, echo commands to stdout + +exec 6>&2 # save stderr to file descriptor 6 +exec 2>&1 # fd 2 now writes to stdout + +ID=`bzr whoami` +echo "I am: $ID" + +TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX` +cd $TESTDIR +bzr init +be set-root . +OUT=`be new 'having too much fun'` +echo "$OUT" +BUG=`echo "$OUT" | sed -n 's/Created bug with ID //p'` +echo "Working with bug: $BUG" +be comment $BUG "This is an argument" +be comment $BUG:1 "No it isn't" # comment on the first comment +be show $BUG # show details on a given bug +be close $BUG # set bug status to 'closed' +be comment $BUG "It's closed, but I can still comment." +be open $BUG # set bug status to 'open' +be comment $BUG "Reopend, comment again" +be status $BUG fixed # set bug status to 'fixed' +be show $BUG # show bug details & comments +be list # list all open bugs +be list --status closed # list all closed bugs +be assign $BUG # assign the bug to yourself +be list -m # see bugs assigned to you +be assign $BUG 'Joe' # assign the bug to Joe +be list --assigned Joe # list the bugs assigned to Joe +be assign $BUG none # assign the bug to noone +be remove $BUG # decide that you don't like that bug after all +cd / +rm -rf $TESTDIR + +exec 2>&6 6>&- # restore stderr and close fd 6 -- cgit From 2b071a28a2cedab54c713948c6b6f4bd27bb45e2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 16 Nov 2008 15:37:14 -0500 Subject: Fixed another bug in git.strip_git() (bug 0cad). Also added git mode to test_usage.sh. I'll go through and add modes for the other RCSs... --- test_usage.sh | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'test_usage.sh') diff --git a/test_usage.sh b/test_usage.sh index e214e75..c751d28 100755 --- a/test_usage.sh +++ b/test_usage.sh @@ -4,7 +4,10 @@ # features work, and gives an example of suggested usage to get people # started. # -# usage: test_usage.sh +# usage: test_usage.sh RCS +# where RCS is one of: +# bzr +# git set -e # exit imediately on failed command set -o pipefail # pipes fail if any stage fails @@ -13,12 +16,39 @@ set -v # verbose, echo commands to stdout exec 6>&2 # save stderr to file descriptor 6 exec 2>&1 # fd 2 now writes to stdout -ID=`bzr whoami` -echo "I am: $ID" +if [ $# -ne 1 ] +then + echo "usage: test_usage.sh RCS" + echo "" + echo "where RCS is one of" + for RCS in bzr git + do + echo " $RCS" + done + exit 1 +fi + +RCS="$1" TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX` cd $TESTDIR -bzr init + +if [ "$RCS" == "bzr" ] +then + ID=`bzr whoami` + bzr init +elif [ "$RCS" == "git" ] +then + NAME=`git-config user.name` + EMAIL=`git-config user.email` + ID="$NAME <$EMAIL>" + git init +else + echo "Unrecognized RCS $RCS" + exit 1 +fi +echo "I am '$ID'" + be set-root . OUT=`be new 'having too much fun'` echo "$OUT" @@ -34,11 +64,11 @@ be comment $BUG "Reopend, comment again" be status $BUG fixed # set bug status to 'fixed' be show $BUG # show bug details & comments be list # list all open bugs -be list --status closed # list all closed bugs +be list --status fixed # list all fixed bugs be assign $BUG # assign the bug to yourself -be list -m # see bugs assigned to you +be list -m -s fixed # see fixed bugs assigned to you be assign $BUG 'Joe' # assign the bug to Joe -be list --assigned Joe # list the bugs assigned to Joe +be list -a Joe -s fixed # list the fixed bugs assigned to Joe be assign $BUG none # assign the bug to noone be remove $BUG # decide that you don't like that bug after all cd / -- cgit From e4018dfe8cfa553adbd20898c5b42c3462ca1733 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 16 Nov 2008 15:59:41 -0500 Subject: Added 'hg', 'arch', and 'none' RCS modes to test_usage.sh. --- test_usage.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'test_usage.sh') diff --git a/test_usage.sh b/test_usage.sh index c751d28..26acce1 100755 --- a/test_usage.sh +++ b/test_usage.sh @@ -6,8 +6,7 @@ # # usage: test_usage.sh RCS # where RCS is one of: -# bzr -# git +# bzr, git, hg, arch, none set -e # exit imediately on failed command set -o pipefail # pipes fail if any stage fails @@ -21,7 +20,7 @@ then echo "usage: test_usage.sh RCS" echo "" echo "where RCS is one of" - for RCS in bzr git + for RCS in bzr git hg arch none do echo " $RCS" done @@ -43,10 +42,25 @@ then EMAIL=`git-config user.email` ID="$NAME <$EMAIL>" git init +elif [ "$RCS" == "hg" ] +then + ID=`hg showconfig ui.username` + hg init +elif [ "$RCS" == "arch" ] +then + ID=`tla my-id` + tla init-tree +elif [ "$RCS" == "none" ] +then + ID=`id -nu` else echo "Unrecognized RCS $RCS" exit 1 fi +if [ -z "$ID" ] +then # set a default ID + ID="John Doe " +fi echo "I am '$ID'" be set-root . -- cgit From 19b153b9a86377a2b30cc80fa3f475fed892e2fe Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 18 Nov 2008 20:42:50 -0500 Subject: Major rewrite of RCS backends. RCS now represented as a class. Lots of changes and just one commit. This started with bug dac91856-cb6a-4f69-8c03-38ff0b29aab2, when I noticed that new bugs were not being added appropriately with the Git backend. I'd been working with Git trouble before with bug 0cad2ac6-76ef-4a88-abdf-b2e02de76f5c, and decided things would be better off if I just scrapped the current RCS architecture and went to a more object oriented setup. So I did. It's not clear how to add support for an RCS backend: * Create a new module that - defines an inheritor of rsc.RCS, overriding the _rcs_*() methods - provide a new() function for instantizating the new class - defines an inheritor of rcs.RCStestCase, overiding the Class attribute - defines 'suite' a unittest.TestSuite testing the module * Add your new module to the rest in rcs._get_matching_rcs() * Add your new module to the rest in libbe/tests.py Although I'm not sure libbe/tests.py is still usefull. The new framework clears out a bunch of hackery that used to be involved with supporting becommands/diff.py. There's still room for progress though. While implementing the new verision, I moved the testing framework over from doctest to a doctest/unittest combination. Longer tests that don't demonstrate a function's usage should be moved to unittests at the end of the module, since unittest has better support for setup/teardown, etc. The new framework also revealed some underimplented backends, most notably arch. These backends have now been fixed. I also tweaked the test_usage.sh script to run through all the backends if it is called with no arguments. The fix for the dac bug turned out to be an unflushed file write :p. --- test_usage.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'test_usage.sh') diff --git a/test_usage.sh b/test_usage.sh index 26acce1..bba21ee 100755 --- a/test_usage.sh +++ b/test_usage.sh @@ -7,6 +7,9 @@ # usage: test_usage.sh RCS # where RCS is one of: # bzr, git, hg, arch, none +# +# Note that this script uses the *installed* version of be, not the +# one in your working tree. set -e # exit imediately on failed command set -o pipefail # pipes fail if any stage fails @@ -15,9 +18,9 @@ set -v # verbose, echo commands to stdout exec 6>&2 # save stderr to file descriptor 6 exec 2>&1 # fd 2 now writes to stdout -if [ $# -ne 1 ] +if [ $# -gt 1 ] then - echo "usage: test_usage.sh RCS" + echo "usage: test_usage.sh [RCS]" echo "" echo "where RCS is one of" for RCS in bzr git hg arch none @@ -25,6 +28,14 @@ then echo " $RCS" done exit 1 +elif [ $# -eq 0 ] +then + for RCS in bzr git hg arch none + do + echo -e "\n\nTesting $RCS\n\n" + $0 "$RCS" || exit 1 + done + exit 0 fi RCS="$1" @@ -54,7 +65,7 @@ elif [ "$RCS" == "none" ] then ID=`id -nu` else - echo "Unrecognized RCS $RCS" + echo "Unrecognized RCS '$RCS'" exit 1 fi if [ -z "$ID" ] @@ -84,6 +95,7 @@ be list -m -s fixed # see fixed bugs assigned to you be assign $BUG 'Joe' # assign the bug to Joe be list -a Joe -s fixed # list the fixed bugs assigned to Joe be assign $BUG none # assign the bug to noone +be diff # see what has changed be remove $BUG # decide that you don't like that bug after all cd / rm -rf $TESTDIR -- cgit From 9e0a846ff4fdaac45665e5a1e085aa37e3fa135b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 23 Nov 2008 06:51:30 -0500 Subject: Added archive/project init code for `./test_usage.sh arch`. Also some minor cleanups. --- test_usage.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'test_usage.sh') diff --git a/test_usage.sh b/test_usage.sh index bba21ee..11be0d5 100755 --- a/test_usage.sh +++ b/test_usage.sh @@ -60,7 +60,22 @@ then elif [ "$RCS" == "arch" ] then ID=`tla my-id` - tla init-tree + ARCH_PARAM_DIR="$HOME/.arch-params" + ARCH_ARCHIVE_ROOT=`mktemp -d /tmp/BEtest.XXXXXXXXXX` + UNIQUE=`echo "$ARCH_ARCHIVE_ROOT" | sed 's/\/tmp\/BEtest.//;s/[0-9]//g'` + ARCH_ARCHIVE="j@x.com--BE-test-usage-$UNIQUE" + ARCH_PROJECT="BE-test-usage--twig--99.5" + ARCH_ARCHIVE_DIR="$ARCH_ARCHIVE_ROOT/$ARCH_PROJECT" + echo "tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR" + tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR + echo "tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT" + tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT + echo "tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT" + tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT + echo "Adjusing the naming conventions to allow .files" + sed -i 's/^source .*/source ^[._=a-zA-X0-9].*$/' '{arch}/=tagging-method' + echo "tla import -A $ARCH_ARCHIVE --summary 'Began versioning'" + tla import -A $ARCH_ARCHIVE --summary 'Began versioning' elif [ "$RCS" == "none" ] then ID=`id -nu` @@ -100,4 +115,11 @@ be remove $BUG # decide that you don't like that bug after all cd / rm -rf $TESTDIR +if [ "$RCS" == "arch" ] +then + # Cleanup everything outside of TESTDIR + rm -rf "$ARCH_ARCHIVE_ROOT" + rm -rf "$ARCH_PARAM_DIR/=locations/$ARCH_ARCHIVE" +fi + exec 2>&6 6>&- # restore stderr and close fd 6 -- cgit From 116c356bdb9b8e6d32af2419dda1d423b238efe1 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 24 Nov 2008 08:11:08 -0500 Subject: Removed auto-wrapping from comment.Comment.string(). It makes tracebacks almost illegible. I doubt markup/markdown systax or auto-formatting is really useful, since bugs-reports are ususally a short comment and a traceback. I also closed a4d38ba7-ec28-4096-a4f3-eb8c9790ffb2 and 7bfc591e-584a-476e-8e11-b548f1afcaa6, which have probably been fixed for a long time... --- test_usage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test_usage.sh') diff --git a/test_usage.sh b/test_usage.sh index 11be0d5..43b5d4d 100755 --- a/test_usage.sh +++ b/test_usage.sh @@ -89,7 +89,7 @@ then # set a default ID fi echo "I am '$ID'" -be set-root . +be set-root OUT=`be new 'having too much fun'` echo "$OUT" BUG=`echo "$OUT" | sed -n 's/Created bug with ID //p'` -- cgit