diff --git a/.gitignore b/.gitignore index e3e5e72..d42744f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ deps erln8.config hexer.config TEST-*.xml +*.d +_build diff --git a/rebar.config b/rebar.config index 9d26448..0206198 100644 --- a/rebar.config +++ b/rebar.config @@ -40,6 +40,14 @@ ]}. {plugins, [ - rebar_gdb_plugin + rebar_gdb_plugin, pc ]}. +{provider_hooks, + [ + {pre, + [ + {compile, {pc, compile}}, + {clean, {pc, clean}} + ]} +]}. diff --git a/test/jiffy_01_yajl_tests.erl b/test/jiffy_01_yajl_tests.erl index aedaf71..8c1ec97 100644 --- a/test/jiffy_01_yajl_tests.erl +++ b/test/jiffy_01_yajl_tests.erl @@ -5,6 +5,7 @@ -include_lib("eunit/include/eunit.hrl"). +-include("jiffy_util.hrl"). yajl_test_() -> @@ -19,7 +20,7 @@ gen({Name, Json, Erl}) -> read_cases() -> - CasesPath = filename:join(["..", "test", "cases", "*.json"]), + CasesPath = filename:join([cases_path(), "*.json"]), FileNames = lists:sort(filelib:wildcard(CasesPath)), lists:map(fun(F) -> make_pair(F) end, FileNames). @@ -30,3 +31,4 @@ make_pair(FileName) -> ErlFname = BaseName ++ ".eterm", {ok, [Term]} = file:consult(ErlFname), {filename:basename(BaseName), Json, Term}. + diff --git a/test/jiffy_10_short_double_tests.erl b/test/jiffy_10_short_double_tests.erl index d66e1ea..b709441 100644 --- a/test/jiffy_10_short_double_tests.erl +++ b/test/jiffy_10_short_double_tests.erl @@ -8,7 +8,8 @@ -include("jiffy_util.hrl"). -filename() -> "../test/cases/short-doubles.txt". +filename() -> + cases_path() ++ "/short-doubles.txt". short_double_test_() -> diff --git a/test/jiffy_util.hrl b/test/jiffy_util.hrl index 51bd86a..8b95415 100644 --- a/test/jiffy_util.hrl +++ b/test/jiffy_util.hrl @@ -25,3 +25,15 @@ enc(V) -> enc(V, Opts) -> iolist_to_binary(jiffy:encode(V, Opts)). + +%% rebar runs eunit with PWD as .eunit/ +%% rebar3 runs eunit with PWD as ./ +%% this adapts to the differences +cases_path() -> + Path = "test/cases", + AltPath = "../" ++ Path, + case filelib:is_dir( Path ) of + true -> Path; + false -> AltPath + end. +