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 bzr git hg arch none
33 for RCS in bzr git hg arch none
35 echo -e "\n\nTesting $RCS\n\n"
43 TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
46 if [ "$RCS" == "bzr" ]
50 elif [ "$RCS" == "git" ]
52 NAME=`git-config user.name`
53 EMAIL=`git-config user.email`
56 elif [ "$RCS" == "hg" ]
58 ID=`hg showconfig ui.username`
60 elif [ "$RCS" == "arch" ]
63 ARCH_PARAM_DIR="$HOME/.arch-params"
64 ARCH_ARCHIVE_ROOT=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
65 UNIQUE=`echo "$ARCH_ARCHIVE_ROOT" | sed 's/\/tmp\/BEtest.//;s/[0-9]//g'`
66 ARCH_ARCHIVE="j@x.com--BE-test-usage-$UNIQUE"
67 ARCH_PROJECT="BE-test-usage--twig--99.5"
68 ARCH_ARCHIVE_DIR="$ARCH_ARCHIVE_ROOT/$ARCH_PROJECT"
69 echo "tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR"
70 tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR
71 echo "tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT"
72 tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT
73 echo "tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT"
74 tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT
75 echo "Adjusing the naming conventions to allow .files"
76 sed -i 's/^source .*/source ^[._=a-zA-X0-9].*$/' '{arch}/=tagging-method'
77 echo "tla import -A $ARCH_ARCHIVE --summary 'Began versioning'"
78 tla import -A $ARCH_ARCHIVE --summary 'Began versioning'
79 elif [ "$RCS" == "none" ]
83 echo "Unrecognized RCS '$RCS'"
87 then # set a default ID
88 ID="John Doe <jdoe@example.com>"
93 OUT=`be new 'having too much fun'`
95 BUG=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
96 echo "Working with bug: $BUG"
97 be comment $BUG "This is an argument"
98 be set user_id "$ID" # get tired of guessing user id for none RCS
99 be set # show settings
100 be comment $BUG:1 "No it isn't" # comment on the first comment
101 be show $BUG # show details on a given bug
102 be close $BUG # set bug status to 'closed'
103 be comment $BUG "It's closed, but I can still comment."
104 be open $BUG # set bug status to 'open'
105 be comment $BUG "Reopend, comment again"
106 be status $BUG fixed # set bug status to 'fixed'
107 be list # list all open bugs
108 be list --status fixed # list all fixed bugs
109 be assign $BUG # assign the bug to yourself
110 be list -m -s fixed # see fixed bugs assigned to you
111 be assign $BUG 'Joe' # assign the bug to Joe
112 be list -a Joe -s fixed # list the fixed bugs assigned to Joe
113 be assign $BUG none # assign the bug to noone
114 be diff # see what has changed
115 OUT=`be new 'also having too much fun'`
116 BUGB=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
117 be comment $BUGB "Blissfully unaware of a similar bug"
118 be merge $BUG $BUGB # join BUGB to BUG
119 be show $BUG # show bug details & comments
120 be remove $BUG # decide that you don't like that bug after all
124 if [ "$RCS" == "arch" ]
126 # Cleanup everything outside of TESTDIR
127 rm -rf "$ARCH_ARCHIVE_ROOT"
128 rm -rf "$ARCH_PARAM_DIR/=locations/$ARCH_ARCHIVE"
131 exec 2>&6 6>&- # restore stderr and close fd 6