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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
# Yarn scenario step implementations
This chapter defines the various scenario steps for Yarn so they can
be actually executed. Surprise! You didn't know you were reading a
test suite! If you're only interested in this document as a manual,
you can skip this chapter.
## Checking that the target address is set
IMPLEMENTS GIVEN the (.+) variable is set
env | grep -F "$MATCH_1="
## Git repository setup
Set up git repository. We add a dummy README file so that the
repository has a `master` branch.
IMPLEMENTS GIVEN a minimal project repository in (.+)
git init "$DATADIR/$MATCH_1"
cd "$DATADIR/$MATCH_1"
touch README
git add README
git commit -m "Initial commit"
## Git tagging
Add a tag to a repository.
IMPLEMENTS GIVEN a git tag (\S+) on tip of (\S+) in (\S+)
cd "$DATADIR/$MATCH_3"
git tag -a -m "A git tag" "$MATCH_1" "$MATCH_2"
## Ick file handling
Create an ick file.
IMPLEMENTS GIVEN an ick file (.+).ick containing (.*)
# Expand all $foo references.
expand_env_vars()
{
local temp="$(mktemp)"
printf '#!/bin/sh\ncat <<EOF\n%s' "$1" > "$temp"
sh "$temp"
rm -f "$temp"
}
expand_env_vars "$MATCH_2" > "$DATADIR/$MATCH_1.ick"
## Running Ick
Run ick, capturing its output for later inspection. We run ick in
`$DATADIR` so that relative references in the ick file work.
IMPLEMENTS WHEN user runs ick (.+).ick
cd "$DATADIR"
if ! "$SRCDIR/ick" --no-default-config \
--log "$DATADIR/ick.log" \
--verbose \
"$DATADIR/$MATCH_1.ick" \
> "$DATADIR/ick.stdout" 2> "$DATADIR/ick.stderr"
then
cat "$DATADIR/ick.stdout"
cat "$DATADIR/ick.stderr"
exit 1
fi
Inspect the captured output of the latest ick file.
IMPLEMENTS THEN ick build log for (.+) in (.+) contains "(.+)"
export PROJECT="$MATCH_1"
export STATE="$MATCH_2"
export PATTERN="$MATCH_3"
builds="$DATADIR/$STATE/$PROJECT/builds"
build_log="$(ls "$builds"/*/build.log | tail -n1)"
cat "$build_log"
grep "$PATTERN" "$build_log"
IMPLEMENTS THEN ick build log for (.+) in (.+) doesn't contain "(.+)"
export PROJECT="$MATCH_1"
export STATE="$MATCH_2"
export PATTERN="$MATCH_3"
builds="$DATADIR/$STATE/$PROJECT/builds"
build_log="$(ls "$builds"/*/build.log | tail -n1)"
cat "$build_log"
! grep "$PATTERN" "$build_log"
IMPLEMENTS THEN there is (\d+) build log(s?) for (.+) in (.+)
export COUNT="$MATCH_1"
export PROJECT="$MATCH_3"
export STATE="$MATCH_4"
builds="$DATADIR/$STATE/$PROJECT/builds"
export NUM_BUILDS="$(ls "$builds" | wc -l)"
if [ "$NUM_BUILDS" != "$COUNT" ]
then
echo "Expected $COUNT builds, found $NUM_BUILDS" 1>&2
exit 1
fi
## Creating a git repository
We need a git repository with some source code. It should have a
master branch, which includes at least one file. We'll create a README
file for that. We also add basic Debian packaging, so packages can be
built. Following the author's habit, the Debian packaging goes into
the master branch as well.
IMPLEMENTS GIVEN a source code repository for project (.+) version (.+)
gitdir="$DATADIR/$MATCH_1"
git init "$gitdir"
cd "$gitdir"
echo "This is $MATCH_1" > README
git add README
git commit -m "Add README"
printf '#!/bin/sh\necho hello, world\n' > hello
chmod +x hello
git add hello
git commit -m "Add hello"
mkdir debian
mkdir debian/source
echo '3.0 (quilt)' > debian/source/format
echo Public domain > debian/copyright
echo 9 > debian/compat
echo hello usr/bin > debian/install
dch --create --package "$MATCH_1" --newversion "$MATCH_2" \
"Initial version."
dch -r ''
cat << EOF > debian/control
Source: $MATCH_1
Maintainer: John Doe <john@example.com>
Section: python
Priority: optional
Standards-Version: 3.9.6
Build-Depends: debhelper (>= 7.3.8)
Package: $MATCH_1
Architecture: all
Depends: \${misc:Depends}
Description: this is a test package
Test package is this.
EOF
printf '#!/usr/bin/make -f\n%%:\n\tdh $@\n' > debian/rules
chmod +x debian/rules
git add debian
git commit -m "Add Debian packaging"
Create repository with just upstream code.
IMPLEMENTS GIVEN an upstream source repository for project (\S+)
gitdir="$DATADIR/$MATCH_1"
git init "$gitdir"
cd "$gitdir"
echo "This is $MATCH_1" > README
git add README
git commit -m "Add README"
printf '#!/bin/sh\necho hello, world\n' > hello
chmod +x hello
git add hello
git commit -m "Add hello"
Create a git repository with just Debian packaging files.
IMPLEMENTS GIVEN a packaging repository called (\S+) for project (\S+) version (\S+)
gitdir="$DATADIR/$MATCH_1"
PROJECT="$MATCH_2"
VERSION="$MATCH_3"
git init "$gitdir"
cd "$gitdir"
mkdir source
echo '3.0 (quilt)' > source/format
echo Public domain > copyright
echo 9 > compat
echo hello usr/bin > install
export DEVSCRIPTS_CHECK_DIRNAME_LEVEL=0
dch --create --package "$PROJECT" --newversion "$VERSION" \
-c changelog "Initial version."
dch -c changelog -r ''
cat << EOF > control
Source: $PROJECT
Maintainer: John Doe <john@example.com>
Section: python
Priority: optional
Standards-Version: 3.9.6
Build-Depends: debhelper (>= 7.3.8)
Package: $PROJECT
Architecture: all
Depends: \${misc:Depends}
Description: this is a test package
Test package is this.
EOF
printf '#!/usr/bin/make -f\n%%:\n\tdh $@\n' > rules
chmod +x rules
git add .
git commit -m "Add Debian packaging"
## Running "cleanly"
We need to run the `cleanly` command in various ways. We invoke it
from the Ick source tree, and save the standard output and error, for
later investigation.
IMPLEMENTS WHEN user runs, in (.+), cleanly (.+)
cd "$DATADIR/$MATCH_1"
# Note that we do NOT quote the second match. We let the shell
# parse it as-is. This is necessary to allow multiple arguments.
if ! "$SRCDIR/icklib/cleanly" --no-default-config \
--log "$DATADIR/cleanly.log" \
--results "$DATADIR" $MATCH_2 \
> "$DATADIR/cleanly.stdout" \
2> "$DATADIR/cleanly.stderr"
then
echo ==== stdout ====
cat "$DATADIR/cleanly.stdout"
echo ==== stderr ====
cat "$DATADIR/cleanly.stderr" 1>&2
echo ==== end of stderr ====
exit 1
fi
## Checking "cleanly" output
Check what the output of the latest invocation of `cleanly` was.
IMPLEMENTS THEN the output is "(.*)"
printf "$MATCH_1" | diff - "$DATADIR/cleanly.stdout"
## Checking if a file exists
Does a file exist?
IMPLEMENTS THEN file (.+) exists
ls -a "$DATADIR"
test -e "$DATADIR/$MATCH_1"
## Checking for package files in the APT repository
Does a file with a given basename exist in the APT repository's pool
tree?
IMPLEMENTS THEN the APT repository for (.+)\.ick contains (.+)
find "$DATADIR/$MATCH_1.state"
find "$DATADIR/$MATCH_1.state/debian/pool" \
-type f -name "$MATCH_2" | grep .
|