Skip to content

Commit

Permalink
Update whitebox test generation to use config
Browse files Browse the repository at this point in the history
  • Loading branch information
bugarela committed Aug 7, 2022
1 parent 75588e6 commit 0999cee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions StateGraphParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,21 @@ unescape (c1:c2:cs) =
header :: String -> String
header m = unlines ["defmodule " ++ m ++ "Test do", " use ExUnit.Case", " doctest " ++ m]

main :: IO ()
main = do
(moduleName:file:configFile:_) <- getArgs
config <- parseConfig configFile
generateWhiteboxTests ps (Config _ _ _ _ _ name _ _ file _ dest) = do
d <- (eitherDecode <$> getJSON file) :: IO (Either String Graph)
case d of
Left err -> putStrLn err
Right ps ->
case fmap processNames config of
Left err -> putStrLn err
Right ms -> case genTests moduleName ms ps of
Left err -> putStrLn err
Right s ->
let f = "elixir/test/generated_code/" ++ snake moduleName ++ "_test.exs"
in writeFile f s
Right graph -> case genTests name ps graph of
Left err -> putStrLn err
Right s ->
let f = dest ++ "/test/generated_code/" ++ snake name ++ "_test.exs"
in writeFile f s


main :: IO ()
main = do
(configFile:_) <- getArgs
config <- parseConfig configFile
case fmap (\c -> generateWhiteboxTests (processNames c) c) config of
Left err -> error err
Right c -> c
2 changes: 1 addition & 1 deletion WitnessTestGeneration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ generateTestFromTrace moduleName dest ps (Test n t) = do
-- generateBlackboxTests :: [String] -> DistributionConfig -> Either String IO()
generateBlackboxTests ps (Config _ _ _ _ _ name _ _ _ tests dest) = mapM (generateTestFromTrace name dest ps) tests

-- main :: IO [()]
main :: IO [()]
main = do
(configFile:_) <- getArgs
config <- parseConfig configFile
Expand Down

0 comments on commit 0999cee

Please sign in to comment.