mdoc-0.1.1.0: test/Mdoc/Gen/ExitStatusSpec.hs
-- |
--
-- Module : Mdoc.Gen.ExitStatusSpec
-- Copyright : (c) 2026 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : pbrisbin@gmail.com
-- Stability : experimental
-- Portability : POSIX
module Mdoc.Gen.ExitStatusSpec
( spec
) where
import Mdoc.Prelude
import Mdoc.Gen.ExitStatus
import Mdoc.Test.Render
import Test.Hspec
spec :: Spec
spec = do
describe "renderExitStatuses" $ do
it "can re-create Ex -std format" $ do
let nzs = pure $ NonZeroStatus ">0" "if an error occurs"
renderExitStatuses nzs
`shouldRender` [ "The"
, ".Nm"
, "utility exits 0 on success,"
, "and >0 if an error occurs."
]
it "is flexible to more non-zero statuses" $ do
-- https://github.com/ocharles/weeder#exit-codes
let nzs =
NonZeroStatus "228" "if one or more weeds found"
:| [ NonZeroStatus "1" "for generic failing exit code"
, NonZeroStatus "2" "due to failure to read HIE file due to GHC version mismatch"
, NonZeroStatus "3" "due to failure to parse config file"
, NonZeroStatus "4" "when no HIE files found"
]
renderExitStatuses nzs
`shouldRender` [ "The"
, ".Nm"
, "utility exits 0 on success,"
, "228 if one or more weeds found,"
, "1 for generic failing exit code,"
, "2 due to failure to read HIE file due to GHC version mismatch,"
, "3 due to failure to parse config file,"
, "and 4 when no HIE files found."
]