packages feed

hark-0.2: test/TestHelpers.hs

{-----------------------------------------------------------------
 
  collection of tools for use with the test routines

  (c) 2008 Markus Dittrich 
 
  This program is free software; you can redistribute it 
  and/or modify it under the terms of the GNU General Public 
  License Version 3 as published by the Free Software Foundation. 
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License Version 3 for more details.
 
  You should have received a copy of the GNU General Public 
  License along with this program; if not, write to the Free 
  Software Foundation, Inc., 59 Temple Place - Suite 330, 
  Boston, MA 02111-1307, USA.

--------------------------------------------------------------------}

module TestHelpers ( print_success,
                     print_failure,
                     get_test_dbDir
                   ) where

-- imports
import Prelude
import System.Directory


-- local imports
import Helpers.PrettyPrint

--
-- a small helper function to print [ok] and [failed] messages
--
print_success :: IO Bool
print_success = 
  do
    putColorStr Cyan "["
    putColorStr Green "ok"
    putColorStrLn Cyan "]"
    return True


print_failure :: IO Bool
print_failure = 
  do
    putColorStr Cyan "["
    putColorStr Red "failed!!"
    putColorStrLn Cyan "]"
    return False


--
-- location of test database 
--
dbName :: String
dbName = "test-db"

get_test_dbDir :: IO FilePath
get_test_dbDir = do
  cwd <- getCurrentDirectory 
  return $ cwd ++ "/" ++ dbName