2014-08-03 14:17:43 +02:00
|
|
|
module Main where
|
|
|
|
|
2018-04-05 00:32:21 +02:00
|
|
|
import Control.Monad
|
2018-04-07 21:09:49 +02:00
|
|
|
import Data.List (isInfixOf)
|
2015-12-21 06:55:53 +01:00
|
|
|
import qualified EvalTests
|
2018-02-09 15:32:53 +01:00
|
|
|
import qualified NixLanguageTests
|
2018-03-28 06:59:27 +02:00
|
|
|
import qualified ParserTests
|
|
|
|
import qualified PrettyTests
|
2018-03-29 01:30:54 +02:00
|
|
|
import System.Environment
|
2018-04-07 21:02:33 +02:00
|
|
|
import System.Posix.Files
|
2018-04-07 21:09:49 +02:00
|
|
|
import System.Process
|
2018-03-28 06:59:27 +02:00
|
|
|
import Test.Tasty
|
2016-01-23 22:46:30 +01:00
|
|
|
|
2014-08-03 14:17:43 +02:00
|
|
|
main :: IO ()
|
2018-02-09 15:32:53 +01:00
|
|
|
main = do
|
|
|
|
nixLanguageTests <- NixLanguageTests.genTests
|
2018-04-07 21:09:49 +02:00
|
|
|
|
2018-04-05 00:32:21 +02:00
|
|
|
langTestsEnv <- lookupEnv "LANGUAGE_TESTS"
|
|
|
|
let runLangTests = langTestsEnv == Just "yes"
|
|
|
|
when runLangTests $ do
|
2018-04-07 21:02:33 +02:00
|
|
|
exist <- fileExist "data/nix/tests/local.mk"
|
2018-04-05 01:33:43 +02:00
|
|
|
unless exist $
|
|
|
|
errorWithoutStackTrace $ unlines
|
|
|
|
[ "Directory data/nix does not have any files."
|
2018-04-07 21:09:49 +02:00
|
|
|
, "Did you forget to run"
|
|
|
|
++ " \"git submodule update --init --recursive\"?"
|
2018-04-05 01:33:43 +02:00
|
|
|
]
|
2018-04-07 21:09:49 +02:00
|
|
|
|
|
|
|
output <- readCreateProcess (shell "hpack") ""
|
|
|
|
when ("modified manually" `isInfixOf` output) $
|
|
|
|
errorWithoutStackTrace
|
|
|
|
"Edit package.yaml and re-generate hnix.cabal by running \"hpack\""
|
|
|
|
|
2018-03-29 01:30:54 +02:00
|
|
|
defaultMain $ testGroup "hnix" $
|
2018-02-09 15:32:53 +01:00
|
|
|
[ ParserTests.tests
|
|
|
|
, EvalTests.tests
|
|
|
|
, PrettyTests.tests
|
2018-03-29 01:30:54 +02:00
|
|
|
] ++
|
2018-04-05 00:32:21 +02:00
|
|
|
[ nixLanguageTests | runLangTests ]
|