{-# LANGUAGE TupleSections, RecordWildCards, ScopedTypeVariables #-} module Action.Test(actionTest) where import Query import Action.CmdLine import Action.Search import Action.Server import Action.Generate import General.Util import Input.Item import Input.Haddock import System.IO.Extra import Control.Monad import Output.Items import Control.DeepSeq import Control.Exception actionTest :: CmdLine -> IO () actionTest :: CmdLine -> IO () actionTest Test{..} = Handle -> BufferMode -> IO () -> IO () forall a. Handle -> BufferMode -> IO a -> IO a withBuffering Handle stdout BufferMode NoBuffering (IO () -> IO ()) -> IO () -> IO () forall a b. (a -> b) -> a -> b $ (FilePath -> IO ()) -> IO () forall a. (FilePath -> IO a) -> IO a withTempFile ((FilePath -> IO ()) -> IO ()) -> (FilePath -> IO ()) -> IO () forall a b. (a -> b) -> a -> b $ \sample :: FilePath sample -> do FilePath -> IO () putStrLn "Code tests" IO () general_util_test IO () input_haddock_test IO () query_test IO () action_server_test_ IO () item_test FilePath -> IO () putStrLn "" FilePath -> IO () putStrLn "Sample database tests" CmdLine -> IO () actionGenerate CmdLine defaultGenerate{database :: FilePath database=FilePath sample, local_ :: [FilePath] local_=["misc/sample-data"]} Bool -> FilePath -> IO () action_search_test Bool True FilePath sample Bool -> FilePath -> IO () action_server_test Bool True FilePath sample FilePath -> IO () putStrLn "" FilePath -> IO () putStrLn "Haskell.org database tests" Bool -> FilePath -> IO () action_search_test Bool False FilePath database Bool -> FilePath -> IO () action_server_test Bool False FilePath database Bool -> IO () -> IO () forall (f :: * -> *). Applicative f => Bool -> f () -> f () when Bool deep (IO () -> IO ()) -> IO () -> IO () forall a b. (a -> b) -> a -> b $ FilePath -> (StoreRead -> IO ()) -> IO () forall a. NFData a => FilePath -> (StoreRead -> IO a) -> IO a withSearch FilePath database ((StoreRead -> IO ()) -> IO ()) -> (StoreRead -> IO ()) -> IO () forall a b. (a -> b) -> a -> b $ \store :: StoreRead store -> do FilePath -> IO () putStrLn "Deep tests" let xs :: [FilePath] xs = (Target -> FilePath) -> [Target] -> [FilePath] forall a b. (a -> b) -> [a] -> [b] map Target -> FilePath targetItem ([Target] -> [FilePath]) -> [Target] -> [FilePath] forall a b. (a -> b) -> a -> b $ StoreRead -> [Target] listItems StoreRead store () -> IO () forall a. a -> IO a evaluate (() -> IO ()) -> () -> IO () forall a b. (a -> b) -> a -> b $ [FilePath] -> () forall a. NFData a => a -> () rnf [FilePath] xs FilePath -> IO () putStrLn (FilePath -> IO ()) -> FilePath -> IO () forall a b. (a -> b) -> a -> b $ "Loaded " FilePath -> FilePath -> FilePath forall a. [a] -> [a] -> [a] ++ Int -> FilePath forall a. Show a => a -> FilePath show ([FilePath] -> Int forall (t :: * -> *) a. Foldable t => t a -> Int length [FilePath] xs) FilePath -> FilePath -> FilePath forall a. [a] -> [a] -> [a] ++ " items"