comparison tests/testlib/merge-combination-util.sh @ 46265:8045e4aa366b

test: extract the `genmerges` out of test-merge-combination.t This open the way to splitting this slow test in multiple ones. Differential Revision: https://phab.mercurial-scm.org/D9767
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 14 Jan 2021 11:33:09 +0100
parents
children e8b0c519dfb3
comparison
equal deleted inserted replaced
46264:7149fb17ff72 46265:8045e4aa366b
1 # genmerges is the workhorse of the test-merge-combination.t tests.
2
3 # Given:
4 # - a `range` function describing the possible values for file a
5 # - a `isgood` function to filter out uninteresting combination
6 # - a `createfile` function to actually write the values for file a on the
7 # filesystem
8 #
9 # it print a series of lines that look like: abcd C: output of -T {files}
10 # describing the file a at respectively the base, p2, p1, merge
11 # revision. "C" indicates that hg merge had conflicts.
12
13 genmerges () {
14
15 (LC_ALL=C type range | grep -q 'function') || (echo >&2 "missing function: range")
16 (LC_ALL=C type isgood | grep -q 'function') || (echo >&2 "missing function: isgood")
17 (LC_ALL=C type createfile | grep -q 'function') || (echo >&2 "missing function: createfile")
18
19 for base in `range` -; do
20 for r1 in `range $base` -; do
21 for r2 in `range $base $r1` -; do
22 for m in `range $base $r1 $r2` -; do
23 line="$base$r1$r2$m"
24 isgood $line || continue
25 hg init repo
26 cd repo
27 make_commit () {
28 v=$1; msg=$2; file=$3;
29 if [ $v != - ]; then
30 createfile $v
31 else
32 if [ -f a ]
33 then rm a
34 else touch $file
35 fi
36 fi
37 hg commit -q -Am $msg || exit 123
38 }
39 echo foo > foo
40 make_commit $base base b
41 make_commit $r1 r1 c
42 hg up -r 0 -q
43 make_commit $r2 r2 d
44 hg merge -q -r 1 > ../output 2>&1
45 if [ $? -ne 0 ]; then rm -f *.orig; hg resolve -m --all -q; fi
46 if [ -s ../output ]; then conflicts=" C"; else conflicts=" "; fi
47 make_commit $m m e
48 if [ $m = $r1 ] && [ $m = $r2 ]
49 then expected=
50 elif [ $m = $r1 ]
51 then if [ $base = $r2 ]
52 then expected=
53 else expected=a
54 fi
55 elif [ $m = $r2 ]
56 then if [ $base = $r1 ]
57 then expected=
58 else expected=a
59 fi
60 else expected=a
61 fi
62 got=`hg log -r 3 --template '{files}\n' | tr -d 'e '`
63 if [ "$got" = "$expected" ]
64 then echo "$line$conflicts: agree on \"$got\""
65 else echo "$line$conflicts: hg said \"$got\", expected \"$expected\""
66 fi
67 cd ../
68 rm -rf repo
69 done
70 done
71 done
72 done
73 }