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
21 ONLY_TEST_COMMIT="true"
25 echo "usage: test_usage.sh [RCS]"
27 echo "where RCS is one of"
28 for RCS in arch bzr darcs git hg none
35 for RCS in arch bzr darcs git hg none
37 echo -e "\n\nTesting $RCS\n\n"
45 TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
48 if [ "$RCS" == "arch" ]
51 ARCH_PARAM_DIR="$HOME/.arch-params"
52 ARCH_ARCHIVE_ROOT=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
53 UNIQUE=`echo "$ARCH_ARCHIVE_ROOT" | sed 's/\/tmp\/BEtest.//;s/[0-9]//g'`
54 ARCH_ARCHIVE="j@x.com--BE-test-usage-$UNIQUE"
55 ARCH_PROJECT="BE-test-usage--twig--99.5"
56 ARCH_ARCHIVE_DIR="$ARCH_ARCHIVE_ROOT/$ARCH_PROJECT"
57 echo "tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR"
58 tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR
59 echo "tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT"
60 tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT
61 echo "tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT"
62 tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT
63 echo "Adjusing the naming conventions to allow .files"
64 sed -i 's/^source .*/source ^[._=a-zA-X0-9].*$/' '{arch}/=tagging-method'
65 echo "tla import -A $ARCH_ARCHIVE --summary 'Began versioning'"
66 tla import -A $ARCH_ARCHIVE --summary 'Began versioning'
67 elif [ "$RCS" == "bzr" ]
71 elif [ "$RCS" == "darcs" ]
73 if [ -z "$DARCS_EMAIL" ]; then
74 export DARCS_EMAIL="J. Doe <jdoe@example.com>"
78 elif [ "$RCS" == "git" ]
80 NAME=`git config user.name`
81 EMAIL=`git config user.email`
84 elif [ "$RCS" == "hg" ]
86 ID=`hg showconfig ui.username`
88 elif [ "$RCS" == "none" ]
92 echo "Unrecognized RCS '$RCS'"
96 then # set a default ID
97 ID="John Doe <jdoe@example.com>"
102 OUT=`be new 'having too much fun'`
104 BUG=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
105 echo "Working with bug: $BUG"
106 be comment $BUG "This is an argument"
107 be set user_id "$ID" # get tired of guessing user id for none RCS
108 be set # show settings
109 be comment $BUG:1 "No it isn't" # comment on the first comment
110 be show $BUG # show details on a given bug
111 be close $BUG # set bug status to 'closed'
112 be comment $BUG "It's closed, but I can still comment."
113 be open $BUG # set bug status to 'open'
114 be comment $BUG "Reopend, comment again"
115 be status $BUG fixed # set bug status to 'fixed'
116 be list # list all open bugs
117 be list --status fixed # list all fixed bugs
118 be assign $BUG # assign the bug to yourself
119 be list -m -s fixed # see fixed bugs assigned to you
120 be assign $BUG 'Joe' # assign the bug to Joe
121 be list -a Joe -s fixed # list the fixed bugs assigned to Joe
122 be assign $BUG none # assign the bug to noone
123 be diff # see what has changed
124 OUT=`be new 'also having too much fun'`
125 BUGB=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
126 be comment $BUGB "Blissfully unaware of a similar bug"
127 be merge $BUG $BUGB # join BUGB to BUG
128 be show $BUG # show bug details & comments
129 # you can also export/import XML bugs/comments
130 OUT=`be new 'yet more fun'`
131 BUGC=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
132 be comment $BUGC "The ants go marching..."
133 be show --xml $BUGC | be comment --xml ${BUG}:2 -
134 be remove $BUG # decide that you don't like that bug after all
135 be commit "You can even commit using BE"
136 be commit --allow-empty "And you can add empty commits if you like"
137 be commit "But this will fail" || echo "Failed"
142 if [ "$RCS" == "arch" ]
144 # Cleanup everything outside of TESTDIR
145 rm -rf "$ARCH_ARCHIVE_ROOT"
146 rm -rf "$ARCH_PARAM_DIR/=locations/$ARCH_ARCHIVE"
149 exec 2>&6 6>&- # restore stderr and close fd 6