Skip to content

Commit c05ee1f

Browse files
9999yearssol
andcommitted
Rename tests
Co-authored-by: Simon Hengel <[email protected]>
1 parent 189aa42 commit c05ee1f

File tree

1 file changed

+76
-72
lines changed

1 file changed

+76
-72
lines changed

test/System/Process/TypedSpec.hs

Lines changed: 76 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -171,28 +171,28 @@ spec = do
171171
let expected = "Raw command: podman exec --detach-keys \"\" ctx bash"
172172
in show (proc "podman" ["exec", "--detach-keys", "", "ctx", "bash"]) `shouldBe` expected
173173

174-
describe "ProcessConfig" $ do
175-
it "Show shell-escapes arguments" $ do
174+
describe "Show ProcessConfig" $ do
175+
it "shell-escapes arguments" $ do
176176
let processConfig = proc "echo" ["a", "", "\"b\"", "'c'", "\\d"]
177177
-- I promise this escaping behavior is correct; paste it into GHCi
178178
-- `putStrLn` and then paste it into `sh` to verify.
179179
show processConfig `shouldBe`
180180
"Raw command: echo a \"\" \"\\\"b\\\"\" \"'c'\" \"\\\\d\""
181181

182-
it "Show displays working directory" $ do
182+
it "displays working directory" $ do
183183
let processConfig = setWorkingDir "puppy/doggy" $ proc "true" []
184184
show processConfig `shouldBe`
185185
"Raw command: true\n"
186186
++ "Run from: puppy/doggy"
187187

188-
it "Show displays environment (1 variable)" $ do
188+
it "displays environment (1 variable)" $ do
189189
let processConfig = setEnv [("PUPPY", "DOGGY")] $ proc "true" []
190190
show processConfig `shouldBe`
191191
"Raw command: true\n"
192192
++ "Environment:\n"
193193
++ "PUPPY=DOGGY"
194194

