From 0c738456ff12c1b9a2db8d2e5268c5410dbc7b91 Mon Sep 17 00:00:00 2001 From: Thomas Arts Date: Fri, 8 May 2020 12:00:44 +0200 Subject: [PATCH 1/4] When using asserts and other Eunit related functions, TEST must be defined --- src/hashtree.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hashtree.erl b/src/hashtree.erl index f5ed2d345..846ac3bea 100644 --- a/src/hashtree.erl +++ b/src/hashtree.erl @@ -154,16 +154,14 @@ run_multiple/2, run_remote/0, run_remote/1]). --endif. % TEST -ifdef(EQC). -export([prop_correct/0, prop_sha/0, prop_est/0]). -include_lib("eqc/include/eqc.hrl"). -endif. --ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). --endif. +-endif. %% TEST -define(NUM_SEGMENTS, (1024*1024)). -define(WIDTH, 1024). @@ -1584,6 +1582,7 @@ opened_closed_test() -> %%% EQC %%%=================================================================== +-ifdef(TEST). -ifdef(EQC). prop_sha() -> %% NOTE: Generating 1MB (1024 * 1024) size binaries is incredibly slow @@ -1692,3 +1691,4 @@ prop_est() -> true end). -endif. +-endif. From 9b28d7824b4ec2e4f080accb903b79e8da211cb7 Mon Sep 17 00:00:00 2001 From: Thomas Arts Date: Sat, 9 May 2020 16:55:21 +0200 Subject: [PATCH 2/4] Add eqc as Makefile target --- Makefile | 11 ++++++++--- rebar.config | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 60edb9118..96875a9f2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: compile rel cover test dialyzer +.PHONY: compile rel cover test dialyzer eqc REBAR=./rebar3 compile: @@ -7,11 +7,12 @@ compile: clean: $(REBAR) clean -cover: test +cover: + $(REBAR) eunit --cover $(REBAR) cover test: compile - $(REBAR) as test do eunit + $(REBAR) eunit dialyzer: $(REBAR) dialyzer @@ -19,4 +20,8 @@ dialyzer: xref: $(REBAR) xref +eqc: + $(REBAR) as test eqc --testing_budget 120 + $(REBAR) as eqc eunit + check: test dialyzer xref diff --git a/rebar.config b/rebar.config index 2b60b22b2..bc4c60fac 100644 --- a/rebar.config +++ b/rebar.config @@ -36,5 +36,5 @@ {profiles, [ {test, [{deps, [meck]}, {erl_opts, [nowarn_export_all]}]}, - {eqc, [{deps, [meck]}, {erl_opts, [nowarn_export_all]}]} + {eqc, [{deps, [meck]}, {erl_opts, [{d, 'EQC'}, nowarn_export_all]}]} ]}. From 3fcb0c2fb6369ec1e4f51a219d91ce3fd44d6a71 Mon Sep 17 00:00:00 2001 From: Thomas Arts Date: Sat, 9 May 2020 16:56:31 +0200 Subject: [PATCH 3/4] Run claim test by giving a possible initial state --- test/riak_core_claim_statem.erl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/riak_core_claim_statem.erl b/test/riak_core_claim_statem.erl index 6e9c84ee6..fd3b9f3c6 100644 --- a/test/riak_core_claim_statem.erl +++ b/test/riak_core_claim_statem.erl @@ -244,6 +244,9 @@ weight(_, _, _, _) -> -define(QC_OUT(P), eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)). +claim_test() -> + eqc:quickcheck(?QC_OUT(prop_claim(with_ring_size(5)))). + eqc_check(File, Prop) -> {ok, Bytes} = file:read_file(File), CE = binary_to_term(Bytes), From b0b6783b87642ec2324ff6d4097d2485aa3db794 Mon Sep 17 00:00:00 2001 From: Thomas Arts Date: Tue, 12 May 2020 08:38:12 +0200 Subject: [PATCH 4/4] No need for TEST macro in eqc directory --- eqc/bg_manager_eqc.erl | 2 -- 1 file changed, 2 deletions(-) diff --git a/eqc/bg_manager_eqc.erl b/eqc/bg_manager_eqc.erl index c148b6e69..b158ba794 100644 --- a/eqc/bg_manager_eqc.erl +++ b/eqc/bg_manager_eqc.erl @@ -19,7 +19,6 @@ -module(bg_manager_eqc). --ifdef(TEST). -ifdef(EQC). -include("include/riak_core_bg_manager.hrl"). @@ -858,4 +857,3 @@ prop_bgmgr_parallel() -> end))). -endif. --endif.