| 1 | #!/bin/sh |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2008 Walter Franzini |
|---|
| 4 | # |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | here=`pwd` |
|---|
| 8 | |
|---|
| 9 | # |
|---|
| 10 | # Add the development dir to the PATH |
|---|
| 11 | # |
|---|
| 12 | PATH=$here:$PATH |
|---|
| 13 | export PATH |
|---|
| 14 | |
|---|
| 15 | pass() |
|---|
| 16 | { |
|---|
| 17 | echo "PASSED:" |
|---|
| 18 | exit 0 |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | fail() |
|---|
| 22 | { |
|---|
| 23 | echo "FAILED: $activity" |
|---|
| 24 | exit 1 |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | no_result() |
|---|
| 28 | { |
|---|
| 29 | echo "NO_RESULT: $activity" |
|---|
| 30 | exit 2 |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | work=${TMPDIR-/tmp}/TAILOR.$$ |
|---|
| 34 | mkdir $work |
|---|
| 35 | if test $? -ne 0; then no_result; fi |
|---|
| 36 | |
|---|
| 37 | cd $work |
|---|
| 38 | |
|---|
| 39 | activity="darcs setup" |
|---|
| 40 | mkdir $work/darcs-repo > log 2>&1 |
|---|
| 41 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 42 | |
|---|
| 43 | darcs initialize --repodir=$work/darcs-repo > log 2>&1 |
|---|
| 44 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 45 | |
|---|
| 46 | activity="create foo" |
|---|
| 47 | mkdir $work/darcs-repo/dir |
|---|
| 48 | if test $? -ne 0; then no_result; fi |
|---|
| 49 | |
|---|
| 50 | cat > $work/darcs-repo/dir/foo.txt <<EOF |
|---|
| 51 | A simple text file |
|---|
| 52 | EOF |
|---|
| 53 | if test $? -ne 0; then no_result; fi |
|---|
| 54 | |
|---|
| 55 | darcs add dir/foo.txt --repodir=$work/darcs-repo > log 2>&1 |
|---|
| 56 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 57 | |
|---|
| 58 | darcs record --repodir=$work/darcs-repo -a -A Nobody -m "initial commit" \ |
|---|
| 59 | > log 2>&1 |
|---|
| 60 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 61 | |
|---|
| 62 | cat > $work/darcs-repo/dir/foo.txt <<EOF |
|---|
| 63 | A simple text file |
|---|
| 64 | wit some more text. |
|---|
| 65 | EOF |
|---|
| 66 | if test $? -ne 0; then no_result; fi |
|---|
| 67 | |
|---|
| 68 | cat > $work/darcs-repo/bar.txt <<EOF |
|---|
| 69 | This is bar.txt |
|---|
| 70 | EOF |
|---|
| 71 | if test $? -ne 0; then no_result; fi |
|---|
| 72 | |
|---|
| 73 | darcs add bar.txt --repodir=$work/darcs-repo > log 2>&1 |
|---|
| 74 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 75 | |
|---|
| 76 | darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \ |
|---|
| 77 | -m "second commit" > log 2>&1 |
|---|
| 78 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 79 | |
|---|
| 80 | cat > $work/darcs-repo/dir/foo.txt <<EOF |
|---|
| 81 | A simple text file |
|---|
| 82 | wit some more text. |
|---|
| 83 | more text again! |
|---|
| 84 | EOF |
|---|
| 85 | if test $? -ne 0; then no_result; fi |
|---|
| 86 | |
|---|
| 87 | darcs mv bar.txt baz.txt --repodir=$work/darcs-repo > log 2>&1 |
|---|
| 88 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 89 | |
|---|
| 90 | darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \ |
|---|
| 91 | -m "third commit" > log 2>&1 |
|---|
| 92 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 93 | |
|---|
| 94 | # |
|---|
| 95 | # Initialize the aegis repository |
|---|
| 96 | # |
|---|
| 97 | |
|---|
| 98 | unset AEGIS_PROJECT |
|---|
| 99 | unset AEGIS_CHANGE |
|---|
| 100 | unset AEGIS_PATH |
|---|
| 101 | unset AEGIS |
|---|
| 102 | umask 022 |
|---|
| 103 | |
|---|
| 104 | LINES=24 |
|---|
| 105 | export LINES |
|---|
| 106 | COLS=80 |
|---|
| 107 | export COLS |
|---|
| 108 | |
|---|
| 109 | USER=${USER:-${LOGNAME:-`whoami`}} |
|---|
| 110 | |
|---|
| 111 | PAGER=cat |
|---|
| 112 | export PAGER |
|---|
| 113 | AEGIS_THROTTLE=-1 |
|---|
| 114 | export AEGIS_THROTTLE |
|---|
| 115 | |
|---|
| 116 | # This tells aeintegratq that it is being used by a test. |
|---|
| 117 | AEGIS_TEST_DIR=$work |
|---|
| 118 | export AEGIS_TEST_DIR |
|---|
| 119 | |
|---|
| 120 | if test $? -ne 0; then exit 2; fi |
|---|
| 121 | |
|---|
| 122 | AEGIS_DATADIR=$here/lib |
|---|
| 123 | export AEGIS_DATADIR |
|---|
| 124 | |
|---|
| 125 | AEGIS_MESSAGE_LIBRARY=$work/no-such-dir |
|---|
| 126 | export AEGIS_MESSAGE_LIBRARY |
|---|
| 127 | unset LANG |
|---|
| 128 | unset LANGUAGE |
|---|
| 129 | unset LC_ALL |
|---|
| 130 | |
|---|
| 131 | AEGIS_PROJECT=example |
|---|
| 132 | export AEGIS_PROJECT |
|---|
| 133 | AEGIS_PATH=$work/lib |
|---|
| 134 | export AEGIS_PATH |
|---|
| 135 | |
|---|
| 136 | mkdir $AEGIS_PATH |
|---|
| 137 | |
|---|
| 138 | chmod 777 $AEGIS_PATH |
|---|
| 139 | if test $? -ne 0; then no_result; cat log; fi |
|---|
| 140 | |
|---|
| 141 | workproj=$work/foo.proj |
|---|
| 142 | workchan=$work/foo.chan |
|---|
| 143 | |
|---|
| 144 | activity="new project" |
|---|
| 145 | aegis -npr $AEGIS_PROJECT -version "" -lib $AEGIS_PATH \ |
|---|
| 146 | -dir $workproj/ > log 2>&1 |
|---|
| 147 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 148 | |
|---|
| 149 | activity="project_acttributes" |
|---|
| 150 | cat > $work/pa <<EOF |
|---|
| 151 | description = "A bogus project created to test tailor functionality."; |
|---|
| 152 | developer_may_review = true; |
|---|
| 153 | developer_may_integrate = true; |
|---|
| 154 | reviewer_may_integrate = true; |
|---|
| 155 | default_test_exemption = true; |
|---|
| 156 | develop_end_action = goto_awaiting_integration; |
|---|
| 157 | EOF |
|---|
| 158 | if test $? -ne 0 ; then no_result; fi |
|---|
| 159 | |
|---|
| 160 | aegis -pa -f $work/pa > log 2>&1 |
|---|
| 161 | if test $? -ne 0 ; then cat log; no_result; fi |
|---|
| 162 | |
|---|
| 163 | # |
|---|
| 164 | # add the staff |
|---|
| 165 | # |
|---|
| 166 | activity="staff 62" |
|---|
| 167 | aegis -nd $USER > log 2>&1 |
|---|
| 168 | if test $? -ne 0 ; then cat log; no_result; fi |
|---|
| 169 | aegis -nrv $USER > log 2>&1 |
|---|
| 170 | if test $? -ne 0 ; then cat log; no_result; fi |
|---|
| 171 | aegis -ni $USER > log 2>&1 |
|---|
| 172 | if test $? -ne 0 ; then cat log; no_result; fi |
|---|
| 173 | |
|---|
| 174 | # |
|---|
| 175 | # tailor config |
|---|
| 176 | # |
|---|
| 177 | cat > $work/tailor.conf <<EOF |
|---|
| 178 | [DEFAULT] |
|---|
| 179 | verbose = True |
|---|
| 180 | Debug = True |
|---|
| 181 | |
|---|
| 182 | [project] |
|---|
| 183 | patch-name-format = %(revision)s |
|---|
| 184 | root-directory = $PWD/rootdir |
|---|
| 185 | source = darcs:source |
|---|
| 186 | target = aegis:target |
|---|
| 187 | |
|---|
| 188 | [darcs:source] |
|---|
| 189 | repository = $work/darcs-repo |
|---|
| 190 | #module = project |
|---|
| 191 | subdir = darcs1side |
|---|
| 192 | |
|---|
| 193 | [aegis:target] |
|---|
| 194 | module = $AEGIS_PROJECT |
|---|
| 195 | subdir = aegisside |
|---|
| 196 | EOF |
|---|
| 197 | if test $? -ne 0; then no_result; fi |
|---|
| 198 | |
|---|
| 199 | activity="run tailor" |
|---|
| 200 | python $here/tailor -c $work/tailor.conf > tailor.log 2>&1 |
|---|
| 201 | if test $? -ne 0; then cat tailor.log; fail; fi |
|---|
| 202 | |
|---|
| 203 | cat > $work/ok <<EOF |
|---|
| 204 | 1 10 initial commit |
|---|
| 205 | 2 11 second commit |
|---|
| 206 | 3 12 third commit |
|---|
| 207 | EOF |
|---|
| 208 | if test $? -ne 0; then no_result; fi |
|---|
| 209 | |
|---|
| 210 | activity="check aegis project history" |
|---|
| 211 | aegis -list project_history -unformatted 2> log | cut -d\ -f 1,7- > history |
|---|
| 212 | if test $? -ne 0; then cat history; no_result; fi |
|---|
| 213 | |
|---|
| 214 | diff ok history |
|---|
| 215 | if test $? -ne 0; then fail; fi |
|---|
| 216 | |
|---|
| 217 | # |
|---|
| 218 | # add more darcs changes |
|---|
| 219 | # |
|---|
| 220 | cat > $work/darcs-repo/bar.txt <<EOF |
|---|
| 221 | A simple text file |
|---|
| 222 | wit some more text. |
|---|
| 223 | more text again! |
|---|
| 224 | ancora piu\` test |
|---|
| 225 | EOF |
|---|
| 226 | if test $? -ne 0; then no_result; fi |
|---|
| 227 | |
|---|
| 228 | darcs remove dir/foo.txt --repodir=$work/darcs-repo > log 2>&1 |
|---|
| 229 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 230 | |
|---|
| 231 | cat > $work/logfile <<EOF |
|---|
| 232 | fourth commit |
|---|
| 233 | This text is now |
|---|
| 234 | the description of the aegis change |
|---|
| 235 | splitted on multiple lines. |
|---|
| 236 | EOF |
|---|
| 237 | if test $? -ne 0; then no_result; fi |
|---|
| 238 | |
|---|
| 239 | darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \ |
|---|
| 240 | --logfile $work/logfile > log 2>&1 |
|---|
| 241 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 242 | |
|---|
| 243 | activity="run tailor again" |
|---|
| 244 | python $here/tailor -c $work/tailor.conf > log 2>&1 |
|---|
| 245 | if test $? -ne 0; then cat log; fail; fi |
|---|
| 246 | |
|---|
| 247 | cat > $work/ok <<EOF |
|---|
| 248 | 1 10 initial commit |
|---|
| 249 | 2 11 second commit |
|---|
| 250 | 3 12 third commit |
|---|
| 251 | 4 13 fourth commit |
|---|
| 252 | EOF |
|---|
| 253 | if test $? -ne 0; then no_result; fi |
|---|
| 254 | |
|---|
| 255 | activity="check aegis project history" |
|---|
| 256 | aegis -list project_history -unformatted 2> log | cut -d\ -f 1,7- > history |
|---|
| 257 | if test $? -ne 0; then cat history; no_result; fi |
|---|
| 258 | |
|---|
| 259 | diff ok history |
|---|
| 260 | if test $? -ne 0; then fail; fi |
|---|
| 261 | |
|---|
| 262 | cat > $work/ok <<EOF |
|---|
| 263 | brief_description = "fourth commit"; |
|---|
| 264 | description = "This text is now the description of the aegis change splitted on\n\\ |
|---|
| 265 | multiple lines."; |
|---|
| 266 | cause = external_improvement; |
|---|
| 267 | test_exempt = true; |
|---|
| 268 | test_baseline_exempt = true; |
|---|
| 269 | regression_test_exempt = true; |
|---|
| 270 | architecture = |
|---|
| 271 | [ |
|---|
| 272 | "unspecified", |
|---|
| 273 | ]; |
|---|
| 274 | copyright_years = |
|---|
| 275 | [ |
|---|
| 276 | `date +%Y`, |
|---|
| 277 | ]; |
|---|
| 278 | EOF |
|---|
| 279 | if test $? -ne 0; then no_result; fi |
|---|
| 280 | |
|---|
| 281 | activity="check project content" |
|---|
| 282 | aegis -ca -l 13 > $work/change_attr 2> log |
|---|
| 283 | if test $? -ne 0; then cat log; no_result; fi |
|---|
| 284 | |
|---|
| 285 | diff ok change_attr |
|---|
| 286 | if test $? -ne 0; then fail; fi |
|---|
| 287 | |
|---|
| 288 | # |
|---|
| 289 | # test change content |
|---|
| 290 | # |
|---|
| 291 | activity="change 10" |
|---|
| 292 | cat > $work/ok <<EOF |
|---|
| 293 | config create 1 aegis.conf |
|---|
| 294 | source create 1 dir/foo.txt |
|---|
| 295 | EOF |
|---|
| 296 | if test $? -ne 0; then no_result; fi |
|---|
| 297 | |
|---|
| 298 | aegis -list change_files -unf -c 10 > $work/out |
|---|
| 299 | if test $? -ne 0; then no_result; fi |
|---|
| 300 | |
|---|
| 301 | diff $work/ok $work/out |
|---|
| 302 | if test $? -ne 0; then fail; fi |
|---|
| 303 | |
|---|
| 304 | pass |
|---|