Commit 637337f8 authored by Ben Gamari's avatar Ben Gamari 🐢

Refactor flags

parent 6d9f33ce
......@@ -69,7 +69,9 @@ data Nofib
,compiler_args :: String
,tag :: String
,output :: String
,run :: Maybe Speed
,cachegrind :: Bool
,run :: Bool
,speed :: Speed
,rts :: [String]
,times :: Int
,skip_check :: Bool
......@@ -93,7 +95,9 @@ nofibMode = cmdArgsMode $ modes
,compiler_args = "" &= help "Extra arguments to pass to the Compiler when building tests"
,tag = "" &= help "Tag to name the compiler, defaults to compiler --version"
,output = "" &= help "Where to put created files under _make, defaults to tag/way"
,run = Nothing &= groupname "Running" &= opt "norm" &= help "Run the results (Fast,Norm,Slow)"
,cachegrind = False &= groupname "Running" &= help "Run the tests under cachegrind (Fast,Norm,Slow)"
,run = False &= groupname "Running" &= help "Run the tests"
,speed = Norm &= groupname "Running" &= help "Test speed (Fast,Norm,Slow)"
,times = 1 &= help "Number of times to run each test"
,rts = [] &= help "Which RTS options to pass when running"
,skip_check = False &= help "Skip checking the results of the tests"
......@@ -161,7 +165,7 @@ main = do
buildRules args
putStrLn "Build completed"
when (isJust run) $ do
when run $ do
ns <- mapM (runTest args) tests
let tot = length ns
bad = length $ filter not ns
......@@ -197,7 +201,7 @@ buildRules nofib@Build{..} = do
in f $ takeDirectory $ drop (length output + 1) x
want $ concat
[ [s </> "Main" <.> exe, s </> "config.txt"] | t <- tests, let s = output </> t]
want $ [ "cachegrind" ]
when cachegrind $ want [ "cachegrind" ]
"//all-results" %> \out -> do
let results = [ s </> "Main" <.> exe <.> "result"
......@@ -295,7 +299,7 @@ buildRules nofib@Build{..} = do
cmd_ (Cwd test) (EchoStdout False) (StdinBS stdin) "valgrind" "--tool=cachegrind" ("--cachegrind-out-file="++out') executable args
getTestCmdline :: Nofib -> String -> IO (BSL.ByteString, [String])
getTestCmdline nofib@Build{run=Just speed,..} test = do
getTestCmdline nofib@Build{..} test = do
config <- readConfig $ output </> test </> "config.txt"
let args = words (config "PROG_ARGS") ++ words (config $ map toUpper (show speed) ++ "_OPTS")
stdin <- let s = config "STDIN_FILE" in if s == "" then grab "stdin" else BSL.readFile $ test </> s
......@@ -311,7 +315,7 @@ getTestCmdline nofib@Build{run=Just speed,..} test = do
-- | Run a test, checking stdout/stderr are as expected, and reporting time.
-- Return True if the test passes.
runTest :: Nofib -> String -> IO Bool
runTest nofib@Build{run=Just speed,..} test = do
runTest nofib@Build{..} test = do
putStrLn $ "==nofib== " ++ takeDirectory1 test ++ ": time to run " ++ takeDirectory1 test ++ " follows..."
(stdin, args) <- getTestCmdline nofib test
stats <- IO.canonicalizePath $ output </> test </> "stat.txt"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment