Skip to content

Commit

Permalink
Ct tests will now run using proper or eqc
Browse files Browse the repository at this point in the history
Ct does not use the modules compiled by rebar (during the eunit tests).
Ct will try to compile the *_SUITE test modules. It does this by trying to
find an "Emakefile" in the same directory as the suite. If there isn't one,
it just compiles everything using default options. This meant that the
tests rebar does to set to the 'EQC' and 'PROPER' macros is never run or
found. So, the quickcheck tests that ct defines where never run.

The change adds a script to generate the Emakefile before the ct tests are
run. It uses similar logic as rebar to accomplish the task. Note how tests
are failing (as of this commit); at least now they are running.
  • Loading branch information
lordnull committed Jun 20, 2013
1 parent bcde354 commit 13a8976
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,3 +10,4 @@ deps
src/protobuffs_parser.erl
src/protobuffs_scanner.erl
erl_crash.dump
test/Emakefile
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -9,6 +9,7 @@ compile:
@$(REBAR) compile

ct:
./scripts/generate_emakefile.escript
@$(REBAR) skip_deps=true ct

eunit:
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Expand Up @@ -4,7 +4,7 @@
{meck,"0.*", {git, "https://github.com/eproxus/meck", {branch, "master"}}}
]}.

{clean_files, ["*~","**/*~","**/*.beam","logs/*"]}.
{clean_files, ["*~","**/*~","**/*.beam","logs/*","test/Emakefile"]}.
{cover_enabled, true}.
Expand Down
32 changes: 32 additions & 0 deletions scripts/generate_emakefile.escript
@@ -0,0 +1,32 @@
#! /usr/bin/env escript

main(_Args) ->
CompileOpts = [debug_info],
CheckFor = [{proper, 'PROPER', "proper.hrl"}, {eqc, 'EQC', "eqc.hrl"}],
Opts = lists:foldl(fun({Mod, Define, Hrl}, Acc) ->
case is_avail(Mod, Hrl) of
false ->
Acc;
true ->
[{d, Define} | Acc]
end
end, CompileOpts, CheckFor),
MakeLine = {'*', Opts},

FileName = filename:join(["test", "Emakefile"]),
case file:open(FileName, [write]) of
{ok, File} ->
io:format(File, "~p.~n", [MakeLine]);
Error ->
io:format("Could not open file ~s: ~p~n", [FileName, Error])
end.

is_avail(AppMod, Hrl) ->
case code:lib_dir(AppMod) of
{error, bad_name} ->
false;
Dir ->
filelib:is_regular(filename:join([Dir, "include", Hrl]))
end.


0 comments on commit 13a8976

Please sign in to comment.