tests: add a shortcut env variable to run all tests

Instead of having to specify all env variables manually, this defaults to
running all tests.
This commit is contained in:
Profpatsch 2018-05-14 23:47:58 +02:00
parent 9cfe060a9d
commit 9724c649ce
2 changed files with 9 additions and 4 deletions

View file

@ -22,7 +22,9 @@ $ cabal configure --enable-tests
$ cabal build
$ cabal test
# To run all of the tests, which takes up to a minute:
$ LANGUAGE_TESTS=yes NIXPKGS_TESTS=yes cabal test
$ env ALL_TESTS=yes cabal test
# To run only specific tests (see `tests/Main.hs` for a list)
$ env NIXPKGS_TESTS=yes PRETTY_TESTS=yes cabal test
$ ./dist/build/hnix/hnix --help
```

View file

@ -7,6 +7,7 @@ module Main where
import Control.DeepSeq
import qualified Control.Exception as Exc
import Control.Applicative ((<|>))
import Control.Monad
import Control.Monad.IO.Class
import Data.Fix
@ -84,9 +85,11 @@ main :: IO ()
main = do
nixLanguageTests <- NixLanguageTests.genTests
evalComparisonTests <- EvalTests.genEvalCompareTests
nixpkgsTestsEnv <- lookupEnv "NIXPKGS_TESTS"
prettyTestsEnv <- lookupEnv "PRETTY_TESTS"
hpackTestsEnv <- lookupEnv "HPACK_TESTS"
let allOrLookup = \var ->
lookupEnv "ALL_TESTS" <|> lookupEnv var
nixpkgsTestsEnv <- allOrLookup "NIXPKGS_TESTS"
prettyTestsEnv <- allOrLookup "PRETTY_TESTS"
hpackTestsEnv <- allOrLookup "HPACK_TESTS"
pwd <- getCurrentDirectory
setEnv "NIX_REMOTE" ("local?root=" ++ pwd ++ "/")