source: tailor/test-scripts/test-darcs2aegis-simple.sh @ 1578

Revision 1578, 12.4 KB checked in by lele@…, 5 years ago (diff)

Removed useless module option for darcs

Line 
1#!/bin/sh
2#
3# Copyright (C) 2008 Walter Franzini
4#
5# NOTE: TABS in aegis metadata samples below must be preserved.
6#
7
8#
9# This test expects to be run from the tailor top source dir, change
10# the following line if the convention used by tailor developer(s)
11# differs.
12#
13here=`pwd`
14
15#
16# To test against the stable aegis branch add the stable executables
17# directory to the PATH.  Only needed for aegis contributors.
18#
19aegis_stable_baseline=$(aegis -cd -p aegis.stable -bl 2> /dev/null)
20if test -n "$aegis_stable_baseline"
21then
22    PATH=$aegis_stable_baseline/linux-i486/bin:$PATH
23fi
24
25#
26# Add the development dir to the PATH
27#
28PATH=$here:$PATH
29export PATH
30
31pass()
32{
33    echo "PASSED:"
34    exit 0
35}
36
37fail()
38{
39    echo "FAILED: $activity"
40    exit 1
41}
42
43no_result()
44{
45    echo "NO_RESULT: $activity"
46    exit 2
47}
48
49#
50# The following function is used to check aegis metadata files.
51#
52check_it()
53{
54        sed     -e "s|$work|...|g" \
55                -e 's|= [0-9][0-9]*; /.*|= TIME;|' \
56                -e "s/\"$USER\"/\"USER\"/g" \
57                -e 's/uuid = ".*"/uuid = "UUID"/' \
58                -e 's/19[0-9][0-9]/YYYY/' \
59                -e 's/20[0-9][0-9]/YYYY/' \
60                -e 's/node = ".*"/node = "NODE"/' \
61                -e 's/crypto = ".*"/crypto = "GUNK"/' \
62                < $2 > $work/sed.out
63        if test $? -ne 0; then no_result; fi
64        diff -B $1 $work/sed.out
65        if test $? -ne 0; then no_result; fi
66}
67
68
69#
70# This test follows Aegis convention, where a test must be able to
71# work even when the development directory is not writable, this
72# happens when running tests in the integration stage.
73#
74work=${TMPDIR-/tmp}/TAILOR.$$
75mkdir $work
76if test $? -ne 0; then no_result; fi
77
78cd $work
79
80#
81# Prepare the darcs repository
82#
83activity="darcs setup"
84mkdir $work/darcs-repo > log 2>&1
85if test $? -ne 0; then cat log; no_result; fi
86
87darcs initialize --repodir=$work/darcs-repo > log 2>&1
88if test $? -ne 0; then cat log; no_result; fi
89
90activity="create foo"
91mkdir $work/darcs-repo/dir
92if test $? -ne 0; then no_result; fi
93
94cat > $work/darcs-repo/dir/foo.txt <<EOF
95A simple text file
96EOF
97if test $? -ne 0; then no_result; fi
98
99darcs add dir/foo.txt --repodir=$work/darcs-repo > log 2>&1
100if test $? -ne 0; then cat log; no_result; fi
101
102darcs record --repodir=$work/darcs-repo -a -A Nobody -m "initial commit" \
103    > log 2>&1
104if test $? -ne 0; then cat log; no_result; fi
105
106cat > $work/darcs-repo/dir/foo.txt <<EOF
107A simple text file
108wit some more text.
109EOF
110if test $? -ne 0; then no_result; fi
111
112cat > $work/darcs-repo/bar.txt <<EOF
113This is bar.txt
114EOF
115if test $? -ne 0; then no_result; fi
116
117darcs add bar.txt --repodir=$work/darcs-repo > log 2>&1
118if test $? -ne 0; then cat log; no_result; fi
119
120darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
121    -m "second commit" > log 2>&1
122if test $? -ne 0; then cat log; no_result; fi
123
124cat > $work/darcs-repo/dir/foo.txt <<EOF
125A simple text file
126wit some more text.
127more text again!
128EOF
129if test $? -ne 0; then no_result; fi
130
131darcs mv bar.txt baz.txt --repodir=$work/darcs-repo > log 2>&1
132if test $? -ne 0; then cat log; no_result; fi
133
134darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
135    -m "third commit" > log 2>&1
136if test $? -ne 0; then cat log; no_result; fi
137
138#
139# Initialize the aegis repository
140#
141
142unset AEGIS_PROJECT
143unset AEGIS_CHANGE
144unset AEGIS_PATH
145unset AEGIS
146umask 022
147
148LINES=24
149export LINES
150COLS=80
151export COLS
152
153USER=${USER:-${LOGNAME:-`whoami`}}
154
155PAGER=cat
156export PAGER
157AEGIS_THROTTLE=-1
158export AEGIS_THROTTLE
159
160# This tells aeintegratq that it is being used by a test.
161AEGIS_TEST_DIR=$work
162export AEGIS_TEST_DIR
163
164if test $? -ne 0; then exit 2; fi
165
166AEGIS_DATADIR=$here/lib
167export AEGIS_DATADIR
168
169AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
170export AEGIS_MESSAGE_LIBRARY
171unset LANG
172unset LANGUAGE
173unset LC_ALL
174
175AEGIS_PROJECT=example
176export AEGIS_PROJECT
177AEGIS_PATH=$work/lib
178export AEGIS_PATH
179
180mkdir $AEGIS_PATH
181
182chmod 777 $AEGIS_PATH
183if test $? -ne 0; then no_result; cat log; fi
184
185workproj=$work/foo.proj
186workchan=$work/foo.chan
187
188#
189# The project is NOT created by means of tailor since it should be
190# created with a different user.
191#
192activity="new project"
193aegis -npr $AEGIS_PROJECT -version "" -lib $AEGIS_PATH \
194    -dir $workproj/ > log 2>&1
195if test $? -ne 0; then cat log; no_result; fi
196
197activity="project_acttributes"
198cat > $work/pa <<EOF
199description = "A bogus project created to test tailor functionality.";
200developer_may_review = true;
201developer_may_integrate = true;
202reviewer_may_integrate = true;
203default_test_exemption = true;
204develop_end_action = goto_awaiting_integration;
205EOF
206if test $? -ne 0 ; then no_result; fi
207
208aegis -pa -f $work/pa > log 2>&1
209if test $? -ne 0 ; then cat log; no_result; fi
210
211#
212# add the staff
213#
214activity="staff 62"
215aegis -nd $USER > log 2>&1
216if test $? -ne 0 ; then cat log; no_result; fi
217aegis -nrv $USER > log 2>&1
218if test $? -ne 0 ; then cat log; no_result; fi
219aegis -ni $USER > log 2>&1
220if test $? -ne 0 ; then cat log; no_result; fi
221
222#
223# tailor config
224#
225cat > $work/tailor.conf <<EOF
226[DEFAULT]
227verbose = true
228Debug = true
229
230[project]
231patch-name-format = %(revision)s
232root-directory = $PWD/rootdir
233source = darcs:source
234target = aegis:target
235
236[darcs:source]
237repository = $work/darcs-repo
238subdir = darcs1side
239
240[aegis:target]
241module = $AEGIS_PROJECT
242subdir = aegisside
243EOF
244if test $? -ne 0; then no_result; fi
245
246activity="run tailor"
247python $here/tailor -c $work/tailor.conf > $work/tailor.log 2>&1
248if test $? -ne 0; then cat $work/tailor.log; fail; fi
249
250cat > $work/ok <<EOF
2511 10 initial commit
2522 11 second commit
2533 12 third commit
254EOF
255if test $? -ne 0; then no_result; fi
256
257activity="check aegis project history"
258aegis -list project_history -unformatted 2> $work/log \
259    | cut -d\  -f 1,7- > $work/history
260if test $? -ne 0; then cat $work/log; no_result; fi
261
262diff -u $work/ok $work/history
263if test $? -ne 0; then fail; fi
264
265#
266# add more darcs changes
267#
268cat > $work/darcs-repo/baz.txt <<EOF
269A simple text file
270wit some more text.
271more text again!
272ancora piu\` test
273EOF
274if test $? -ne 0; then no_result; fi
275
276darcs remove dir/foo.txt --repodir=$work/darcs-repo > log 2>&1
277if test $? -ne 0; then cat log; no_result; fi
278
279activity="tag 1.0.0"
280darcs tag 1.0.0 --repodir=$work/darcs-repo -A Nobody > log 2>&1
281if test $? -ne 0; then cat log; no_result; fi
282
283cat > $work/logfile <<EOF
284fourth commit
285This text is now
286the description of the aegis change
287splitted on multiple lines.
288EOF
289if test $? -ne 0; then no_result; fi
290
291darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
292    --logfile $work/logfile > log 2>&1
293if test $? -ne 0; then cat log; no_result; fi
294
295activity="run tailor again"
296python $here/tailor -c $work/tailor.conf > log 2>&1
297if test $? -ne 0; then cat log; fail; fi
298
299#
300# Check the aegis project history.
301# fixme:  there is a gap in the change number sequence (13 is missing)
302#         because currently the change corresponding to the tags is
303#         still created even if it cannot be completed because it's empty
304#
305activity="check aegis project history (again)"
306
307cat > $work/ok <<EOF
3081 10 initial commit
3092 11 second commit
310Name: "1.0.0"
3113 12 third commit
3124 14 fourth commit
313EOF
314if test $? -ne 0; then no_result; fi
315
316aegis -list project_history -unformatted 2> log > history
317if test $? -ne 0; then cat history; no_result; fi
318
319cat > $work/massage_history.awk <<'EOF'
320/^Name:/ {print $0}
321/^[0-9]/ {print $1, $7, $8, $9}
322EOF
323if test $? -ne 0; then no_result; fi
324
325awk -f $work/massage_history.awk < history > history.new
326if test $? -ne 0; then no_result; fi
327
328diff -u ok history.new
329if test $? -ne 0; then fail; fi
330
331activity="check change 14 attributes"
332cat > $work/ok <<EOF
333brief_description = "fourth commit";
334description = "This text is now the description of the aegis change splitted on\n\\
335multiple lines.";
336cause = external_improvement;
337test_exempt = true;
338test_baseline_exempt = true;
339regression_test_exempt = true;
340architecture =
341[
342        "unspecified",
343];
344copyright_years =
345[
346        `date +%Y`,
347];
348EOF
349if test $? -ne 0; then no_result; fi
350
351aegis -ca -l 14 > $work/change_attr 2> log
352if test $? -ne 0; then cat log; no_result; fi
353
354diff ok change_attr
355if test $? -ne 0; then fail; fi
356
357#
358# test the change content
359#
360activity="change 10 content"
361cat > $work/ok <<EOF
362config create 1 aegis.conf
363source create 1 dir/foo.txt
364EOF
365if test $? -ne 0; then no_result; fi
366
367aegis -list change_files -unf -c 10 > $work/out
368if test $? -ne 0; then no_result; fi
369
370diff -u $work/ok $work/out
371if test $? -ne 0; then fail; fi
372
373#
374# Check the content of change 11 (second commit)
375#
376activity="check change 11 content"
377cat > $work/ok <<EOF
378source create 1 bar.txt
379source modify 1 -> 2 dir/foo.txt
380EOF
381if test $? -ne 0; then no_result; fi
382
383aegis -list change_files -unf -c 11 > $work/out
384if test $? -ne 0; then no_result; fi
385
386diff -u $work/ok $work/out
387if test $? -ne 0; then fail; fi
388
389#
390# Check the content of change 12 (third commit)
391#
392# Note: we check the change fstate file to verify the rename
393#       operation, since the unformatted output lacks some details..
394#
395activity="check change 12 content"
396cat > $work/ok <<EOF
397src =
398[
399        {
400                file_name = "bar.txt";
401                uuid = "UUID";
402                action = remove;
403                edit_origin =
404                {
405                        revision = "1";
406                        encoding = none;
407                };
408                usage = source;
409                move = "baz.txt";
410        },
411        {
412                file_name = "baz.txt";
413                uuid = "UUID";
414                action = create;
415                edit =
416                {
417                        revision = "2";
418                        encoding = none;
419                };
420                edit_origin =
421                {
422                        revision = "1";
423                        encoding = none;
424                };
425                usage = source;
426                move = "bar.txt";
427        },
428        {
429                file_name = "dir/foo.txt";
430                uuid = "UUID";
431                action = modify;
432                edit =
433                {
434                        revision = "3";
435                        encoding = none;
436                };
437                edit_origin =
438                {
439                        revision = "2";
440                        encoding = none;
441                };
442                usage = source;
443        },
444];
445EOF
446if test $? -ne 0; then no_result; fi
447
448check_it ok $workproj/info/change/0/012.fs
449
450#
451# Note: there is a gap in the change numbers sequence, the next should
452#       be 13, because the aegis target back-end needs to be improved
453#       in the case of changeset setting only a tag
454#
455activity="check change 14 content"
456cat > $work/ok <<EOF
457source modify 2 -> 3 baz.txt
458source remove 3 dir/foo.txt
459EOF
460if test $? -ne 0; then no_result; fi
461
462aegis -list change_files -unf -c 14 > $work/out
463if test $? -ne 0; then no_result; fi
464
465diff -u $work/ok $work/out
466if test $? -ne 0; then fail; fi
467
468#
469# Check the content of the baseline
470#
471activity="check the baseline"
472cat > $work/ok <<EOF
473src =
474[
475        {
476                file_name = "aegis.conf";
477                uuid = "UUID";
478                action = create;
479                edit =
480                {
481                        revision = "1";
482                        encoding = none;
483                };
484                edit_origin =
485                {
486                        revision = "1";
487                        encoding = none;
488                };
489                usage = config;
490                file_fp =
491                {
492                        youngest = TIME;
493                        oldest = TIME;
494                        crypto = "GUNK";
495                };
496                diff_file_fp =
497                {
498                        youngest = TIME;
499                        oldest = TIME;
500                        crypto = "GUNK";
501                };
502        },
503        {
504                file_name = "bar.txt";
505                uuid = "UUID";
506                action = remove;
507                edit =
508                {
509                        revision = "1";
510                        encoding = none;
511                };
512                edit_origin =
513                {
514                        revision = "1";
515                        encoding = none;
516                };
517                usage = source;
518                move = "baz.txt";
519                deleted_by = 12;
520        },
521        {
522                file_name = "baz.txt";
523                uuid = "UUID";
524                action = create;
525                edit =
526                {
527                        revision = "3";
528                        encoding = none;
529                };
530                edit_origin =
531                {
532                        revision = "3";
533                        encoding = none;
534                };
535                usage = source;
536                file_fp =
537                {
538                        youngest = TIME;
539                        oldest = TIME;
540                        crypto = "GUNK";
541                };
542                diff_file_fp =
543                {
544                        youngest = TIME;
545                        oldest = TIME;
546                        crypto = "GUNK";
547                };
548                move = "bar.txt";
549        },
550        {
551                file_name = "dir/foo.txt";
552                uuid = "UUID";
553                action = remove;
554                edit =
555                {
556                        revision = "3";
557                        encoding = none;
558                };
559                edit_origin =
560                {
561                        revision = "3";
562                        encoding = none;
563                };
564                usage = source;
565                diff_file_fp =
566                {
567                        youngest = TIME;
568                        oldest = TIME;
569                        crypto = "GUNK";
570                };
571                deleted_by = 14;
572        },
573];
574EOF
575if test $? -ne 0; then no_result; fi
576
577check_it ok $workproj/info/trunk.fs
578
579activity="check aegis.conf baseline copy"
580cat > $work/ok <<'EOF'
581
582build_command = "exit 0";
583link_integration_directory = true;
584
585history_get_command = "aesvt -check-out -edit ${quote $edit} "
586    "-history ${quote $history} -f ${quote $output}";
587history_put_command = "aesvt -check-in -history ${quote $history} "
588    "-f ${quote $input}";
589history_query_command = "aesvt -query -history ${quote $history}";
590history_content_limitation = binary_capable;
591
592diff_command = "set +e; $diff $orig $i > $out; test $$? -le 1";
593merge_command =
594"(diff3 -e $i $orig $mr | sed -e '/^w$$/d' -e '/^q$$/d'; echo '1,$$p') "
595"| ed - $i > $out";
596patch_diff_command =
597"set +e; $diff -C0 -L $index -L $index $orig $i > $out; test $$? -le 1";
598
599shell_safe_filenames = false;
600EOF
601if test $? -ne 0; then no_result; fi
602
603diff ok $workproj/baseline/aegis.conf
604if test $? -ne 0; then fail; fi
605
606activity="check baz.txt baseline copy"
607cat > $work/ok <<EOF
608A simple text file
609wit some more text.
610more text again!
611ancora piu\` test
612EOF
613if test $? -ne 0; then no_result; fi
614
615diff ok $workproj/baseline/baz.txt
616if test $? -ne 0; then fail; fi
617
618pass
Note: See TracBrowser for help on using the repository browser.