@@ -12,6 +12,7 @@ import System.FilePath
1212import System.IO.Temp
1313import System.Exit
1414import System.IO
15+ import System.Environment
1516import Control.Exception
1617
1718import Test.Tasty
@@ -24,13 +25,18 @@ import Test.Utils
2425
2526main :: IO ()
2627main = 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