@@ -111,53 +111,55 @@ test-append() {
111
111
}
112
112
113
113
test-usage () {
114
- # no args
115
- set +o errexit
116
-
117
- time-tool; status=$?
114
+ local status
115
+ nq-run status \
116
+ time-tool
118
117
nq-assert $status -eq 2
119
118
120
- time-tool --output; status=$?
119
+ nq-run status \
120
+ time-tool --output
121
121
nq-assert $status -eq 2
122
122
123
- time-tool sleep 0.1
124
- time-tool --append sleep 0.1; status= $?
123
+ nq-run status \
124
+ time-tool sleep 0.1
125
125
nq-assert $status -eq 0
126
126
127
- set -o errexit
127
+ nq-run status \
128
+ time-tool --append sleep 0.1
129
+ nq-assert $status -eq 0
128
130
}
129
131
130
132
test-bad-tsv-chars () {
133
+ local status
131
134
local out=_tmp/time2.tsv
132
135
rm -f $out
133
136
134
- set +o errexit
135
-
136
137
# Newline should fail
137
- time-tool --tsv -o $out --field $' \n ' -- sleep 0.001; status=$?
138
- nq-assert $status -eq 1
138
+ nq-run status \
139
+ time-tool --tsv -o $out --field $' \n ' -- sleep 0.001
140
+ nq-assert $status = 1
139
141
140
142
# Tab should fail
141
- time-tool --tsv -o $out --field $' \t ' -- sleep 0.001; status=$?
142
- nq-assert $status -eq 1
143
+ nq-run status \
144
+ time-tool --tsv -o $out --field $' \t ' -- sleep 0.001
145
+ nq-assert $status = 1
143
146
144
147
# Quote should fail
145
- time-tool --tsv -o $out --field ' "' -- sleep 0.001; status=$?
146
- nq-assert $status -eq 1
148
+ nq-run status \
149
+ time-tool --tsv -o $out --field ' "' -- sleep 0.001
150
+ nq-assert $status = 1
147
151
148
152
# Backslash is OK
149
- time-tool --tsv -o $out --field ' \' -- sleep 0.001; status=$?
150
- nq-assert $status -eq 0
153
+ nq-run status \
154
+ time-tool --tsv -o $out --field ' \' -- sleep 0.001
155
+ nq-assert $status = 0
151
156
152
157
# Space is OK, although canonical form would be " "
153
- time-tool --tsv -o $out --field ' ' -- sleep 0.001; status=$?
154
- nq-assert $status -eq 0
155
-
156
- set -o errexit
158
+ nq-run status \
159
+ time-tool --tsv -o $out --field ' ' -- sleep 0.001
160
+ nq-assert $status = 0
157
161
158
162
cat $out
159
-
160
- echo $' OK\t test-bad-tsv-chars'
161
163
}
162
164
163
165
test-stdout () {
@@ -218,34 +220,38 @@ test-maxrss() {
218
220
}
219
221
220
222
test-print-header () {
221
- set +o errexit
223
+ local status
222
224
223
225
# no arguments allowed
224
- time-tool --tsv --print-header foo bar
225
- nq-assert $? -eq 2
226
+ nq-run status \
227
+ time-tool --tsv --print-header foo bar
228
+ nq-assert $status = 2
226
229
227
- time-tool --tsv --print-header --field name
228
- nq-assert $? -eq 0
230
+ nq-run status \
231
+ time-tool --tsv --print-header --field name
232
+ nq-assert $status = 0
229
233
230
- time-tool --tsv --print-header --rusage --field name
231
- nq-assert $? -eq 0
234
+ nq-run status \
235
+ time-tool --tsv --print-header --rusage --field name
236
+ nq-assert $status = 0
232
237
233
- time-tool --print-header --rusage --field foo --field bar
234
- nq-assert $? -eq 0
238
+ nq-run status \
239
+ time-tool --print-header --rusage --field foo --field bar
240
+ nq-assert $status = 0
235
241
236
- time-tool -o _tmp/time-test-1 \
242
+ nq-run status \
243
+ time-tool -o _tmp/time-test-1 \
237
244
--print-header --rusage --stdout DUMMY --tsv --field a --field b
238
- nq-assert $? -eq 0
245
+ nq-assert $status = 0
239
246
240
- # set -x
241
247
head _tmp/time-test-1
248
+
249
+ echo OK
242
250
}
243
251
244
252
test-time-helper () {
245
- set +o errexit
246
-
253
+ local status
247
254
local tmp=_tmp/time-helper.txt
248
-
249
255
local th=_devbuild/bin/time-helper
250
256
251
257
# Make some work show up
@@ -254,26 +260,32 @@ test-time-helper() {
254
260
echo ' will be overwritten' > $tmp
255
261
cat $tmp
256
262
257
- $th
258
- nq-assert $? -ne 0 # it's 1, but could be 2
263
+ nq-run status \
264
+ $th
265
+ nq-assert $status ! = 0 # it's 1, but could be 2
259
266
260
- $th /bad
261
- nq-assert $? -eq 1
267
+ nq-run status \
268
+ $th /bad
269
+ nq-assert $status = 1
262
270
263
- $th -o $tmp -d $' \t ' -x -e -- sh -c " $cmd "
264
- nq-assert $? -eq 42
271
+ nq-run status \
272
+ $th -o $tmp -d $' \t ' -x -e -- sh -c " $cmd "
273
+ nq-assert $status = 42
265
274
cat $tmp
266
275
echo
267
276
268
277
# Now append
269
- $th -o $tmp -a -d , -x -e -U -S -M -- sh -c " $cmd "
270
- nq-assert $? -eq 42
278
+
279
+ nq-run status \
280
+ $th -o $tmp -a -d , -x -e -U -S -M -- sh -c " $cmd "
281
+ nq-assert $status = 42
271
282
cat $tmp
272
283
echo
273
284
274
285
# Error case
275
- $th -q
276
- nq-assert $? -eq 2
286
+ nq-run status \
287
+ $th -q
288
+ nq-assert $status -eq 2
277
289
}
278
290
279
291
test-time-tsv () {
@@ -283,12 +295,8 @@ test-time-tsv() {
283
295
rm -f -v $out
284
296
285
297
# Similar to what soil/worker.sh does
286
- set +o errexit
287
- time-tsv -o $out --append -- zz
288
- status=$?
289
- set -o errexit
290
-
291
- echo status=$status
298
+ nq-run status \
299
+ time-tsv -o $out --append -- zz
292
300
nq-assert $status -eq 1
293
301
294
302
cat $out
0 commit comments