Commit 825d97d4 authored by Camil Staps's avatar Camil Staps 🚀

Report test coverage

parent 9b6fe9d9
......@@ -199,7 +199,7 @@ handleModule opts fp w
# (funs,macros,_,_,_,_,_,_,(modname,mod,_),w) = findModuleContents False (dropExtension fp) w
# output_modname = opts.output_prefix +++ "." +++ modname
# output_filename = opts.output_directory </> replaceSubString "." {pathSeparator} output_modname +++ ".icl"
# (nprops,props) = generatePropertyModule
# (nprops,coverage,props) = generatePropertyModule
output_modname
opts.print_options
opts.test_options
......@@ -207,7 +207,10 @@ handleModule opts fp w
[f \\ (_,f,_) <- funs ++ macros]
// Write properties
| nprops == 0 = w
# w = output INFO ("Found " +++ pluralisen English nprops "test case" +++ " in module " +++ modname) opts w
# w = output INFO
("Found " +++ pluralisen English nprops "test case" +++
" in module " +++ modname +++
"; " <+ entier (coverage * 100.0) <+ "% coverage") opts w
# (dir,_) = splitFileName output_filename
# (ok,w) = assertDirectory dir w
| isError ok = exit (snd (fromError ok) <+ " " +++ output_filename) opts w
......@@ -246,18 +249,24 @@ where
interleave _ [] = []
interleave g [x:xs] = [g,x:interleave g xs]
generatePropertyModule :: !String ![String] ![String] !ModuleEntry ![FunctionEntry] -> (!Int, !String)
generatePropertyModule name print_options test_options me fes = (length props, join "\n\n"
[ "module " +++ name
, "import Gast, Gast.CommandLine"
, bootstrap
, generators_string
, start
: [gp.gp_implementation \\ gp <- props]
])
generatePropertyModule :: !String ![String] ![String] !ModuleEntry ![FunctionEntry] -> (!Int, !Real, !String)
generatePropertyModule name print_options test_options me fes
= (length props, coverage, tests)
where
props = concatMap (generateProperties pvis generators) fes
n_props = length props
coverage = toReal (length (filter (not o isEmpty) propsets)) / toReal (length fes)
tests = join "\n\n"
[ "module " +++ name
, "import Gast, Gast.CommandLine"
, bootstrap
, generators_string
, start
: [gp.gp_implementation \\ gp <- props]
]
propsets = map (generateProperties pvis generators) fes
where pvis = fromMaybe [] $ docPropertyTestWith <$> me.me_documentation
props = flatten propsets
bootstrap = fromMaybe "" (docPropertyBootstrap =<< me.me_documentation)
......
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