diff --git a/.gitignore b/.gitignore index e3e5e72..c6154b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,15 @@ .eunit +.rebar .jiffy.dev *.app *.beam +*.d *.o *.so +_build +compile_commands.json deps erln8.config hexer.config +rebar.lock TEST-*.xml diff --git a/enc b/enc new file mode 100755 index 0000000..239a351 Binary files /dev/null and b/enc differ diff --git a/rebar.config b/rebar.config index 9d26448..33b8186 100644 --- a/rebar.config +++ b/rebar.config @@ -33,13 +33,8 @@ ]}. {eunit_opts, [ - verbose, - {report, { - eunit_surefire, [{dir,"."}] - }} -]}. - -{plugins, [ - rebar_gdb_plugin + verbose ]}. +{pre_hooks, [{"", compile, "./enc compile"}]}. +{post_hooks, [{"", clean, "./enc clean"}]}. diff --git a/test/jiffy_01_yajl_tests.erl b/test/jiffy_01_yajl_tests.erl index aedaf71..689c880 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 = cases_path("*.json"), FileNames = lists:sort(filelib:wildcard(CasesPath)), lists:map(fun(F) -> make_pair(F) end, FileNames). diff --git a/test/jiffy_10_short_double_tests.erl b/test/jiffy_10_short_double_tests.erl index d66e1ea..0b099c1 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..4b714d9 100644 --- a/test/jiffy_util.hrl +++ b/test/jiffy_util.hrl @@ -25,3 +25,16 @@ 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(Suffix) -> + {ok, Cwd} = file:get_cwd(), + Prefix = case filename:basename(Cwd) of + ".eunit" -> ".."; + _ -> "." + end, + Path = "test/cases", + filename:join([Prefix, Path, Suffix]).