packages feed

phino-0.0.0.27 / test / HLintSpec.hs

{-# LANGUAGE ScopedTypeVariables #-}-- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com-- SPDX-License-Identifier: MITmodule HLintSpec (spec) whereimport Control.Exception (try, IOException)import System.Exit (ExitCode(..))import System.Process (readProcessWithExitCode)import Test.Hspec-- | Check if hlint is available on the systemisHLintAvailable :: IO BoolisHLintAvailable = do  result <- try (readProcessWithExitCode "hlint" ["--version"] "")  case result of    Left (_ :: IOException) -> return False    Right (ExitSuccess, _, _) -> return True    Right (ExitFailure _, _, _) -> return False-- | Run hlint on a directory and check for successrunHLintCheck :: String -> IO ()runHLintCheck dir = do  available <- isHLintAvailable  if not available     then pendingWith "hlint is not available on this system"    else do      (exitCode, stdout, stderr) <- readProcessWithExitCode "hlint" [dir] ""      case exitCode of        ExitSuccess -> return ()        ExitFailure _ -> do          putStrLn $ "HLint warnings/errors in " ++ dir ++ ":"          putStrLn stdout          putStrLn stderr          exitCode `shouldBe` ExitSuccessspec :: Specspec =  describe "HLint" $ do    it "should pass hlint check for src/" $      runHLintCheck "src/"    it "should pass hlint check for app/" $      runHLintCheck "app/"              it "should pass hlint check for test/" $      runHLintCheck "test/"