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 VCS
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 [VCS]"
25 echo "where VCS is one of"
26 for VCS in arch bzr darcs git hg none
33 for VCS in arch bzr darcs git hg none
35 echo -e "\n\nTesting $VCS\n\n"
43 TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
46 # Initialize the VCS repository
47 if [ "$VCS" == "arch" ]
50 ARCH_PARAM_DIR="$HOME/.arch-params"
51 ARCH_ARCHIVE_ROOT=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
52 UNIQUE=`echo "$ARCH_ARCHIVE_ROOT" | sed 's/\/tmp\/BEtest.//;s/[0-9]//g'`
53 ARCH_ARCHIVE="j@x.com--BE-test-usage-$UNIQUE"
54 ARCH_PROJECT="BE-test-usage--twig--99.5"
55 ARCH_ARCHIVE_DIR="$ARCH_ARCHIVE_ROOT/$ARCH_PROJECT"
56 echo "tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR"
57 tla make-archive $ARCH_ARCHIVE $ARCH_ARCHIVE_DIR
58 echo "tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT"
59 tla archive-setup -A $ARCH_ARCHIVE $ARCH_PROJECT
60 echo "tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT"
61 tla init-tree -A $ARCH_ARCHIVE $ARCH_PROJECT
62 echo "Adjusing the naming conventions to allow .files"
63 sed -i 's/^source .*/source ^[._=a-zA-X0-9].*$/' '{arch}/=tagging-method'
64 echo "tla import -A $ARCH_ARCHIVE --summary 'Began versioning'"
65 tla import -A $ARCH_ARCHIVE --summary 'Began versioning'
66 elif [ "$VCS" == "bzr" ]
70 elif [ "$VCS" == "darcs" ]
72 if [ -z "$DARCS_EMAIL" ]; then
73 export DARCS_EMAIL="J. Doe <jdoe@example.com>"
77 elif [ "$VCS" == "git" ]
79 NAME=`git config user.name`
80 EMAIL=`git config user.email`
83 elif [ "$VCS" == "hg" ]
85 ID=`hg showconfig ui.username`
87 elif [ "$VCS" == "none" ]
91 echo "Unrecognized VCS '$VCS'"
96 then # set a default ID for VCSs that aren't tracking one yet.
97 ID="John Doe <jdoe@example.com>"
101 be init # initialize the Bugs Everywhere repository
102 OUT=`be new 'having too much fun'` # create a new bug
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 VCS
108 be set # show settings
109 be comment $BUG/ "No it isn't" # comment on the first comment
110 be show $BUG # show details on a given bug
111 be status closed $BUG # set bug status to 'closed'
112 be comment $BUG "It's closed, but I can still comment."
113 if [ "$VCS" != 'none' ]; then
114 be commit 'Initial commit'
116 be status open $BUG # set bug status to 'open'
117 be comment $BUG "Reopend, comment again"
118 be status fixed $BUG # set bug status to 'fixed'
119 be list # list all open bugs
120 be list --status fixed # list all fixed bugs
121 be assign - $BUG # assign the bug to yourself
122 be list -m --status fixed # see fixed bugs assigned to you
123 be assign 'Joe' $BUG # assign the bug to Joe
124 be list -a Joe --status fixed # list the fixed bugs assigned to Joe
125 be assign none $BUG # un-assign the bug
126 if [ "$VCS" != 'none' ]; then
127 be diff # see what has changed
129 OUT=`be new 'also having too much fun'`
130 BUGB=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
131 be comment $BUGB "Blissfully unaware of a similar bug"
132 be merge $BUG $BUGB # join BUGB to BUG
133 be --no-pager show $BUG # show bug details & comments
134 # you can also export/import XML bugs/comments
135 OUT=`be new 'yet more fun'`
136 BUGC=`echo "$OUT" | sed -n 's/Created bug with ID //p'`
137 be comment $BUGC "The ants go marching..."
138 be show --xml $BUGC/ | be import-xml --add-only --root $BUG -
139 be remove $BUG # decide that you don't like that bug after all
140 be commit "You can even commit using BE"
141 be commit --allow-empty "And you can add empty commits if you like"
142 be commit "But this will fail" || echo "Failed"
147 if [ "$VCS" == "arch" ]
149 # Cleanup everything outside of TESTDIR
150 rm -rf "$ARCH_ARCHIVE_ROOT"
151 rm -rf "$ARCH_PARAM_DIR/=locations/$ARCH_ARCHIVE"
154 exec 2>&6 6>&- # restore stderr and close fd 6