From 64e80a0cac62afa151bc9d04d71043df69419c87 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Wed, 12 Jun 2019 14:57:21 +0200 Subject: [PATCH] Move tests to exe --- app/Niv.hs | 11 +---------- app/test.hs | 8 ++++++++ default.nix | 3 +++ package.yaml | 10 ++++++---- 4 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 app/test.hs diff --git a/app/Niv.hs b/app/Niv.hs index af306f6..6dbed3e 100644 --- a/app/Niv.hs +++ b/app/Niv.hs @@ -7,7 +7,7 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns #-} -module Niv where +module Main where import Control.Applicative import Control.Monad @@ -18,7 +18,6 @@ import Data.Hashable (Hashable) import Data.Maybe (fromMaybe) import Data.String.QQ (s) import Niv.GitHub -import Niv.Test import Niv.Update import System.Exit (exitFailure) import System.FilePath ((), takeDirectory) @@ -36,7 +35,6 @@ import qualified GitHub as GH import qualified Options.Applicative as Opts import qualified Options.Applicative.Help.Pretty as Opts import qualified System.Directory as Dir -import qualified Test.Tasty as Tasty main :: IO () main = join $ Opts.execParser opts @@ -153,13 +151,6 @@ parsePackageSpec = parsePackage :: Opts.Parser (PackageName, PackageSpec) parsePackage = (,) <$> parsePackageName <*> parsePackageSpec -------------------------------------------------------------------------------- --- PACKAGE SPEC OPS -------------------------------------------------------------------------------- - -test :: IO () -test = Tasty.defaultMain $ Niv.Test.tests - ------------------------------------------------------------------------------- -- INIT ------------------------------------------------------------------------------- diff --git a/app/test.hs b/app/test.hs new file mode 100644 index 0000000..746c742 --- /dev/null +++ b/app/test.hs @@ -0,0 +1,8 @@ +module Main where + +import Niv.Test +import qualified Test.Tasty as Tasty + +main :: IO () +main = Tasty.defaultMain $ Niv.Test.tests + diff --git a/default.nix b/default.nix index 988c1ba..74791b7 100644 --- a/default.nix +++ b/default.nix @@ -50,6 +50,9 @@ rec tests = pkgs.callPackage ./tests { inherit niv; }; + niv-test = pkgs.runCommand "niv-test" { buildInputs = [ niv ] ; } + "niv-test && touch $out"; + readme = pkgs.writeText "README.md" (with { template = builtins.readFile ./README.tpl.md; diff --git a/package.yaml b/package.yaml index 9e0d828..a524c37 100644 --- a/package.yaml +++ b/package.yaml @@ -27,9 +27,7 @@ library: executables: niv: - source-dirs: - - app - main: Niv.main + main: app/niv.hs data-files: - nix/sources.nix dependencies: @@ -45,5 +43,9 @@ executables: - optparse-applicative - process - string-qq - - tasty - unordered-containers + niv-test: + main: app/test.hs + dependencies: + - tasty + - niv