diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..c74b23852 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: erlang +sudo: true +otp_release: + - 20.3.8 +script: + - ./rebar3 eunit + + ## for deps tests: + # - ./rebar3 as test compile + # - make test diff --git a/Makefile b/Makefile index 0747cd5f1..d4ed58ba8 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,10 @@ REBAR ?= $(BASE_DIR)/rebar3 OVERLAY_VARS ?= TEST_IGNORE ?= TEST_DEPS_DIR ?= _build/test/lib +DEPS_DIR ?= _build/default/lib REL_DIR ?= _build/default/rel -DEPS = $(patsubst $(TEST_DEPS_DIR)/%, %, $(wildcard $(TEST_DEPS_DIR)/*)) -TEST_DEPS = $(filter-out $(TEST_IGNORE), $(DEPS)) +DEPS = $(patsubst $(DEPS_DIR)/%, %, $(wildcard $(DEPS_DIR)/*)) +TEST_DEPS = $(filter-out $(TEST_IGNORE), $(DEPS)) RIAK_CORE_STAT_PREFIX = riak export RIAK_CORE_STAT_PREFIX @@ -47,24 +48,31 @@ TEST_LOG_FILE := eunit.log testclean: @rm -f $(TEST_LOG_FILE) -TMP_CONFIG=rebar.config.tmp +TMP_CONFIG=rebar.config.deptest + +TEST_IGNORE += riak # Tricking rebar3 to use the dependencies from the top-level _build directory. testdep-% : @echo "--- Running EUnit tests for $* ---" - @rm -rf _build/deptest+test _build/deptest - @(cd $(TEST_DEPS_DIR)/$* && \ - cp rebar.config $(TMP_CONFIG) && \ - echo "" >> $(TMP_CONFIG) && \ - echo '{profiles, [{deptest, [{base_dir, "../../.."}]}]}.' >> $(TMP_CONFIG) && \ - REBAR_CONFIG=$(TMP_CONFIG) $(REBAR) as deptest eunit) || echo "Eunit: $* FAILED" >> $(TEST_LOG_FILE) + @rm -rf _build/deptest+test + @(cd $(TEST_DEPS_DIR)/$* \ + && escript ../../../../misc/deptest.escript rebar.config $(TMP_CONFIG) \ + && REBAR_CONFIG=$(TMP_CONFIG) $(REBAR) as deptest eunit) \ + || echo "Eunit: $* FAILED" >> $(TEST_LOG_FILE) @(cd $(TEST_DEPS_DIR)/$* && rm -f $(TMP_CONFIG)) -test-deps : deps compile testclean $(patsubst %, testdep-%, $(TEST_DEPS)) +TEST_DEPS_RULES = $(patsubst %, testdep-%, $(TEST_DEPS)) -# Test each dependency individually in its own VM -test : test-deps + +test-deps : deps compile testclean $(TEST_DEPS_RULES) + +test-riak: $(REBAR) eunit + + +# Test each dependency individually in its own VM +test : test-riak test-deps @if test -s $(TEST_LOG_FILE) ; then \ cat $(TEST_LOG_FILE) && \ exit `wc -l < $(TEST_LOG_FILE)`; \ diff --git a/misc/deptest.escript b/misc/deptest.escript new file mode 100644 index 000000000..0e67e2e0c --- /dev/null +++ b/misc/deptest.escript @@ -0,0 +1,29 @@ +#!/usr/bin/env escript + +%% A hack for running dependencies test, see Makefile#deptest. Adds riak’s _build as +%% a base_dir to the test profile, renames test profile to deptest + +%% E. g. FileIn=rebar.config, FileOut=rebar.config.deptest +main([FileIn,FileOut]) -> + case file:consult(FileIn) of + {ok,Conf0} -> ok; + _ -> Conf0=[] % no rebar.config! amazing + end, + Conf = lists:ukeymerge(1, lists:keysort(1,Conf0), [{profiles,[]}]), + [Profiles] = [ P || {profiles,P} <- Conf ], + + %% if no test profile, add an empty one + ProfilesT = lists:ukeymerge(1, lists:keysort(1,Profiles), [{test,[]}]), + + NewProfiles + = [ case P of + %% rename test → deptest; add base_dir + {test,Spec} -> {deptest, [{base_dir,"../../.."} | Spec]}; + X -> X + end + || P <- ProfilesT ], + + NewConf = lists:keyreplace(profiles, 1, Conf, {profiles,NewProfiles}), + file:write_file(FileOut, [io_lib:format("~tp.~n", [X]) || X <- NewConf]). + +