summaryrefslogtreecommitdiff
path: root/test/script/run.et
blob: b6dc1b03037d28f156f2a9aaff6fb195a7f050ca (plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
module run

asset scripts:
    path: ../asset/run

def expect_result from p of job result result:
    let dummy = job == ""
    expect from p:
        /job-start $job/
        /job-finish $job ([a-z]+)/ capture done
    guard (done == result)

def expect_success from p of job:
    expect_result from p of job result "done"


test RunWithouRepo:
    node n
    spawn on n as p args [ "${scripts.path}/norepo-basic.yaml", "run", "success", "failure" ]
    expect_result from p:
        of "success" result "done"
        of "failure" result "failed"
    expect /(.*)/ from p capture done
    guard (done == "run-finish")


test RunWithRepo:
    node n
    shell on n as git_init:
        git -c init.defaultBranch=master init -q
        git -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit'
        git rev-parse HEAD
        cp "${scripts.path}/repo-basic.yaml" minici.yaml
        git add minici.yaml
        git -c user.name=test -c user.email=test commit -q -m 'basic1'
        git rev-parse HEAD^{tree}
        cp "${scripts.path}/repo-basic2.yaml" minici.yaml
        git add minici.yaml
        git -c user.name=test -c user.email=test commit -q -m 'basic1'
        git rev-parse HEAD
        git rev-parse HEAD^{tree}

    expect /([0-9a-f]+)/ from git_init capture c0
    expect /([0-9a-f]+)/ from git_init capture t1
    expect /([0-9a-f]+)/ from git_init capture c2
    expect /([0-9a-f]+)/ from git_init capture t2

    local:
        spawn on n as p args [ "run", "--range=$c0..$c2" ]
        expect_result from p:
            of "$t1.success" result "done"
            of "$t1.failure" result "failed"

            of "$t2.success" result "done"
            of "$t2.failure" result "failed"
            of "$t2.third" result "done"
            of "$t2.fourth" result "done"

        expect /(.*)/ from p capture done
        guard (done == "run-finish")

    local:
        spawn on n as p args [ "./minici.yaml", "run", "--range=$c0..$c2" ]
        expect_result from p:
            of "$t1.success" result "done"
            of "$t1.failure" result "failed"
            of "$t1.third" result "done"
            of "$t1.fourth" result "done"

            of "$t2.success" result "done"
            of "$t2.failure" result "failed"
            of "$t2.third" result "done"
            of "$t2.fourth" result "done"

        expect /(.*)/ from p capture done
        guard (done == "run-finish")


test RunExternalRepo:
    node n
    shell on n as git_init:
        mkdir -p first/subdir
        git -C first -c init.defaultBranch=master init -q
        git -C first -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit'
        touch first/subdir/file
        git -C first add subdir
        git -C first -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C first rev-parse HEAD^{tree}
        git -C first rev-parse HEAD:subdir

        mkdir -p second/sub
        git -C second -c init.defaultBranch=master init -q
        git -C second -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit'
        touch second/sub/other
        git -C second add sub
        git -C second -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C second rev-parse HEAD^{tree}
        git -C second rev-parse HEAD:sub

        mkdir -p main
        git -C main -c init.defaultBranch=master init -q
        git -C main -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit'
        cp "${scripts.path}/external.yaml" main/minici.yaml
        git -C main add minici.yaml
        git -C main -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C main rev-parse HEAD^{tree}

    expect /([0-9a-f]+)/ from git_init capture first_root
    expect /([0-9a-f]+)/ from git_init capture first_subtree
    expect /([0-9a-f]+)/ from git_init capture second_root
    expect /([0-9a-f]+)/ from git_init capture second_subtree
    expect /([0-9a-f]+)/ from git_init capture main_root

    # Explicit jobfile outside of any git repo
    local:
        spawn on n as p args [ "--repo=first:./first", "--repo=second:./second", "${scripts.path}/external.yaml", "run", "single", "multiple", "combine" ]
        for job in [ "single.$first_root", "multiple.$first_subtree.$second_subtree", "combine.$first_root.$second_subtree" ]:
            expect_success from p of job

        expect /(.*)/ from p capture done
        guard (done == "run-finish")

    # Explicit jobfile within a git repo
    local:
        spawn on n as p args [ "--repo=first:./first", "--repo=second:./second", "${scripts.path}/external.yaml", "run", "single" ]
        expect_success from p of "single.$first_root"
        expect /(.*)/ from p capture done
        guard (done == "run-finish")

    # Implicit jobfile within a git repo
    local:
        spawn on n as p args [ "--repo=first:./first", "--repo=second:./second", "./main", "run", "HEAD^..HEAD" ]
        for job in [ "single.$first_root", "multiple.$first_subtree.$second_subtree", "combine.$first_root.$second_subtree" ]:
            expect_success from p of "$main_root.$job"

        expect /(.*)/ from p capture done
        guard (done == "run-finish")


test RunExplicitJob:
    node n
    shell on n as git_init:
        mkdir -p main
        git -C main -c init.defaultBranch=master init -q
        cp "${scripts.path}/explicit.yaml" main/minici.yaml
        git -C main add minici.yaml
        git -C main -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit'

        mkdir -p main/subdir

        touch main/subdir/a
        git -C main add subdir
        git -C main -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C main rev-parse HEAD^{commit}
        git -C main rev-parse HEAD^{tree}

        touch main/subdir/b
        git -C main add subdir
        git -C main -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C main rev-parse HEAD^{tree}

        rm main/subdir/a
        rm main/subdir/b
        touch main/subdir/c
        git -C main add subdir
        git -C main -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C main rev-parse HEAD^{tree}

        touch main/subdir/d
        git -C main add subdir
        git -C main -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C main rev-parse HEAD^{tree}

    expect /([0-9a-f]+)/ from git_init capture c1
    expect /([0-9a-f]+)/ from git_init capture t1
    expect /([0-9a-f]+)/ from git_init capture t2
    expect /([0-9a-f]+)/ from git_init capture t3
    expect /([0-9a-f]+)/ from git_init capture t4

    local:
        spawn on n as p args [ "./main", "run", "$c1.build" ]
        expect_success from p of "$t1.build"
        expect /(.*)/ from p capture done
        guard (done == "run-finish")
    local:
        spawn on n as p args [ "./main", "extract", "$c1.build.out", "list" ]
    local:
        shell on n as s:
            cat list
            rm list
        expect /a/ from s

    local:
        spawn on n as p args [ "./main", "run", "$t2.build" ]
        expect_success from p of "$t2.build"
        expect /(.*)/ from p capture done
        guard (done == "run-finish")
    local:
        spawn on n as p args [ "./main", "extract", "$t2.build.out", "list" ]
    local:
        shell on n as s:
            cat list
            rm list
        expect /a b/ from s

    local:
        spawn on n as p args [ "./main", "run", "HEAD^.build" ]
        expect_success from p of "$t3.build"
        expect /(.*)/ from p capture done
        guard (done == "run-finish")
    local:
        spawn on n as p args [ "./main", "extract", "HEAD^.build.out", "list" ]
    local:
        shell on n as s:
            cat list
            rm list
        expect /c/ from s

    local:
        spawn on n as p args [ "./main", "run", "HEAD.build" ]
        expect_success from p of "$t4.build"
        expect /(.*)/ from p capture done
        guard (done == "run-finish")
    local:
        spawn on n as p args [ "./main", "extract", "HEAD.build.out", "list" ]
    local:
        shell on n as s:
            cat list
            rm list
        expect /c d/ from s