From d1af165af799134f791886ea788311cbf68b788d Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Wed, 3 Sep 2014 14:53:59 +0200 Subject: ct_property_test: add Triq support Also, ensure that the right module's counterexample/0 is called. --- lib/common_test/src/ct_property_test.erl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/common_test/src/ct_property_test.erl b/lib/common_test/src/ct_property_test.erl index e401fef669..240a36fbfc 100644 --- a/lib/common_test/src/ct_property_test.erl +++ b/lib/common_test/src/ct_property_test.erl @@ -78,7 +78,8 @@ %%% %%% @doc Initializes Config for property testing. %%% -%%%

The function investigates if support is available for either Quickcheck or PropEr. +%%%

The function investigates if support is available for either Quickcheck, PropEr, +%%% or Triq. %%% The options {property_dir,AbsPath} and %%% {property_test_tool,Tool} is set in the Config returned.

%%%

The function is intended to be called in the init_per_suite in the test suite.

@@ -86,7 +87,7 @@ %%% @end init_per_suite(Config) -> - case which_module_exists([eqc,proper]) of + case which_module_exists([eqc,proper,triq]) of {ok,ToolModule} -> ct:pal("Found property tester ~p",[ToolModule]), Path = property_tests_path("property_test", Config), @@ -114,7 +115,7 @@ init_per_suite(Config) -> quickcheck(Property, Config) -> Tool = proplists:get_value(property_test_tool,Config), - mk_ct_return( Tool:quickcheck(Property) ). + mk_ct_return( Tool:quickcheck(Property), Tool ). %%%================================================================ @@ -123,10 +124,10 @@ quickcheck(Property, Config) -> %%% %%% Make return values back to the calling Common Test suite -mk_ct_return(true) -> +mk_ct_return(true, _Tool) -> true; -mk_ct_return(Other) -> - try lists:last(hd(eqc:counterexample())) +mk_ct_return(Other, Tool) -> + try lists:last(hd(Tool:counterexample())) of {set,{var,_},{call,M,F,Args}} -> {fail, io_lib:format("~p:~p/~p returned bad result",[M,F,length(Args)])} @@ -174,5 +175,6 @@ compile_tests(Path, ToolModule) -> macro_def(eqc) -> [{d, 'EQC'}]; -macro_def(proper) -> [{d, 'PROPER'}]. +macro_def(proper) -> [{d, 'PROPER'}]; +macro_def(triq) -> [{d, 'TRIQ'}]. -- cgit v1.2.3 From fc2e55e44a0d5a684c2bf10cbfbd0dd0d0c03261 Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Fri, 5 Sep 2014 15:40:19 +0200 Subject: common_test: ct_property_test call correct Triq function. --- lib/common_test/src/ct_property_test.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/common_test/src/ct_property_test.erl b/lib/common_test/src/ct_property_test.erl index 240a36fbfc..39d089f04c 100644 --- a/lib/common_test/src/ct_property_test.erl +++ b/lib/common_test/src/ct_property_test.erl @@ -115,7 +115,8 @@ init_per_suite(Config) -> quickcheck(Property, Config) -> Tool = proplists:get_value(property_test_tool,Config), - mk_ct_return( Tool:quickcheck(Property), Tool ). + F = function_name(quickcheck, Tool), + mk_ct_return( Tool:F(Property), Tool ). %%%================================================================ @@ -178,3 +179,6 @@ macro_def(eqc) -> [{d, 'EQC'}]; macro_def(proper) -> [{d, 'PROPER'}]; macro_def(triq) -> [{d, 'TRIQ'}]. +function_name(quickcheck, triq) -> check; +function_name(F, _) -> F. + -- cgit v1.2.3 From 32573a29bae633f9af09d7958d49f1d06daebd18 Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Fri, 5 Sep 2014 15:42:55 +0200 Subject: ssh: update for triq tests --- lib/ssh/test/property_test/ssh_eqc_client_server.erl | 5 +++++ lib/ssh/test/property_test/ssh_eqc_encode_decode.erl | 16 ++++++++++++++++ lib/ssh/test/ssh_property_test_SUITE.erl | 6 ++---- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/ssh/test/property_test/ssh_eqc_client_server.erl b/lib/ssh/test/property_test/ssh_eqc_client_server.erl index 3a84acebb3..cf895ae85e 100644 --- a/lib/ssh/test/property_test/ssh_eqc_client_server.erl +++ b/lib/ssh/test/property_test/ssh_eqc_client_server.erl @@ -27,6 +27,10 @@ -ifdef(PROPER). %% Proper is not supported. -else. +-ifdef(TRIQ). +%% Proper is not supported. +-else. + -include_lib("eqc/include/eqc.hrl"). -include_lib("eqc/include/eqc_statem.hrl"). @@ -600,3 +604,4 @@ erase_dir(Dir) -> file:del_dir(Dir). -endif. +-endif. diff --git a/lib/ssh/test/property_test/ssh_eqc_encode_decode.erl b/lib/ssh/test/property_test/ssh_eqc_encode_decode.erl index 6ddf2c9972..34630bdc91 100644 --- a/lib/ssh/test/property_test/ssh_eqc_encode_decode.erl +++ b/lib/ssh/test/property_test/ssh_eqc_encode_decode.erl @@ -22,20 +22,36 @@ -compile(export_all). +-proptest(eqc). +-proptest([triq,proper]). + +-include_lib("ct_property_test.hrl"). + -ifndef(EQC). -ifndef(PROPER). +-ifndef(TRIQ). -define(EQC,true). %%-define(PROPER,true). +%%-define(TRIQ,true). +-endif. -endif. -endif. -ifdef(EQC). -include_lib("eqc/include/eqc.hrl"). -define(MOD_eqc,eqc). + -else. -ifdef(PROPER). -include_lib("proper/include/proper.hrl"). -define(MOD_eqc,proper). + +-else. +-ifdef(TRIQ). +-define(MOD_eqc,triq). +-include_lib("triq/include/triq.hrl"). + +-endif. -endif. -endif. diff --git a/lib/ssh/test/ssh_property_test_SUITE.erl b/lib/ssh/test/ssh_property_test_SUITE.erl index c6c63d7367..ffad8ebbb7 100644 --- a/lib/ssh/test/ssh_property_test_SUITE.erl +++ b/lib/ssh/test/ssh_property_test_SUITE.erl @@ -57,10 +57,8 @@ init_per_suite(Config) -> %%% if we run proper. init_per_group(client_server, Config) -> case ?config(property_test_tool,Config) of - proper -> - {skip, "PropEr is not supported"}; - eqc -> - Config + eqc -> Config; + X -> {skip, lists:concat([X," is not supported"])} end; init_per_group(_, Config) -> Config. -- cgit v1.2.3