Added becommands/tag.py
[be.git] / test_usage.sh
1 #!/bin/bash
2 #
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
5 # started.
6 #
7 # usage: test_usage.sh RCS
8 # where RCS is one of:
9 #   bzr, git, hg, arch, none
10 #
11 # Note that this script uses the *installed* version of be, not the
12 # one in your working tree.
13
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
17
18 exec 6>&2 # save stderr to file descriptor 6
19 exec 2>&1 # fd 2 now writes to stdout
20
21 if [ $# -gt 1 ]
22 then
23     echo "usage: test_usage.sh [RCS]"
24     echo ""
25     echo "where RCS is one of"
26     for RCS in bzr git hg arch none
27     do
28         echo "  $RCS"
29     done
30     exit 1
31 elif [ $# -eq 0 ]
32 then
33     for RCS in bzr git hg arch none
34     do
35         echo -e "\n\nTesting $RCS\n\n"
36         $0 "$RCS" || exit 1
37     done
38     exit 0
39 fi
40
41 RCS="$1"
42
43 TESTDIR=`mktemp -d /tmp/BEtest.XXXXXXXXXX`
44 cd $TESTDIR
45
46 if [ "$RCS" == "bzr" ]
47 then
48     ID=`bzr whoami`
49     bzr init
50 elif [ "$RCS" == "git" ]
51 then
52     NAME=`git-config user.name`
53     EMAIL=`git-config user.email`
54     ID="$NAME <$EMAIL>"
55     git init
56 elif [ "$RCS" == "hg" ]
57 then
58     ID=`hg showconfig ui.username`
59     hg init
60 elif [ "$RCS" == "arch" ]
61 then
62     ID=`tla my-id`
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" ]
80 then
81     ID=`id -nu`
82 else
83     echo "Unrecognized RCS '$RCS'"
84     exit 1
85 fi
86 if [ -z "$ID" ]
87 then # set a default ID
88     ID="John Doe <jdoe@example.com>"
89 fi
90 echo "I am '$ID'"
91
92 be set-root
93 OUT=`be new 'having too much fun'`
94 echo "$OUT"
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
121 cd /
122 rm -rf $TESTDIR
123
124 if [ "$RCS" == "arch" ]
125 then
126     # Cleanup everything outside of TESTDIR
127     rm -rf "$ARCH_ARCHIVE_ROOT"
128     rm -rf "$ARCH_PARAM_DIR/=locations/$ARCH_ARCHIVE"
129 fi
130
131 exec 2>&6 6>&- # restore stderr and close fd 6