diff options
author | Ben Sima <ben@bsima.me> | 2021-01-15 22:18:03 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-01-15 22:18:03 -0500 |
commit | 4ea4faa4f6405801de19d0ea56e8bc29aa4362e1 (patch) | |
tree | 9028fa5b67d7ee57176e48e589aac1972c37efcb /Biz/Bild.hs | |
parent | e77cdc025b0e80049344f258d9ca170d0953d0d7 (diff) |
Add bild --test
This argument will run the tests for an output after building. It's active in
'ci' so running that will ensure tests are passing. This way testing a
namespace and building a namespace are as close together as possible, so
presumably it will be that much easier to write good tests.
Diffstat (limited to 'Biz/Bild.hs')
-rw-r--r-- | Biz/Bild.hs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 0fd5bb4..721da46 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -125,10 +125,8 @@ import qualified Data.Char as Char import qualified Data.List as List import qualified Data.String as String import qualified Data.Text as Text -import qualified System.Console.Docopt as Docopt import qualified System.Directory as Dir import qualified System.Environment as Env -import qualified System.Exit as Exit import System.FilePath ((</>)) import qualified System.Process as Process import qualified Text.Regex.Applicative as Regex @@ -137,24 +135,24 @@ import qualified Prelude main :: IO () main = Cli.main <| Cli.Plan help move test where - test = Test.group "Biz.Bild" [Test.unit "id" <| 1 @=? 1] + test = Test.group "Biz.Bild" [Test.unit "id" <| 1 @=? (1 :: Integer)] move args = - mapM getNamespace (Docopt.getAllArgs args (Docopt.argument "target")) + mapM getNamespace (Cli.getAllArgs args (Cli.argument "target")) /> catMaybes /> filter isBuildableNs >>= mapM analyze - >>= mapM_ build + >>= mapM_ (build (args `Cli.has` Cli.longOption "test")) -help :: Docopt.Docopt +help :: Cli.Docopt help = - [Docopt.docopt| + [Cli.docopt| bild Usage: - bild <target>... + bild [--test] <target>... Options: - -v, --verbose Show output from underlying compiler + --test Run tests on a target after building. |] type Dep = String @@ -286,8 +284,8 @@ detectGhcCompiler _ content jsSuffix :: String -> Bool jsSuffix = List.isSuffixOf ".js" -build :: Target -> IO () -build target@Target {..} = do +build :: Bool -> Target -> IO () +build andTest target@Target {..} = do root <- Env.getEnv "BIZ_ROOT" case compiler of GhcExe -> do @@ -310,6 +308,9 @@ build target@Target {..} = do "-o", outDir </> out ] + when andTest <| do + putStrLn <| "bild: dev: test: " <> Namespace.toPath namespace + Process.callProcess (outDir </> out) ["test"] GhcLib -> do putStrLn <| "bild: dev: ghc-lib: " <> Namespace.toPath namespace putText <| "bild: dev: bilder: " <> Text.pack builder |