Skip to content

Commit caedd61

Browse files
committed
Testesuite driver fixe
1 parent cff57dc commit caedd61

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

test/golden/T164/T164.hdb-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$HDB cli Main.hs -v 0 < T164.hdb-stdin
1+
$HDB Main.hs -v 0 < T164.hdb-stdin

test/golden/T61/T61.hdb-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$HDB cli x/Main.hs < T61.hdb-stdin
1+
$HDB x/Main.hs < T61.hdb-stdin

test/golden/T83/T83.hdb-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$HDB cli Main.hs -v 0 < T83.hdb-stdin
1+
$HDB Main.hs -v 0 < T83.hdb-stdin
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
$HDB cli prog/Main.hs < exceptions-multiple.hdb-stdin
3+
$HDB prog/Main.hs < exceptions-multiple.hdb-stdin
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
$HDB cli prog/Main.hs < exceptions-uncaught.hdb-stdin
3+
$HDB prog/Main.hs < exceptions-uncaught.hdb-stdin
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
$HDB cli prog/Main.hs < exceptions.hdb-stdin
3+
$HDB prog/Main.hs < exceptions.hdb-stdin

test/haskell/Main.hs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import System.FilePath
1212
import System.IO.Temp
1313
import System.Exit
1414
import System.IO
15+
import System.Environment
1516
import Control.Exception
1617

1718
import Test.Tasty
@@ -24,13 +25,18 @@ import Test.Utils
2425

2526
main :: IO ()
2627
main = do
27-
goldens <- mapM (mkGoldenTest False) =<< findByExtension [".hdb-test"] "test/golden"
28+
env <- getEnvironment
29+
let mkTest = mkGoldenTest False env
30+
golden_tests <- findByExtension [".hdb-test"] "test/golden"
31+
default_goldens <- mapM (mkTest "") golden_tests
32+
intinterp_goldens <- mapM (mkTest "--internal-interpreter") golden_tests
2833
defaultMain $
2934
#ifdef mingw32_HOST_OS
3035
ignoreTestBecause "Testsuite is not enabled on Windows (#149)" $
3136
#endif
3237
testGroup "Tests"
33-
[ testGroup "Golden tests" goldens
38+
[ testGroup "Golden tests" default_goldens
39+
, testGroup "Golden tests (--internal-interpreter)" intinterp_goldens
3440
, testGroup "Unit tests" unitTests
3541
]
3642

@@ -41,24 +47,21 @@ unitTests =
4147

4248
-- | Receives as an argument the path to the @*.hdb-test@ which contains the
4349
-- shell invocation for running
44-
mkGoldenTest :: Bool -> FilePath -> IO TestTree
45-
mkGoldenTest keepTmpDirs path = do
50+
mkGoldenTest :: Bool -> [(String, String)] -> FilePath -> String -> IO TestTree
51+
mkGoldenTest keepTmpDirs inheritedEnv flags path = do
4652
let testName = takeBaseName path
4753
let goldenPath = replaceExtension path ".hdb-stdout"
48-
return $
49-
testGroup testName
50-
[ goldenVsStringComparing "(default)" goldenPath (action "")
51-
, goldenVsStringComparing "with --internal-interpreter" goldenPath (action "--internal-interpreter")
52-
]
54+
return $ goldenVsStringComparing testName goldenPath action
5355
where
54-
action :: String -> IO LBS.ByteString
55-
action flags = do
56+
action :: IO LBS.ByteString
57+
action = do
5658
script <- readFile path
5759
withHermeticDir keepTmpDirs (takeDirectory path) $ \test_dir -> do
5860
(_, Just hout, _, p)
5961
<- P.createProcess (P.shell script)
6062
{ P.cwd = Just test_dir, P.std_out = P.CreatePipe
61-
, P.env = Just
63+
, P.env = Just $
64+
inheritedEnv ++
6265
[ ("HDB", "hdb " ++ flags)
6366
]
6467
}

0 commit comments

Comments
 (0)