2{-# LANGUAGE ForeignFunctionInterface #-}
3-----------------------------------------------------------------------------
5-- Module : Main (doctests)
6-- Copyright : (C) 2014 Chris Allen
7-- License : BSD-style (see the file LICENSE)
8-- Maintainer : Chris Allen <cma@bitemyapp.com>
9-- Stability : provisional
10-- Portability : portable
12-- This module provides doctests for a project based on the actual versions
13-- of the packages it was built with. It requires a corresponding Setup.lhs
14-- to be added to the project
15-----------------------------------------------------------------------------
19import Build_doctests (deps)
20import Control.Applicative
23import System.Directory
27##if defined(mingw32_HOST_OS)
28##if defined(i386_HOST_ARCH)
30import Control.Applicative
31import Control.Exception
33foreign import stdcall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
34foreign import stdcall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
35##elif defined(x86_64_HOST_ARCH)
37import Control.Applicative
38import Control.Exception
40foreign import ccall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
41foreign import ccall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
45-- | Run in a modified codepage where we can print UTF-8 values on Windows.
46withUnicode :: IO a -> IO a
50 (c_SetConsoleCP 65001 >> m) `finally` c_SetConsoleCP cp
56main = withUnicode $ getSources >>= \sources -> doctest $
58 : "-idist/build/autogen"
60 : "-optPdist/build/autogen/cabal_macros.h"
61 : "-hide-all-packages"
62 : map ("-package="++) deps ++ sources
64getSources :: IO [FilePath]
65getSources = filter (isSuffixOf ".hs") <$> go "src"
68 (dirs, files) <- getFilesAndDirectories dir
69 (files ++) . concat <$> mapM go dirs
71getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])
72getFilesAndDirectories dir = do
73 c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir
74 (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list