3 # Copyright (c) 2006 Catalin Marinas
6 test_description
='Test the sync command.'
11 'Initialize the StGIT repository' \
17 'Create some patches' \
20 echo foo1 > foo1.txt &&
24 echo foo2 > foo2.txt &&
28 echo foo3 > foo3.txt &&
33 [ "$(echo $(stg applied))" = "p1 p2" ] &&
34 [ "$(echo $(stg unapplied))" = "p3" ]
38 'Create a branch with empty patches' \
40 stg branch -c foo base &&
44 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
45 [ "$(echo $(stg unapplied))" = "" ]
49 'Synchronise second patch with the master branch' \
51 stg sync -B master p2 &&
52 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
53 [ "$(echo $(stg unapplied))" = "" ] &&
54 test $(cat foo2.txt) = "foo2"
58 'Synchronise the first two patches with the master branch' \
60 stg sync -B master -a &&
61 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
62 [ "$(echo $(stg unapplied))" = "" ] &&
63 test $(cat foo1.txt) = "foo1" &&
64 test $(cat foo2.txt) = "foo2"
68 'Synchronise all the patches with the exported series' \
70 stg sync -s patches-master/series -a &&
71 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
72 [ "$(echo $(stg unapplied))" = "" ] &&
73 test $(cat foo1.txt) = "foo1" &&
74 test $(cat foo2.txt) = "foo2" &&
75 test $(cat foo3.txt) = "foo3"
79 'Modify the master patches' \
82 [ "$(echo $(stg applied))" = "p1 p2" ] &&
83 [ "$(echo $(stg unapplied))" = "p3" ] &&
85 echo bar1 >> foo1.txt &&
88 echo bar2 > bar2.txt &&
92 echo bar3 >> foo3.txt &&
94 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
95 [ "$(echo $(stg unapplied))" = "" ] &&
100 test_expect_success \
101 'Synchronise second patch with the master branch' \
103 stg sync -B master p2 &&
104 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
105 [ "$(echo $(stg unapplied))" = "" ] &&
106 test $(cat bar2.txt) = "bar2"
109 test_expect_failure \
110 'Synchronise the first two patches with the master branch (to fail)' \
112 stg sync -B master -a
115 test_expect_success \
116 'Restore the stack status after the failed sync' \
118 [ "$(echo $(stg applied))" = "p1" ] &&
119 [ "$(echo $(stg unapplied))" = "p2 p3" ] &&
123 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
124 [ "$(echo $(stg unapplied))" = "" ]
127 test_expect_failure \
128 'Synchronise the third patch with the exported series (to fail)' \
130 stg sync -s patches-master/series p3
133 test_expect_success \
134 'Restore the stack status after the failed sync' \
136 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
137 [ "$(echo $(stg unapplied))" = "" ] &&
140 [ "$(echo $(stg applied))" = "p1 p2 p3" ] &&
141 [ "$(echo $(stg unapplied))" = "" ]