Skip to content

Commit f123254

Browse files
hasufellBodigrim
authored andcommitted
Add regression test for putEnv wrt #68
1 parent dd1f0aa commit f123254

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/PutEnv001.hs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
{-# OPTIONS_GHC -O0 -Wno-name-shadowing #-}
3+
4+
module Main (main) where
5+
6+
import Data.String ( fromString )
7+
import System.Mem
8+
import System.Posix.Env.ByteString
9+
import Test.Tasty
10+
import Test.Tasty.HUnit
11+
12+
-- test regression of incorrect 'free': https://github.com/haskell/unix/issues/68#issue-170072591
13+
main :: IO ()
14+
main = do
15+
putEnv "foo=bar"
16+
defaultMain $ testGroup "All" [ test ]
17+
18+
test :: TestTree
19+
test = testCase "putEnv" $ do
20+
performMinorGC
21+
env <- System.Posix.Env.ByteString.getEnv (fromString "foo")
22+
performMinorGC
23+
print env
24+
env <- System.Posix.Env.ByteString.getEnv (fromString "foo")
25+
performMinorGC
26+
print env
27+
env <- System.Posix.Env.ByteString.getEnv (fromString "foo")
28+
performMinorGC
29+
print env
30+
env <- System.Posix.Env.ByteString.getEnv (fromString "foo")
31+
print env
32+
env @?= Just (fromString "bar")

unix.cabal

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,11 @@ test-suite Terminal
242242
default-language: Haskell2010
243243
build-depends: base, unix, tasty-hunit
244244
ghc-options: -Wall
245+
246+
test-suite PutEnv001
247+
hs-source-dirs: tests
248+
main-is: PutEnv001.hs
249+
type: exitcode-stdio-1.0
250+
default-language: Haskell2010
251+
build-depends: base, unix, tasty, tasty-hunit
252+
ghc-options: -Wall -with-rtsopts=-V0 -O0

0 commit comments

Comments
 (0)