forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_merge.sh
executable file
·111 lines (74 loc) · 2.91 KB
/
check_merge.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
@INCLUDE_COMMON@
echo
echo ELEKTRA MERGE SCRIPTS TESTS
echo
check_version
if "$KDB" plugin-info storage provides 2> /dev/null | grep -q 'storage/ini'; then
echo "This test does not work if Elektra uses the INI plugin as default storage"
exit 0
fi
OURS_ROOT=$USER_ROOT/mergetest/ours
THEIRS_ROOT=$USER_ROOT/mergetest/theirs
BASE_ROOT=$USER_ROOT/mergetest/base
MERGED_ROOT=$USER_ROOT/mergetest/merged
echo "Testing trivial merging"
"$KDB" set $OURS_ROOT/key "init" > /dev/null
exit_if_fail "could not set"
"$KDB" set $THEIRS_ROOT/key "init" > /dev/null
exit_if_fail "could not set"
"$KDB" set $BASE_ROOT/key "init" > /dev/null
exit_if_fail "could not set"
"$KDB" ls $MERGED_ROOT
"$KDB" merge $OURS_ROOT $THEIRS_ROOT $BASE_ROOT $MERGED_ROOT
exit_if_fail "could not merge"
[ "x$("$KDB" ls $MERGED_ROOT/key 2> /dev/null)" = "x$MERGED_ROOT/key" ]
exit_if_fail "not exactly one result"
[ "x$("$KDB" get $MERGED_ROOT/key 2> /dev/null)" = "xinit" ]
"$KDB" rm -r $USER_ROOT/mergetest
echo "Testing conflict"
"$KDB" set $OURS_ROOT/key "ours" > /dev/null
exit_if_fail "could not set"
"$KDB" set $THEIRS_ROOT/key "theirs" > /dev/null
exit_if_fail "could not set"
"$KDB" set $BASE_ROOT/key "init" > /dev/null
exit_if_fail "could not set"
"$KDB" merge $OURS_ROOT $THEIRS_ROOT $BASE_ROOT $MERGED_ROOT 2> /dev/null
[ $? != 0 ]
succeed_if "Merging did not fail"
[ "x$("$KDB" ls $MERGED_ROOT/key 2> /dev/null)" = "x" ]
exit_if_fail "should be no result"
"$KDB" merge --strategy ours $OURS_ROOT $THEIRS_ROOT $BASE_ROOT $MERGED_ROOT
exit_if_fail "could not merge"
[ "x$("$KDB" ls $MERGED_ROOT/key 2> /dev/null)" = "x$MERGED_ROOT/key" ]
exit_if_fail "not exactly one result"
[ "x$("$KDB" get $MERGED_ROOT/key 2> /dev/null)" = "xours" ]
exit_if_fail "merge produced wrong result"
"$KDB" rm -r $MERGED_ROOT/key
"$KDB" rm -r $OURS_ROOT/key
"$KDB" rm -r $THEIRS_ROOT/key
"$KDB" rm -r $BASE_ROOT/key
echo "Testing metadata"
"$KDB" set $OURS_ROOT/key "init" > /dev/null
exit_if_fail "could not set"
"$KDB" meta-set $OURS_ROOT/key comment "init" > /dev/null
exit_if_fail "could not set meta"
"$KDB" set $THEIRS_ROOT/key "init" > /dev/null
exit_if_fail "could not set"
"$KDB" meta-set $THEIRS_ROOT/key comment "theirs" > /dev/null
exit_if_fail "could not set meta"
"$KDB" set $BASE_ROOT/key "init" > /dev/null
exit_if_fail "could not set"
"$KDB" meta-set $BASE_ROOT/key comment "base" > /dev/null
exit_if_fail "could not set meta"
"$KDB" merge $OURS_ROOT $THEIRS_ROOT $BASE_ROOT $MERGED_ROOT 2> /dev/null
[ $? != 0 ]
succeed_if "Merging did not failed"
[ "x$("$KDB" ls $MERGED_ROOT/key 2> /dev/null)" = "x" ]
exit_if_fail "should be no result"
"$KDB" merge --strategy ours $OURS_ROOT $THEIRS_ROOT $BASE_ROOT $MERGED_ROOT
exit_if_fail "could not merge"
[ "x$("$KDB" ls $MERGED_ROOT/key 2> /dev/null)" = "x$MERGED_ROOT/key" ]
exit_if_fail "not exactly one result"
[ "x$("$KDB" get $MERGED_ROOT/key 2> /dev/null)" = "xinit" ]
"$KDB" rm -r $USER_ROOT/mergetest
end_script