summaryrefslogtreecommitdiff
path: root/src/rebar_qc.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_qc.erl')
-rw-r--r--src/rebar_qc.erl32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/rebar_qc.erl b/src/rebar_qc.erl
index 051400f..5784f7d 100644
--- a/src/rebar_qc.erl
+++ b/src/rebar_qc.erl
@@ -30,6 +30,8 @@
-include("rebar.hrl").
+-define(QC_DIR, ".qc").
+
%% ===================================================================
%% Public API
%% ===================================================================
@@ -102,23 +104,41 @@ load_qc_mod(Mod) ->
?ABORT("Failed to load QC lib '~p'~n", [Mod])
end.
+ensure_dirs() ->
+ ok = filelib:ensure_dir(filename:join(qc_dir(), "dummy")),
+ ok = filelib:ensure_dir(filename:join(rebar_utils:ebin_dir(), "dummy")).
+
setup_codepath() ->
CodePath = code:get_path(),
- true = code:add_patha(rebar_utils:test_dir()),
- true = code:add_patha(rebar_utils:ebin_dir()),
+ true = code:add_patha(qc_dir()),
+ true = code:add_pathz(rebar_utils:ebin_dir()),
CodePath.
+qc_dir() ->
+ filename:join(rebar_utils:get_cwd(), ?QC_DIR).
+
run(Config, QC, QCOpts) ->
?DEBUG("qc_opts: ~p~n", [QCOpts]),
- ok = filelib:ensure_dir(?TEST_DIR ++ "/foo"),
+ ok = ensure_dirs(),
CodePath = setup_codepath(),
- %% Compile erlang code to ?TEST_DIR, using a tweaked config
+ CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
+ false),
+ %% Compile erlang code to ?QC_DIR, using a tweaked config
%% with appropriate defines, and include all the test modules
%% as well.
- {ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config),
+ {ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config, "qc", ?QC_DIR),
+
+ case CompileOnly of
+ "true" ->
+ true = code:set_path(CodePath),
+ ?CONSOLE("Compiled modules for qc~n", []);
+ false ->
+ run1(QC, QCOpts, CodePath)
+ end.
+run1(QC, QCOpts, CodePath) ->
TestModule = fun(M) -> qc_module(QC, QCOpts, M) end,
case lists:flatmap(TestModule, find_prop_mods()) of
[] ->
@@ -139,7 +159,7 @@ qc_module(QC=triq, _QCOpts, M) ->
qc_module(QC=eqc, QCOpts, M) -> QC:module(QCOpts, M).
find_prop_mods() ->
- Beams = rebar_utils:find_files(?TEST_DIR, ".*\\.beam\$"),
+ Beams = rebar_utils:find_files(?QC_DIR, ".*\\.beam\$"),
[M || M <- [rebar_utils:erl_to_mod(Beam) || Beam <- Beams], has_prop(M)].
has_prop(Mod) ->