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