@@ -223,6 +223,9 @@ spec = do
223
223
224
224
describe " ExitCodeException" $ do
225
225
it " Show" $ do
226
+ -- Note that the `show` output ends with a newline, so functions
227
+ -- like `print` will output an extra blank line at the end of the
228
+ -- output.
226
229
let exitCodeException =
227
230
ExitCodeException
228
231
{ eceExitCode = ExitFailure 1
@@ -238,7 +241,7 @@ spec = do
238
241
++ " Copied OK\n "
239
242
++ " \n "
240
243
++ " Standard error:\n "
241
- ++ " Uh oh!"
244
+ ++ " Uh oh!\n "
242
245
243
246
it " Show only stdout" $ do
244
247
let exitCodeException =
@@ -253,7 +256,7 @@ spec = do
253
256
++ " Raw command: show-puppy\n "
254
257
++ " \n "
255
258
++ " Standard output:\n "
256
- ++ " No puppies found???"
259
+ ++ " No puppies found???\n "
257
260
258
261
it " Show only stderr" $ do
259
262
let exitCodeException =
@@ -266,17 +269,12 @@ spec = do
266
269
show exitCodeException `shouldBe`
267
270
" Received ExitFailure 1 when running\n "
268
271
++ " Raw command: show-puppy\n "
269
- ++ " \n "
270
272
++ " Standard error:\n "
271
- ++ " No puppies found???"
272
-
273
- it " Show trims stdout/stderr" $ do
274
- -- This keeps the `Show` output looking nice regardless of how many
275
- -- newlines (if any) the command outputs.
276
- --
277
- -- This also makes sure that the `Show` output doesn't end with a
278
- -- spurious trailing newline, making it easier to compose `Show`
279
- -- instances together.
273
+ ++ " No puppies found???\n "
274
+
275
+ it " Show does not trim stdout/stderr" $ do
276
+ -- This looks weird, and I think it would be better to strip the
277
+ -- whitespace from the output.
280
278
let exitCodeException =
281
279
ExitCodeException
282
280
{ eceExitCode = ExitFailure 1
@@ -289,12 +287,12 @@ spec = do
289
287
++ " Raw command: detect-doggies\n "
290
288
++ " \n "
291
289
++ " Standard output:\n "
292
- ++ " puppy \n "
290
+ ++ " \n\n puppy \n\n \n "
293
291
++ " \n "
294
292
++ " Standard error:\n "
295
- ++ " doggy "
293
+ ++ " \t \n doggy \n \t\n "
296
294
297
- it " Show displays correctly with no newlines in stdout" $ do
295
+ it " Show displays weirdly with no newlines in stdout" $ do
298
296
-- Sometimes, commands don't output _any_ newlines!
299
297
let exitCodeException =
300
298
ExitCodeException
@@ -309,3 +307,22 @@ spec = do
309
307
++ " \n "
310
308
++ " Standard output:\n "
311
309
++ " puppy"
310
+
311
+ it " Show displays weirdly with no newlines in stdout or stderr" $ do
312
+ -- If the stderr isn't empty and stdout doesn't end with a newline,
313
+ -- the blank line between the two sections disappears.
314
+ let exitCodeException =
315
+ ExitCodeException
316
+ { eceExitCode = ExitFailure 1
317
+ , eceProcessConfig = proc " detect-doggies" []
318
+ , eceStdout = fromString " puppy"
319
+ , eceStderr = fromString " doggy"
320
+ }
321
+ show exitCodeException `shouldBe`
322
+ " Received ExitFailure 1 when running\n "
323
+ ++ " Raw command: detect-doggies\n "
324
+ ++ " \n "
325
+ ++ " Standard output:\n "
326
+ ++ " puppy\n "
327
+ ++ " Standard error:\n "
328
+ ++ " doggy"
0 commit comments