3 # Run through some simple usage cases. This both tests that important
4 # features work, and gives an example of suggested usage to get people
7 # usage: test_usage.sh RCS
9 # bzr, git, hg, arch, none
11 # Note that this script uses the *installed* version of be, not the
12 # one in your working tree.
14 set -e # exit immediately on failed command
15 set -o pipefail # pipes fail if any stage fails
16 set -v # verbose, echo commands to stdout
18 exec 6>&2 # save stderr to file descriptor 6
19 exec 2>&1 # fd 2 now writes to stdout
23 echo "usage: test_usage.sh [RCS]"
25 echo "where RCS is one of"
26 for RCS in arch bzr darcs git hg none
33 for RCS in arch bzr darcs git hg none
35 echo -e "\n\nTesting $RCS\n\n"
43 TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
46 if [ "$RCS" == "arch" ]
49 ARCH_PARAM_DIR="$HOME/.arch-params"
50 ARCH_ARCHIVE_ROOT=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
51 UNIQUE=`echo "$ARCH_ARCHIVE_ROOT" | sed 's/\/tmp\/BEtest.//;s/[0-9]//g'`
52 ARCH_ARCHIVE="j@x.com--BE-test-usage-$UNIQUE"
53 ARCH_PROJECT="BE-test-usage--twig--99.5"
54 ARCH_ARCHIVE_DIR="$ARCH_ARCHIVE_ROOT/$ARCH_PROJECT"
55 echo "tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR"
56 tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR
57 echo "tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT"
58 tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT
59 echo "tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT"
60 tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT
61 echo "Adjusing the naming conventions to allow .files"
62 sed -i 's/^source .*/source ^[._=a-zA-X0-9].*$/' '{arch}/=tagging-method'
63 echo "tla import -A $ARCH_ARCHIVE --summary 'Began versioning'"
64 tla import -A $ARCH_ARCHIVE --summary 'Began versioning'
65 elif [ "$RCS" == "bzr" ]
69 elif [ "$RCS" == "darcs" ]
71 if [ -z "$DARCS_EMAIL" ]; then
72 export DARCS_EMAIL="J. Doe <jdoe@example.com>"
76 elif [ "$RCS" == "git" ]
78 NAME=`git-config user.name`
79 EMAIL=`git-config user.email`
82 elif [ "$RCS" == "hg" ]
84 ID=`hg showconfig ui.username`
86 elif [ "$RCS" == "none" ]
90 echo "Unrecognized RCS '$RCS'"
94 then # set a default ID
95 ID="John Doe <jdoe@example.com>"
100 OUT=`be new 'having too much fun'`
102 BUG=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
103 echo "Working with bug: $BUG"
104 be comment $BUG "This is an argument"
105 be set user_id "$ID" # get tired of guessing user id for none RCS
106 be set # show settings
107 be comment $BUG:1 "No it isn't" # comment on the first comment
108 be show $BUG # show details on a given bug
109 be close $BUG # set bug status to 'closed'
110 be comment $BUG "It's closed, but I can still comment."
111 be open $BUG # set bug status to 'open'
112 be comment $BUG "Reopend, comment again"
113 be status $BUG fixed # set bug status to 'fixed'
114 be list # list all open bugs
115 be list --status fixed # list all fixed bugs
116 be assign $BUG # assign the bug to yourself
117 be list -m -s fixed # see fixed bugs assigned to you
118 be assign $BUG 'Joe' # assign the bug to Joe
119 be list -a Joe -s fixed # list the fixed bugs assigned to Joe
120 be assign $BUG none # assign the bug to noone
121 be diff # see what has changed
122 OUT=`be new 'also having too much fun'`
123 BUGB=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
124 be comment $BUGB "Blissfully unaware of a similar bug"
125 be merge $BUG $BUGB # join BUGB to BUG
126 be show $BUG # show bug details & comments
127 be remove $BUG # decide that you don't like that bug after all
131 if [ "$RCS" == "arch" ]
133 # Cleanup everything outside of TESTDIR
134 rm -rf "$ARCH_ARCHIVE_ROOT"
135 rm -rf "$ARCH_PARAM_DIR/=locations/$ARCH_ARCHIVE"
138 exec 2>&6 6>&- # restore stderr and close fd 6