Skip to content
This repository

Changes to get eunit to work with coverage. #61

Open
wants to merge 2 commits into from

2 participants

Ben Kearns Kostis Sagonas
Ben Kearns

I made some changes to allow rebar eunit with coverage turned on. I turned coverage on in the rebar config. I was compiling on a slow, loaded box, so the timeout changes in the proper_tests file might not be completely necessary on a faster machine.

-b

Kostis Sagonas
Collaborator

Thanks for your pull request.

We are curious (and a bit concerned) about the purpose of hard-coding {cover_enabled, true} in rebar.config. Do you need this for some specific reason or is it so that we get some idea what percentage of PropEr's code its test suite covers? (Note that this does not affect the tests of users, i.e. the application that is being tested with PropEr.)

We agree that it's probably a good idea to see at some point what percentage of PropEr's code base is covered by its test suite but we doubt that cover should be enabled by default, since it makes the tests run about 4 times slower (at least on my machine).

Also, it seems that it results in an error when one issues a make tests command:

 ERROR: Cover analyze failed for to_remove: {not_cover_compiled,to_remove}: "/home/kostis/proper/.eunit/to_remove.beam"

Do you also get this error, or is it just my bad luck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jan 04, 2013
Ben Kearns Fixed a problem with eunit test cases. e3ebe40
Ben Kearns Changes to get proper to work with eunit with coverage turned on. 710c058
This page is out of date. Refresh to see the latest.
1  rebar.config
@@ -33,6 +33,7 @@
33 33 warn_obsolete_guard, warn_unused_import,
34 34 warn_missing_spec, warn_untyped_record]}.
35 35 {dialyzer_opts, [{warnings, [unmatched_returns]}]}.
  36 +{cover_enabled, true}.
36 37
37 38 {pre_hooks, [{"(linux|bsd|darwin|solaris)", compile, "make include/compile_flags.hrl"},
38 39 {"win32", compile, "escript.exe write_compile_flags include/compile_flags.hrl"}]}.
2  src/proper_typeserver.erl
@@ -624,7 +624,7 @@ get_code_and_exports_from_source(Mod, ObjError) ->
624 624 SrcFileName = atom_to_list(Mod) ++ ?SRC_FILE_EXT,
625 625 case code:where_is_file(SrcFileName) of
626 626 FullSrcFileName when is_list(FullSrcFileName) ->
627   - Opts = [binary,debug_info,return_errors,{d,'PROPER_REMOVE_PROPS'}],
  627 + Opts = [binary,debug_info,return_errors,{d,'PROPER_REMOVE_PROPS'}, {i, "../include"}, {i, "./include"}],
628 628 case compile:file(FullSrcFileName, Opts) of
629 629 {ok,Mod,Binary} ->
630 630 get_chunks(Binary);
24 test/proper_tests.erl
@@ -744,10 +744,10 @@ native_type_props_test_() ->
744 744 code:delete(to_remove),
745 745 code:purge(to_remove),
746 746 file:rename("tests/to_remove.beam",
747   - "tests/to_remove.bak") end,
748   - fun(_) -> file:rename("tests/to_remove.bak",
749   - "tests/to_remove.beam") end,
750   - ?_passes(?FORALL(_, to_remove:exp1(), true))},
  747 + "tests/to_remove.bak") end,
  748 + fun(_) -> file:rename("tests/to_remove.bak",
  749 + "tests/to_remove.beam") end,
  750 + ?_passes(?FORALL(_, to_remove:exp1(), true))},
751 751 ?_passes(rec_props_test1:prop_1()),
752 752 ?_passes(rec_props_test2:prop_2()),
753 753 ?_passes(?FORALL(L, vector(2,my_native_type()),
@@ -810,12 +810,12 @@ true_props_test_() ->
810 810 {three, conjunction([{a,true},{b,true}])}
811 811 ])),
812 812 ?_passes(?FORALL(X, untyped(), is_record(X, untyped))),
813   - ?_passes(pdict_statem:prop_pdict()),
814   - ?_passes(symb_statem:prop_simple()),
  813 + {timeout, 20, ?_passes(pdict_statem:prop_pdict())},
  814 + {timeout, 20, ?_passes(symb_statem:prop_simple())},
815 815 {timeout, 20, ?_passes(symb_statem:prop_parallel_simple())},
816   - {timeout, 10, ?_passes(ets_statem:prop_ets())},
817   - {timeout, 20, ?_passes(ets_statem:prop_parallel_ets())},
818   - {timeout, 20, ?_passes(pdict_fsm:prop_pdict())}].
  816 + {timeout, 20, ?_passes(ets_statem:prop_ets())},
  817 + {timeout, 40, ?_passes(ets_statem:prop_parallel_ets())},
  818 + {timeout, 40, ?_passes(pdict_fsm:prop_pdict())}].
819 819
820 820 false_props_test_() ->
821 821 [?_failsWith([[_Same,_Same]],
@@ -958,12 +958,12 @@ options_test_() ->
958 958 [{start_size,12}])].
959 959
960 960 adts_test_() ->
961   - [{timeout, 20, % for Kostis' old laptop
  961 + [{timeout, 40, % for Kostis' old laptop
962 962 ?_passes(?FORALL({X,S},{integer(),set()},
963 963 sets:is_element(X,sets:add_element(X,S))), [20])},
964   - ?_passes(?FORALL({X,Y,D},
  964 + {timeout, 10, ?_passes(?FORALL({X,Y,D},
965 965 {integer(),float(),dict(integer(),float())},
966   - dict:fetch(X,dict:store(X,Y,eval(D))) =:= Y), [30]),
  966 + dict:fetch(X,dict:store(X,Y,eval(D))) =:= Y), [30])},
967 967 ?_fails(?FORALL({X,D},
968 968 {boolean(),dict(boolean(),integer())},
969 969 dict:erase(X, dict:store(X,42,D)) =:= D))].

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.