Skip to content

Commit

Permalink
Rename tests
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Hengel <[email protected]>
  • Loading branch information
9999years and sol authored Sep 9, 2024
1 parent 189aa42 commit 56fcb70
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions test/System/Process/TypedSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,28 +171,28 @@ spec = do
let expected = "Raw command: podman exec --detach-keys \"\" ctx bash"
in show (proc "podman" ["exec", "--detach-keys", "", "ctx", "bash"]) `shouldBe` expected

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

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

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

it "Show displays environment (multiple variables)" $ do
it "displays environment (multiple variables)" $ do
let processConfig =
setEnv [ ("PUPPY", "DOGGY")
, ("SOUND", "AWOO")
Expand All @@ -206,7 +206,7 @@ spec = do
++ "SOUND=AWOO\n"
++ "HOWLING=RIGHT_NOW"

it "Show displays working directory and environment" $ do
it "displays working directory and environment" $ do
let processConfig =
setEnv [ ("PUPPY", "DOGGY")
, ("SOUND", "AWOO")
Expand All @@ -221,8 +221,8 @@ spec = do
++ "SOUND=AWOO"


describe "ExitCodeException" $ do
it "Show" $ do
describe "Show ExitCodeException" $ do
it "shows ExitCodeException" $ do
-- Note that the `show` output ends with a newline, so functions
-- like `print` will output an extra blank line at the end of the
-- output.
Expand All @@ -243,7 +243,8 @@ spec = do
++ "Standard error:\n"
++ "Uh oh!\n"

it "Show only stdout" $ do
context "without stderr" $ do
it "shows ExitCodeException" $ do
let exitCodeException =
ExitCodeException
{ eceExitCode = ExitFailure 1
Expand All @@ -258,7 +259,8 @@ spec = do
++ "Standard output:\n"
++ "No puppies found???\n"

it "Show only stderr" $ do
context "without stdout" $ do
it "shows ExitCodeException" $ do
let exitCodeException =
ExitCodeException
{ eceExitCode = ExitFailure 1
Expand All @@ -272,7 +274,7 @@ spec = do
++ "Standard error:\n"
++ "No puppies found???\n"

it "Show does not trim stdout/stderr" $ do
it "does not trim stdout/stderr" $ do
-- This looks weird, and I think it would be better to strip the
-- whitespace from the output.
let exitCodeException =
Expand All @@ -292,7 +294,8 @@ spec = do
++ "Standard error:\n"
++ "\t \ndoggy\n \t\n"

it "Show displays weirdly with no newlines in stdout" $ do
context "without newlines in stdout" $ do
it "shows ExitCodeException" $ do
-- Sometimes, commands don't output _any_ newlines!
let exitCodeException =
ExitCodeException
Expand All @@ -308,7 +311,8 @@ spec = do
++ "Standard output:\n"
++ "puppy"

it "Show displays weirdly with no newlines in stdout or stderr" $ do
context "without newlines in stdout or stderr" $ do
it "shows ExitCodeException" $ do
-- If the stderr isn't empty and stdout doesn't end with a newline,
-- the blank line between the two sections disappears.
let exitCodeException =
Expand Down

0 comments on commit 56fcb70

Please sign in to comment.