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

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

test-darcs2aegis-simple.sh improvement

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