Skip to content

Commit

Permalink
add 10 minute timeout to attrpath.tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantm committed Sep 12, 2021
1 parent d4a1c1e commit c2a7a44
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Control.Applicative (many)
import Data.Char (isDigit, isLetter)
import Data.Maybe (fromJust)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Language.Haskell.TH.Env (envQ)
import OurPrelude
import System.Directory (doesDirectoryExist, doesFileExist, listDirectory)
Expand Down Expand Up @@ -67,19 +68,29 @@ hasVersion contents expectedVersion =
isJust $ contents =~ versionRegex expectedVersion

checkTestsBuild :: Text -> IO Bool
checkTestsBuild attrPath =
let args =
checkTestsBuild attrPath = do
let timeout = "10m"
let
args =
[ T.unpack timeout, "nix-build" ] ++
nixBuildOptions
++ [ "-E",
"{ config }: (import ./. { inherit config; })."
++ (T.unpack attrPath)
++ ".tests or {}"
]
in do
r <- runExceptT $ ourReadProcessInterleaved $ proc "nix-build" args
case r of
Right (ExitSuccess, _) -> return True
_ -> return False
r <- runExceptT $ ourReadProcessInterleaved $ proc "timeout" args
case r of
Left errorMessage -> do
T.putStrLn $ attrPath <> ".tests process failed with output: " <> errorMessage
return False
Right (exitCode, output) -> do
case exitCode of
ExitFailure 124 -> do
T.putStrLn $ attrPath <> ".tests took longer than " <> timeout <> " and timed out. Other output: " <> output
return False
ExitSuccess -> return True
_ -> return False

-- | Run a program with provided argument and report whether the output
-- mentions the expected version
Expand Down

0 comments on commit c2a7a44

Please sign in to comment.