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

Revision 1566, 12.5 KB checked in by <walter.franzini@…>, 5 years ago (diff)

enable tags for the aegis target back-end

Now the aegis target back-end add a delta_name for each tags contained
in a changeset

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
238#module = project
239subdir = darcs1side
240
241[aegis:target]
242module = $AEGIS_PROJECT
243subdir = aegisside
244EOF
245if test $? -ne 0; then no_result; fi
246
247activity="run tailor"
248python $here/tailor -c $work/tailor.conf > $work/tailor.log 2>&1
249if test $? -ne 0; then cat $work/tailor.log; fail; fi
250
251cat > $work/ok <<EOF
2521 10 initial commit
2532 11 second commit
2543 12 third commit
255EOF
256if test $? -ne 0; then no_result; fi
257
258activity="check aegis project history"
259aegis -list project_history -unformatted 2> $work/log \
260    | cut -d\  -f 1,7- > $work/history
261if test $? -ne 0; then cat $work/log; no_result; fi
262
263diff -u $work/ok $work/history
264if test $? -ne 0; then fail; fi
265
266#
267# add more darcs changes
268#
269cat > $work/darcs-repo/baz.txt <<EOF
270A simple text file
271wit some more text.
272more text again!
273ancora piu\` test
274EOF
275if test $? -ne 0; then no_result; fi
276
277darcs remove dir/foo.txt --repodir=$work/darcs-repo > log 2>&1
278if test $? -ne 0; then cat log; no_result; fi
279
280activity="tag 1.0.0"
281darcs tag 1.0.0 --repodir=$work/darcs-repo -A Nobody > log 2>&1
282if test $? -ne 0; then cat log; no_result; fi
283
284cat > $work/logfile <<EOF
285fourth commit
286This text is now
287the description of the aegis change
288splitted on multiple lines.
289EOF
290if test $? -ne 0; then no_result; fi
291
292darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
293    --logfile $work/logfile > log 2>&1
294if test $? -ne 0; then cat log; no_result; fi
295
296activity="run tailor again"
297python $here/tailor -c $work/tailor.conf > log 2>&1
298if test $? -ne 0; then cat log; fail; fi
299
300#
301# Check the aegis project history.
302# fixme:  there is a gap in the change number sequence (13 is missing)
303#         because currently the change corresponding to the tags is
304#         still created even if it cannot be completed because it's empty
305#
306activity="check aegis project history (again)"
307
308cat > $work/ok <<EOF
3091 10 initial commit
3102 11 second commit
311Name: "1.0.0"
3123 12 third commit
3134 14 fourth commit
314EOF
315if test $? -ne 0; then no_result; fi
316
317aegis -list project_history -unformatted 2> log > history
318if test $? -ne 0; then cat history; no_result; fi
319
320cat > $work/massage_history.awk <<'EOF'
321/^Name:/ {print $0}
322/^[0-9]/ {print $1, $7, $8, $9}
323EOF
324if test $? -ne 0; then no_result; fi
325
326awk -f $work/massage_history.awk < history > history.new
327if test $? -ne 0; then no_result; fi
328
329diff -u ok history.new
330if test $? -ne 0; then fail; fi
331
332activity="check change 14 attributes"
333cat > $work/ok <<EOF
334brief_description = "fourth commit";
335description = "This text is now the description of the aegis change splitted on\n\\
336multiple lines.";
337cause = external_improvement;
338test_exempt = true;
339test_baseline_exempt = true;
340regression_test_exempt = true;
341architecture =
342[
343        "unspecified",
344];
345copyright_years =
346[
347        `date +%Y`,
348];
349EOF
350if test $? -ne 0; then no_result; fi
351
352aegis -ca -l 14 > $work/change_attr 2> log
353if test $? -ne 0; then cat log; no_result; fi
354
355diff ok change_attr
356if test $? -ne 0; then fail; fi
357
358#
359# test the change content
360#
361activity="change 10 content"
362cat > $work/ok <<EOF
363config create 1 aegis.conf
364source create 1 dir/foo.txt
365EOF
366if test $? -ne 0; then no_result; fi
367
368aegis -list change_files -unf -c 10 > $work/out
369if test $? -ne 0; then no_result; fi
370
371diff -u $work/ok $work/out
372if test $? -ne 0; then fail; fi
373
374#
375# Check the content of change 11 (second commit)
376#
377activity="check change 11 content"
378cat > $work/ok <<EOF
379source create 1 bar.txt
380source modify 1 -> 2 dir/foo.txt
381EOF
382if test $? -ne 0; then no_result; fi
383
384aegis -list change_files -unf -c 11 > $work/out
385if test $? -ne 0; then no_result; fi
386
387diff -u $work/ok $work/out
388if test $? -ne 0; then fail; fi
389
390#
391# Check the content of change 12 (third commit)
392#
393# Note: we check the change fstate file to verify the rename
394#       operation, since the unformatted output lacks some details..
395#
396activity="check change 12 content"
397cat > $work/ok <<EOF
398src =
399[
400        {
401                file_name = "bar.txt";
402                uuid = "UUID";
403                action = remove;
404                edit_origin =
405                {
406                        revision = "1";
407                        encoding = none;
408                };
409                usage = source;
410                move = "baz.txt";
411        },
412        {
413                file_name = "baz.txt";
414                uuid = "UUID";
415                action = create;
416                edit =
417                {
418                        revision = "2";
419                        encoding = none;
420                };
421                edit_origin =
422                {
423                        revision = "1";
424                        encoding = none;
425                };
426                usage = source;
427                move = "bar.txt";
428        },
429        {
430                file_name = "dir/foo.txt";
431                uuid = "UUID";
432                action = modify;
433                edit =
434                {
435                        revision = "3";
436                        encoding = none;
437                };
438                edit_origin =
439                {
440                        revision = "2";
441                        encoding = none;
442                };
443                usage = source;
444        },
445];
446EOF
447if test $? -ne 0; then no_result; fi
448
449check_it ok $workproj/info/change/0/012.fs
450
451#
452# Note: there is a gap in the change numbers sequence, the next should
453#       be 13, because the aegis target back-end needs to be improved
454#       in the case of changeset setting only a tag
455#
456activity="check change 14 content"
457cat > $work/ok <<EOF
458source modify 2 -> 3 baz.txt
459source remove 3 dir/foo.txt
460EOF
461if test $? -ne 0; then no_result; fi
462
463aegis -list change_files -unf -c 14 > $work/out
464if test $? -ne 0; then no_result; fi
465
466diff -u $work/ok $work/out
467if test $? -ne 0; then fail; fi
468
469#
470# Check the content of the baseline
471#
472activity="check the baseline"
473cat > $work/ok <<EOF
474src =
475[
476        {
477                file_name = "aegis.conf";
478                uuid = "UUID";
479                action = create;
480                edit =
481                {
482                        revision = "1";
483                        encoding = none;
484                };
485                edit_origin =
486                {
487                        revision = "1";
488                        encoding = none;
489                };
490                usage = config;
491                file_fp =
492                {
493                        youngest = TIME;
494                        oldest = TIME;
495                        crypto = "GUNK";
496                };
497                diff_file_fp =
498                {
499                        youngest = TIME;
500                        oldest = TIME;
501                        crypto = "GUNK";
502                };
503        },
504        {
505                file_name = "bar.txt";
506                uuid = "UUID";
507                action = remove;
508                edit =
509                {
510                        revision = "1";
511                        encoding = none;
512                };
513                edit_origin =
514                {
515                        revision = "1";
516                        encoding = none;
517                };
518                usage = source;
519                move = "baz.txt";
520                deleted_by = 12;
521        },
522        {
523                file_name = "baz.txt";
524                uuid = "UUID";
525                action = create;
526                edit =
527                {
528                        revision = "3";
529                        encoding = none;
530                };
531                edit_origin =
532                {
533                        revision = "3";
534                        encoding = none;
535                };
536                usage = source;
537                file_fp =
538                {
539                        youngest = TIME;
540                        oldest = TIME;
541                        crypto = "GUNK";
542                };
543                diff_file_fp =
544                {
545                        youngest = TIME;
546                        oldest = TIME;
547                        crypto = "GUNK";
548                };
549                move = "bar.txt";
550        },
551        {
552                file_name = "dir/foo.txt";
553                uuid = "UUID";
554                action = remove;
555                edit =
556                {
557                        revision = "3";
558                        encoding = none;
559                };
560                edit_origin =
561                {
562                        revision = "3";
563                        encoding = none;
564                };
565                usage = source;
566                diff_file_fp =
567                {
568                        youngest = TIME;
569                        oldest = TIME;
570                        crypto = "GUNK";
571                };
572                deleted_by = 14;
573        },
574];
575EOF
576if test $? -ne 0; then no_result; fi
577
578check_it ok $workproj/info/trunk.fs
579
580activity="check aegis.conf baseline copy"
581cat > $work/ok <<'EOF'
582
583build_command = "exit 0";
584link_integration_directory = true;
585
586history_get_command = "aesvt -check-out -edit ${quote $edit} "
587    "-history ${quote $history} -f ${quote $output}";
588history_put_command = "aesvt -check-in -history ${quote $history} "
589    "-f ${quote $input}";
590history_query_command = "aesvt -query -history ${quote $history}";
591history_content_limitation = binary_capable;
592
593diff_command = "set +e; $diff $orig $i > $out; test $$? -le 1";
594merge_command =
595"(diff3 -e $i $orig $mr | sed -e '/^w$$/d' -e '/^q$$/d'; echo '1,$$p') "
596"| ed - $i > $out";
597patch_diff_command =
598"set +e; $diff -C0 -L $index -L $index $orig $i > $out; test $$? -le 1";
599
600shell_safe_filenames = false;
601EOF
602if test $? -ne 0; then no_result; fi
603
604diff ok $workproj/baseline/aegis.conf
605if test $? -ne 0; then fail; fi
606
607activity="check baz.txt baseline copy"
608cat > $work/ok <<EOF
609A simple text file
610wit some more text.
611more text again!
612ancora piu\` test
613EOF
614if test $? -ne 0; then no_result; fi
615
616diff ok $workproj/baseline/baz.txt
617if test $? -ne 0; then fail; fi
618
619pass
Note: See TracBrowser for help on using the repository browser.