Skip to content

Commit

Permalink
Add support for rebar3
Browse files Browse the repository at this point in the history
Allow Jiffy to be used easily in projects using either rebar 2 or 3.
  • Loading branch information
davisp committed Sep 29, 2016
1 parent 0789c08 commit c7756da
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Binary file added enc
Binary file not shown.
11 changes: 3 additions & 8 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]}.
3 changes: 2 additions & 1 deletion test/jiffy_01_yajl_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


-include_lib("eunit/include/eunit.hrl").
-include("jiffy_util.hrl").


yajl_test_() ->
Expand All @@ -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).

Expand Down
3 changes: 2 additions & 1 deletion test/jiffy_10_short_double_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
-include("jiffy_util.hrl").


filename() -> "../test/cases/short-doubles.txt".
filename() ->
cases_path("short-doubles.txt").


short_double_test_() ->
Expand Down
13 changes: 13 additions & 0 deletions test/jiffy_util.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -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]).

0 comments on commit c7756da

Please sign in to comment.