File: t2000-sync.sh

package info (click to toggle)
stgit 0.19-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,748 kB
  • sloc: python: 10,558; sh: 5,739; lisp: 2,678; makefile: 142; perl: 42
file content (144 lines) | stat: -rwxr-xr-x 4,058 bytes parent folder | download | duplicates (3)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
#
# Copyright (c) 2006 Catalin Marinas
#

test_description='Test the sync command.'

. ./test-lib.sh

test_expect_success \
    'Initialize the StGIT repository' \
    '
    stg init
    '

test_expect_success \
    'Create some patches' \
    '
    stg new p1 -m p1 &&
    echo foo1 > foo1.txt &&
    stg add foo1.txt &&
    stg refresh &&
    stg new p2 -m p2 &&
    echo foo2 > foo2.txt &&
    stg add foo2.txt &&
    stg refresh &&
    stg new p3 -m p3 &&
    echo foo3 > foo3.txt &&
    stg add foo3.txt &&
    stg refresh &&
    stg export &&
    stg pop &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "p3" ]
    '

test_expect_success \
    'Create a branch with empty patches' \
    '
    stg branch -c foo {base} &&
    stg new p1 -m p1 &&
    stg new p2 -m p2 &&
    stg new p3 -m p3 &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
    '

test_expect_success \
    'Synchronise second patch with the master branch' \
    '
    stg sync -B master p2 &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
    test "$(cat foo2.txt)" = "foo2"
    '

test_expect_success \
    'Synchronise the first two patches with the master branch' \
    '
    stg sync -B master -a &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
    test "$(cat foo1.txt)" = "foo1" &&
    test "$(cat foo2.txt)" = "foo2"
    '

test_expect_success \
    'Synchronise all the patches with the exported series' \
    '
    stg sync -s patches-master/series -a &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
    test "$(cat foo1.txt)" = "foo1" &&
    test "$(cat foo2.txt)" = "foo2" &&
    test "$(cat foo3.txt)" = "foo3"
    '

test_expect_success \
    'Modify the master patches' \
    '
    stg branch master &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "p3" ] &&
    stg goto p1 &&
    echo bar1 >> foo1.txt &&
    stg refresh &&
    stg goto p2 &&
    echo bar2 > bar2.txt &&
    stg add bar2.txt &&
    stg refresh &&
    stg goto p3 &&
    echo bar3 >> foo3.txt &&
    stg refresh &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
    stg export &&
    stg branch foo
    '

test_expect_success \
    'Synchronise second patch with the master branch' \
    '
    stg sync -B master p2 &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
    test "$(cat bar2.txt)" = "bar2"
    '

test_expect_success \
    'Synchronise the first two patches with the master branch (to fail)' \
    '
    conflict_old stg sync -B master -a
    '

test_expect_success \
    'Restore the stack status after the failed sync' \
    '
    [ "$(echo $(stg series --applied --noprefix))" = "p1" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "p2 p3" ] &&
    stg add --update &&
    stg refresh &&
    stg goto p3
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
    '

test_expect_success \
    'Synchronise the third patch with the exported series (to fail)' \
    '
    conflict_old stg sync -s patches-master/series p3
    '

test_expect_success \
    'Restore the stack status after the failed sync' \
    '
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
    stg add --update &&
    stg refresh &&
    [ "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
    '

test_done