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

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

aegis backend simulate the (missing) aemv -keep command
The aegis -move command does not provide the -keep option to preserve
the content of the newly created file, so the target backend simulate
that behavior.

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
131cat > $work/darcs-repo/bar.txt <<EOF
132This will be baz.txt
133EOF
134if test $? -ne 0; then no_result; fi
135
136darcs mv bar.txt baz.txt --repodir=$work/darcs-repo > log 2>&1
137if test $? -ne 0; then cat log; no_result; fi
138
139darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
140    -m "third commit" > log 2>&1
141if test $? -ne 0; then cat log; no_result; fi
142
143#
144# Initialize the aegis repository
145#
146unset AEGIS_PROJECT
147unset AEGIS_CHANGE
148unset AEGIS_PATH
149unset AEGIS
150umask 022
151
152LINES=24
153export LINES
154COLS=80
155export COLS
156
157USER=${USER:-${LOGNAME:-`whoami`}}
158
159PAGER=cat
160export PAGER
161AEGIS_THROTTLE=-1
162export AEGIS_THROTTLE
163
164# This tells aeintegratq that it is being used by a test.
165AEGIS_TEST_DIR=$work
166export AEGIS_TEST_DIR
167
168if test $? -ne 0; then exit 2; fi
169
170AEGIS_DATADIR=$here/lib
171export AEGIS_DATADIR
172
173AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
174export AEGIS_MESSAGE_LIBRARY
175unset LANG
176unset LANGUAGE
177unset LC_ALL
178
179AEGIS_PROJECT=example
180export AEGIS_PROJECT
181AEGIS_PATH=$work/lib
182export AEGIS_PATH
183
184mkdir $AEGIS_PATH
185
186chmod 777 $AEGIS_PATH
187if test $? -ne 0; then no_result; cat log; fi
188
189workproj=$work/foo.proj
190workchan=$work/foo.chan
191
192#
193# The project is NOT created by means of tailor since it should be
194# created with a different user.
195#
196activity="new project"
197aegis -npr $AEGIS_PROJECT -version "" -lib $AEGIS_PATH \
198    -dir $workproj/ > log 2>&1
199if test $? -ne 0; then cat log; no_result; fi
200
201activity="project_acttributes"
202cat > $work/pa <<EOF
203description = "A bogus project created to test tailor functionality.";
204developer_may_review = true;
205developer_may_integrate = true;
206reviewer_may_integrate = true;
207default_test_exemption = true;
208develop_end_action = goto_awaiting_integration;
209EOF
210if test $? -ne 0 ; then no_result; fi
211
212aegis -pa -f $work/pa > log 2>&1
213if test $? -ne 0 ; then cat log; no_result; fi
214
215#
216# add the staff
217#
218activity="staff 62"
219aegis -nd $USER > log 2>&1
220if test $? -ne 0 ; then cat log; no_result; fi
221aegis -nrv $USER > log 2>&1
222if test $? -ne 0 ; then cat log; no_result; fi
223aegis -ni $USER > log 2>&1
224if test $? -ne 0 ; then cat log; no_result; fi
225
226#
227# tailor config
228#
229cat > $work/tailor.conf <<EOF
230[DEFAULT]
231verbose = true
232Debug = true
233
234[project]
235patch-name-format = %(revision)s
236root-directory = $PWD/rootdir
237source = darcs:source
238target = aegis:target
239
240[darcs:source]
241repository = $work/darcs-repo
242subdir = darcs1side
243
244[aegis:target]
245module = $AEGIS_PROJECT
246subdir = aegisside
247EOF
248if test $? -ne 0; then no_result; fi
249
250activity="run tailor"
251python $here/tailor -c $work/tailor.conf > $work/tailor.log 2>&1
252if test $? -ne 0; then cat $work/tailor.log; fail; fi
253
254cat > $work/ok <<EOF
2551 10 initial commit
2562 11 second commit
2573 12 third commit
258EOF
259if test $? -ne 0; then no_result; fi
260
261activity="check aegis project history"
262aegis -list project_history -unformatted 2> $work/log \
263    | cut -d\  -f 1,7- > $work/history
264if test $? -ne 0; then cat $work/log; no_result; fi
265
266diff -u $work/ok $work/history
267if test $? -ne 0; then fail; fi
268
269activity="check the aegis baseline vs. darcs repository"
270diff $work/darcs-repo/baz.txt $workproj/baseline/baz.txt
271if test $? -ne 0; then fail; fi
272
273diff $work/darcs-repo/dir/foo.txt $workproj/baseline/dir/foo.txt
274if test $? -ne 0; then fail; fi
275
276#
277# add more darcs changes
278#
279cat > $work/darcs-repo/baz.txt <<EOF
280A simple text file
281wit some more text.
282more text again!
283ancora piu\` test
284EOF
285if test $? -ne 0; then no_result; fi
286
287darcs remove dir/foo.txt --repodir=$work/darcs-repo > log 2>&1
288if test $? -ne 0; then cat log; no_result; fi
289
290activity="tag 1.0.0"
291darcs tag 1.0.0 --repodir=$work/darcs-repo -A Nobody > log 2>&1
292if test $? -ne 0; then cat log; no_result; fi
293
294cat > $work/logfile <<EOF
295fourth commit
296This text is now
297the description of the aegis change
298splitted on multiple lines.
299EOF
300if test $? -ne 0; then no_result; fi
301
302darcs record --repodir=$work/darcs-repo -a -A Nobody --ignore-time \
303    --logfile $work/logfile > log 2>&1
304if test $? -ne 0; then cat log; no_result; fi
305
306activity="run tailor again"
307python $here/tailor -c $work/tailor.conf > log 2>&1
308if test $? -ne 0; then cat log; fail; fi
309
310#
311# Check the aegis project history.
312# fixme:  there is a gap in the change number sequence (13 is missing)
313#         because currently the change corresponding to the tags is
314#         still created even if it cannot be completed because it's empty
315#
316activity="check aegis project history (again)"
317
318cat > $work/ok <<EOF
3191 10 initial commit
3202 11 second commit
321Name: "1.0.0"
3223 12 third commit
3234 14 fourth commit
324EOF
325if test $? -ne 0; then no_result; fi
326
327aegis -list project_history -unformatted 2> log > history
328if test $? -ne 0; then cat history; no_result; fi
329
330cat > $work/massage_history.awk <<'EOF'
331/^Name:/ {print $0}
332/^[0-9]/ {print $1, $7, $8, $9}
333EOF
334if test $? -ne 0; then no_result; fi
335
336awk -f $work/massage_history.awk < history > history.new
337if test $? -ne 0; then no_result; fi
338
339diff -u ok history.new
340if test $? -ne 0; then fail; fi
341
342activity="check change 14 attributes"
343cat > $work/ok <<EOF
344brief_description = "fourth commit";
345description = "This text is now the description of the aegis change splitted on\n\\
346multiple lines.";
347cause = external_improvement;
348test_exempt = true;
349test_baseline_exempt = true;
350regression_test_exempt = true;
351architecture =
352[
353        "unspecified",
354];
355copyright_years =
356[
357        `date +%Y`,
358];
359EOF
360if test $? -ne 0; then no_result; fi
361
362aegis -ca -l 14 > $work/change_attr 2> log
363if test $? -ne 0; then cat log; no_result; fi
364
365diff ok change_attr
366if test $? -ne 0; then fail; fi
367
368#
369# test the change content
370#
371activity="change 10 content"
372cat > $work/ok <<EOF
373config create 1 aegis.conf
374source create 1 dir/foo.txt
375EOF
376if test $? -ne 0; then no_result; fi
377
378aegis -list change_files -unf -c 10 > $work/out
379if test $? -ne 0; then no_result; fi
380
381diff -u $work/ok $work/out
382if test $? -ne 0; then fail; fi
383
384#
385# Check the content of change 11 (second commit)
386#
387activity="check change 11 content"
388cat > $work/ok <<EOF
389source create 1 bar.txt
390source modify 1 -> 2 dir/foo.txt
391EOF
392if test $? -ne 0; then no_result; fi
393
394aegis -list change_files -unf -c 11 > $work/out
395if test $? -ne 0; then no_result; fi
396
397diff -u $work/ok $work/out
398if test $? -ne 0; then fail; fi
399
400#
401# Check the content of change 12 (third commit)
402#
403# Note: we check the change fstate file to verify the rename
404#       operation, since the unformatted output lacks some details..
405#
406activity="check change 12 content"
407cat > $work/ok <<EOF
408src =
409[
410        {
411                file_name = "bar.txt";
412                uuid = "UUID";
413                action = remove;
414                edit_origin =
415                {
416                        revision = "1";
417                        encoding = none;
418                };
419                usage = source;
420                move = "baz.txt";
421        },
422        {
423                file_name = "baz.txt";
424                uuid = "UUID";
425                action = create;
426                edit =
427                {
428                        revision = "2";
429                        encoding = none;
430                };
431                edit_origin =
432                {
433                        revision = "1";
434                        encoding = none;
435                };
436                usage = source;
437                move = "bar.txt";
438        },
439        {
440                file_name = "dir/foo.txt";
441                uuid = "UUID";
442                action = modify;
443                edit =
444                {
445                        revision = "3";
446                        encoding = none;
447                };
448                edit_origin =
449                {
450                        revision = "2";
451                        encoding = none;
452                };
453                usage = source;
454        },
455];
456EOF
457if test $? -ne 0; then no_result; fi
458
459check_it ok $workproj/info/change/0/012.fs
460
461#
462# Note: there is a gap in the change numbers sequence, the next should
463#       be 13, because the aegis target back-end needs to be improved
464#       in the case of changeset setting only a tag
465#
466activity="check change 14 content"
467cat > $work/ok <<EOF
468source modify 2 -> 3 baz.txt
469source remove 3 dir/foo.txt
470EOF
471if test $? -ne 0; then no_result; fi
472
473aegis -list change_files -unf -c 14 > $work/out
474if test $? -ne 0; then no_result; fi
475
476diff -u $work/ok $work/out
477if test $? -ne 0; then fail; fi
478
479#
480# Check the content of the baseline
481#
482activity="check the baseline"
483cat > $work/ok <<EOF
484src =
485[
486        {
487                file_name = "aegis.conf";
488                uuid = "UUID";
489                action = create;
490                edit =
491                {
492                        revision = "1";
493                        encoding = none;
494                };
495                edit_origin =
496                {
497                        revision = "1";
498                        encoding = none;
499                };
500                usage = config;
501                file_fp =
502                {
503                        youngest = TIME;
504                        oldest = TIME;
505                        crypto = "GUNK";
506                };
507                diff_file_fp =
508                {
509                        youngest = TIME;
510                        oldest = TIME;
511                        crypto = "GUNK";
512                };
513        },
514        {
515                file_name = "bar.txt";
516                uuid = "UUID";
517                action = remove;
518                edit =
519                {
520                        revision = "1";
521                        encoding = none;
522                };
523                edit_origin =
524                {
525                        revision = "1";
526                        encoding = none;
527                };
528                usage = source;
529                move = "baz.txt";
530                deleted_by = 12;
531        },
532        {
533                file_name = "baz.txt";
534                uuid = "UUID";
535                action = create;
536                edit =
537                {
538                        revision = "3";
539                        encoding = none;
540                };
541                edit_origin =
542                {
543                        revision = "3";
544                        encoding = none;
545                };
546                usage = source;
547                file_fp =
548                {
549                        youngest = TIME;
550                        oldest = TIME;
551                        crypto = "GUNK";
552                };
553                diff_file_fp =
554                {
555                        youngest = TIME;
556                        oldest = TIME;
557                        crypto = "GUNK";
558                };
559                move = "bar.txt";
560        },
561        {
562                file_name = "dir/foo.txt";
563                uuid = "UUID";
564                action = remove;
565                edit =
566                {
567                        revision = "3";
568                        encoding = none;
569                };
570                edit_origin =
571                {
572                        revision = "3";
573                        encoding = none;
574                };
575                usage = source;
576                diff_file_fp =
577                {
578                        youngest = TIME;
579                        oldest = TIME;
580                        crypto = "GUNK";
581                };
582                deleted_by = 14;
583        },
584];
585EOF
586if test $? -ne 0; then no_result; fi
587
588check_it ok $workproj/info/trunk.fs
589
590activity="check aegis.conf baseline copy"
591cat > $work/ok <<'EOF'
592
593build_command = "exit 0";
594link_integration_directory = true;
595
596history_get_command = "aesvt -check-out -edit ${quote $edit} "
597    "-history ${quote $history} -f ${quote $output}";
598history_put_command = "aesvt -check-in -history ${quote $history} "
599    "-f ${quote $input}";
600history_query_command = "aesvt -query -history ${quote $history}";
601history_content_limitation = binary_capable;
602
603diff_command = "set +e; $diff $orig $i > $out; test $$? -le 1";
604merge_command =
605"(diff3 -e $i $orig $mr | sed -e '/^w$$/d' -e '/^q$$/d'; echo '1,$$p') "
606"| ed - $i > $out";
607patch_diff_command =
608"set +e; $diff -C0 -L $index -L $index $orig $i > $out; test $$? -le 1";
609
610shell_safe_filenames = false;
611EOF
612if test $? -ne 0; then no_result; fi
613
614diff ok $workproj/baseline/aegis.conf
615if test $? -ne 0; then fail; fi
616
617diff $work/darcs-repo/baz.txt $workproj/baseline/baz.txt
618if test $? -ne 0; then fail; fi
619
620pass
Note: See TracBrowser for help on using the repository browser.