195-
it "Show displays environment (multiple variables)" $ do
195+
it "displays environment (multiple variables)" $ do
196196
let processConfig =
197197
setEnv [ ("PUPPY", "DOGGY")
198198
, ("SOUND", "AWOO")
@@ -206,7 +206,7 @@ spec = do
206206
++ "SOUND=AWOO\n"
207207
++ "HOWLING=RIGHT_NOW"
208208

209-
it "Show displays working directory and environment" $ do
209+
it "displays working directory and environment" $ do
210210
let processConfig =
211211
setEnv [ ("PUPPY", "DOGGY")
212212
, ("SOUND", "AWOO")
@@ -221,8 +221,8 @@ spec = do
221221
++ "SOUND=AWOO"
222222

223223

224-
describe "ExitCodeException" $ do
225-
it "Show" $ do
224+
describe "Show ExitCodeException" $ do
225+
it "shows ExitCodeException" $ do
226226
-- Note that the `show` output ends with a newline, so functions
227227
-- like `print` will output an extra blank line at the end of the
228228
-- output.
@@ -243,36 +243,38 @@ spec = do
243243
++ "Standard error:\n"
244244
++ "Uh oh!\n"
245245

246-
it "Show only stdout" $ do
247-
let exitCodeException =
248-
ExitCodeException
249-
{ eceExitCode = ExitFailure 1
250-
, eceProcessConfig = proc "show-puppy" []
251-
, eceStdout = fromString "No puppies found???\n"
252-
, eceStderr = fromString ""
253-
}
254-
show exitCodeException `shouldBe`
255-
"Received ExitFailure 1 when running\n"
256-
++ "Raw command: show-puppy\n"
257-
++ "\n"
258-
++ "Standard output:\n"
259-
++ "No puppies found???\n"
260-
261-
it "Show only stderr" $ do
262-
let exitCodeException =
263-
ExitCodeException
264-
{ eceExitCode = ExitFailure 1
265-
, eceProcessConfig = proc "show-puppy" []
266-
, eceStdout = fromString ""
267-
, eceStderr = fromString "No puppies found???\n"
268-
}
269-
show exitCodeException `shouldBe`
270-
"Received ExitFailure 1 when running\n"
271-
++ "Raw command: show-puppy\n"
272-
++ "Standard error:\n"
273-
++ "No puppies found???\n"
274-
275-
it "Show does not trim stdout/stderr" $ do
246+
context "without stderr" $ do
247+
it "shows ExitCodeException" $ do
248+
let exitCodeException =
249+
ExitCodeException
250+
{ eceExitCode = ExitFailure 1
251+
, eceProcessConfig = proc "show-puppy" []
252+
, eceStdout = fromString "No puppies found???\n"
253+
, eceStderr = fromString ""
254+
}
255+
show exitCodeException `shouldBe`
256+
"Received ExitFailure 1 when running\n"
257+
++ "Raw command: show-puppy\n"
258+
++ "\n"
259+
++ "Standard output:\n"
260+
++ "No puppies found???\n"
261+
262+
context "without stdout" $ do
263+
it "shows ExitCodeException" $ do
264+
let exitCodeException =
265+
ExitCodeException
266+
{ eceExitCode = ExitFailure 1
267+
, eceProcessConfig = proc "show-puppy" []
268+
, eceStdout = fromString ""
269+
, eceStderr = fromString "No puppies found???\n"
270+
}
271+
show exitCodeException `shouldBe`
272+
"Received ExitFailure 1 when running\n"
273+
++ "Raw command: show-puppy\n"
274+
++ "Standard error:\n"
275+
++ "No puppies found???\n"
276+
277+
it "does not trim stdout/stderr" $ do
276278
-- This looks weird, and I think it would be better to strip the
277279
-- whitespace from the output.
278280
let exitCodeException =
@@ -292,37 +294,39 @@ spec = do
292294
++ "Standard error:\n"
293295
++ "\t \ndoggy\n \t\n"
294296

295-
it "Show displays weirdly with no newlines in stdout" $ do
296-
-- Sometimes, commands don't output _any_ newlines!
297-
let exitCodeException =
298-
ExitCodeException
299-
{ eceExitCode = ExitFailure 1
300-
, eceProcessConfig = proc "detect-doggies" []
301-
, eceStdout = fromString "puppy"
302-
, eceStderr = fromString ""
303-
}
304-
show exitCodeException `shouldBe`
305-
"Received ExitFailure 1 when running\n"
306-
++ "Raw command: detect-doggies\n"
307-
++ "\n"
308-
++ "Standard output:\n"
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"
297+
context "without newlines in stdout" $ do
298+
it "shows ExitCodeException" $ do
299+
-- Sometimes, commands don't output _any_ newlines!
300+
let exitCodeException =
301+
ExitCodeException
302+
{ eceExitCode = ExitFailure 1
303+
, eceProcessConfig = proc "detect-doggies" []
304+
, eceStdout = fromString "puppy"
305+
, eceStderr = fromString ""
306+
}
307+
show exitCodeException `shouldBe`
308+
"Received ExitFailure 1 when running\n"
309+
++ "Raw command: detect-doggies\n"
310+
++ "\n"
311+
++ "Standard output:\n"
312+
++ "puppy"
313+
314+
context "without newlines in stdout or stderr" $ do
315+
it "shows ExitCodeException" $ do
316+
-- If the stderr isn't empty and stdout doesn't end with a newline,
317+
-- the blank line between the two sections disappears.
318+
let exitCodeException =
319+
ExitCodeException
320+
{ eceExitCode = ExitFailure 1
321+
, eceProcessConfig = proc "detect-doggies" []
322+
, eceStdout = fromString "puppy"
323+
, eceStderr = fromString "doggy"
324+
}
325+
show exitCodeException `shouldBe`
326+
"Received ExitFailure 1 when running\n"
327+
++ "Raw command: detect-doggies\n"
328+
++ "\n"
329+
++ "Standard output:\n"
330+
++ "puppy\n"
331+
++ "Standard error:\n"
332+
++ "doggy"

0 commit comments

Comments
 (0)