From e93a5bdaf08f241ed748c34d4dd71da118bf8833 Mon Sep 17 00:00:00 2001 From: benoitc Date: Fri, 6 Nov 2015 11:00:00 +0100 Subject: [PATCH] add rebar2 support --- rebar.config.script | 44 ++++++++++++++++++++++++++++ test/jiffy_10_short_double_tests.erl | 7 ++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 rebar.config.script diff --git a/rebar.config.script b/rebar.config.script new file mode 100644 index 0000000..537aec3 --- /dev/null +++ b/rebar.config.script @@ -0,0 +1,44 @@ +IsRebar3 = case application:get_key(rebar, vsn) of + {ok, VSN} -> + [VSN1 | _] = string:tokens(VSN, "-"), + [Maj, Min, Patch] = string:tokens(VSN1, "."), + (list_to_integer(Maj) >= 3); + undefined -> + lists:keymember(mix, 1, application:loaded_applications()) + end, + +case IsRebar3 of + true -> + CONFIG; + false -> + io:format("la~n", []), + + CONFIG1 = [{eunit_opts, [verbose]}, {plugins, [rebar_gdb_plugin]} | CONFIG], + + ErlOpts = [{d, 'JIFFY_DEV'}], + Proper = [{proper, ".*", {git, "git://github.com/manopapad/proper.git", "master"}}], + + ConfigPath = filename:dirname(SCRIPT), + DevMarker = filename:join([ConfigPath, ".jiffy.dev"]), + + case filelib:is_file(DevMarker) of + true -> + % Don't override existing dependencies + CONFIG2 = case lists:keyfind(deps, 1, CONFIG1) of + false -> + CONFIG1 ++ [{deps, Proper}]; + {deps, DepsList} -> + lists:keyreplace(deps, 1, CONFIG1, {deps, DepsList ++ Proper}) + end, + + case lists:keyfind(erl_opts, 1, CONFIG2) of + false -> + CONFIG2 ++ [{erl_opts, ErlOpts}]; + {erl_opts, Opts} -> + NewOpts = {erl_opts, Opts ++ ErlOpts}, + lists:keyreplace(erl_opts, 1, CONFIG2, NewOpts) + end; + false -> + CONFIG1 + end +end. diff --git a/test/jiffy_10_short_double_tests.erl b/test/jiffy_10_short_double_tests.erl index f9ef071..3dfef50 100644 --- a/test/jiffy_10_short_double_tests.erl +++ b/test/jiffy_10_short_double_tests.erl @@ -8,7 +8,12 @@ -include("jiffy_util.hrl"). -filename() -> "test/cases/short-doubles.txt". +filename() -> + FName = "test/cases/short-doubles.txt", + case filelib:is_file(FName) of + true -> FName; + false -> "../" ++ FName + end. short_double_test_() ->