diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2017-12-13 23:00:21 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2018-01-18 14:10:26 +0100 |
commit | f40e568f2be06b9254b8b5a956319c6eafd13997 (patch) | |
tree | 357f407c57dcbbba795b262da3cbeab1283555fa /tests/GhcSession.hs | |
parent | aba389ec640eb4f6254b6828621c689c638ab791 (diff) |
Bring in needsBuildOuput query, for indefinite modules
Diffstat (limited to 'tests/GhcSession.hs')
-rw-r--r-- | tests/GhcSession.hs | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs index 127dd8e..e8d3977 100644 --- a/tests/GhcSession.hs +++ b/tests/GhcSession.hs @@ -32,12 +32,12 @@ main = do topdir <- getCurrentDirectory res <- mapM (setup topdir test) $ case args of [] -> [ - -- ("tests/exelib" , parseVer "1.10") - -- , ("tests/exeintlib", parseVer "2.0") - -- , ("tests/fliblib" , parseVer "2.0") - ("tests/bkpregex" , parseVer "2.0") + -- ("tests/exelib" , parseVer "1.10",False) + -- , ("tests/exeintlib", parseVer "2.0", False) + -- , ("tests/fliblib" , parseVer "2.0", False) + ("tests/bkpregex" , parseVer "2.0", True) ] - xs -> map (,parseVer "0") xs + xs -> map (,parseVer "0",False) xs if any (==False) $ concat res then exitFailure @@ -52,8 +52,8 @@ cabalInstallBuiltinCabalVersion = parseVer . trim <$> readProcess "cabal" ["act-as-setup", "--", "--numeric-version"] "" -setup :: FilePath -> (FilePath -> IO [Bool]) -> (FilePath, Version) -> IO [Bool] -setup topdir act (srcdir, min_cabal_ver) = do +setup :: FilePath -> (FilePath -> IO [Bool]) -> (FilePath, Version,Bool) -> IO [Bool] +setup topdir act (srcdir, min_cabal_ver,invokeCabalBuild) = do ci_ver <- cabalInstallVersion c_ver <- cabalInstallBuiltinCabalVersion let mreason @@ -70,13 +70,19 @@ setup topdir act (srcdir, min_cabal_ver) = do putStrLn $ "Skipping test '" ++ srcdir ++ "' because " ++ reason ++ "." return [] Nothing -> do - withSystemTempDirectory "cabal-helper.ghc-session.test" $ \dir -> do + -- withSystemTempDirectory "cabal-helper.ghc-session.test" $ \dir -> do + let dir = "/tmp/xxxx" + e <- doesDirectoryExist dir + when e $ removeDirectoryRecursive dir + createDirectoryIfMissing True dir + do setCurrentDirectory $ topdir </> srcdir run "cabal" [ "sdist", "--output-dir", dir ] setCurrentDirectory dir run "cabal" [ "configure" ] --- run "cabal" [ "build" ] + when invokeCabalBuild $ do + run "cabal" [ "build" ] act dir where @@ -89,21 +95,20 @@ setup topdir act (srcdir, min_cabal_ver) = do test :: FilePath -> IO [Bool] test dir = do let qe = mkQueryEnv dir (dir </> "dist") + let packageDir = dir </> "dist" </> "package.conf.inplace" + cs <- runQuery qe $ components $ (,,,) <$> entrypoints <.> ghcOptions <.> needsBuildOutput + forM cs $ \(ep, opts, nb, cn) -> do - cs <- runQuery qe $ components $ (,) <$> entrypoints - putStrLn "\n--------------------------------eps-----------------------------" - forM cs $ \(ep, cn) -> do - putStrLn $ "\n" ++ show (ep,cn) - putStrLn "\n--------------------------------eps end-----------------------------" - - cs <- runQuery qe $ components $ (,,) <$> entrypoints <.> ghcOptions - putStrLn "\n--------------------------------components-----------------------------" - forM cs $ \(ep, opts, cn) -> do - putStrLn $ "\n" ++ show cn ++ ": " ++ show opts - putStrLn "\n--------------------------------components end-------------------------" - forM cs $ \(ep, opts, cn) -> do - let opts' = "-Werror" : opts - let sopts = intercalate " " $ map formatArg $ "ghc" : opts' + putStrLn $ "\n" ++ show cn ++ ":::: " ++ show nb + + exists <- doesDirectoryExist packageDir + let opts' = if exists + then ("-package-db " ++ packageDir) : "-Werror" : opts + else "-Werror" : opts + + -- let opts' = "-Werror" : opts + -- let opts' = "-v 3" : "-Werror" : opts + let sopts = intercalate " " $ map formatArg $ "\nghc" : opts' putStrLn $ "\n" ++ show cn ++ ": " ++ sopts hFlush stdout compileModule ep opts' @@ -115,6 +120,8 @@ test dir = do compileModule :: ChEntrypoint -> [String] -> IO Bool compileModule ep opts = do + putStrLn $ "compiling:" ++ show ep + E.handle (\(ec :: ExitCode) -> print ec >> return False) $ do #if __GLASGOW_HASKELL__ <= 704 |