diff options
author | Siri Hansen <[email protected]> | 2017-02-16 17:17:06 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2017-02-20 12:40:09 +0100 |
commit | 1a5ba828bf7dda17bdd874b837a3dc8898952d6c (patch) | |
tree | 320344ae40f27edfb9ba405dd6b62d9e303b6901 /lib/common_test | |
parent | 8151495812ffabf560958e5434d3edbe46f29695 (diff) | |
download | otp-1a5ba828bf7dda17bdd874b837a3dc8898952d6c.tar.gz otp-1a5ba828bf7dda17bdd874b837a3dc8898952d6c.tar.bz2 otp-1a5ba828bf7dda17bdd874b837a3dc8898952d6c.zip |
[ct] Remove excessive skipped/failed tag in hook function
When skipping or failing in a configuration function, the
configuration function itself would get {auto_skipped,Reason},
{skipped,Reason} or {failed,Reason} in the hook callbacks on_tc_skip
or on_tc_fail. The other test cases that were skipped as a result of
this would only get Reason in the hook callbacks. This is now
corrected.
Diffstat (limited to 'lib/common_test')
-rw-r--r-- | lib/common_test/src/ct_framework.erl | 26 | ||||
-rw-r--r-- | lib/common_test/test/ct_hooks_SUITE.erl | 67 |
2 files changed, 43 insertions, 50 deletions
diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index dca3b8b5a2..43f1c9de0f 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -1386,25 +1386,25 @@ report(What,Data) -> ok; tc_done -> {Suite,{Func,GrName},Result} = Data, - Data1 = if GrName == undefined -> {Suite,Func,Result}; - true -> Data - end, + FuncSpec = if GrName == undefined -> Func; + true -> {Func,GrName} + end, %% Register the group leader for the process calling the report %% function, making it possible for a hook function to print %% in the test case log file ReportingPid = self(), ct_logs:register_groupleader(ReportingPid, group_leader()), case Result of - {failed, _} -> - ct_hooks:on_tc_fail(What, Data1); - {skipped,{failed,{_,init_per_testcase,_}}} -> - ct_hooks:on_tc_skip(tc_auto_skip, Data1); - {skipped,{require_failed,_}} -> - ct_hooks:on_tc_skip(tc_auto_skip, Data1); - {skipped,_} -> - ct_hooks:on_tc_skip(tc_user_skip, Data1); - {auto_skipped,_} -> - ct_hooks:on_tc_skip(tc_auto_skip, Data1); + {failed, Reason} -> + ct_hooks:on_tc_fail(What, {Suite,FuncSpec,Reason}); + {skipped,{failed,{_,init_per_testcase,_}}=Reason} -> + ct_hooks:on_tc_skip(tc_auto_skip, {Suite,FuncSpec,Reason}); + {skipped,{require_failed,_}=Reason} -> + ct_hooks:on_tc_skip(tc_auto_skip, {Suite,FuncSpec,Reason}); + {skipped,Reason} -> + ct_hooks:on_tc_skip(tc_user_skip, {Suite,FuncSpec,Reason}); + {auto_skipped,Reason} -> + ct_hooks:on_tc_skip(tc_auto_skip, {Suite,FuncSpec,Reason}); _Else -> ok end, diff --git a/lib/common_test/test/ct_hooks_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE.erl index 7c589cea4f..93bcb8fe52 100644 --- a/lib/common_test/test/ct_hooks_SUITE.erl +++ b/lib/common_test/test/ct_hooks_SUITE.erl @@ -720,7 +720,7 @@ test_events(fail_pre_suite_cth) -> {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite, {failed, {error,"Test failure"}}}}, {?eh,cth,{'_',on_tc_fail, - [ct_cth_empty_SUITE,init_per_suite,{failed,"Test failure"},[]]}}, + [ct_cth_empty_SUITE,init_per_suite,"Test failure",[]]}}, {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case, @@ -773,7 +773,7 @@ test_events(fail_post_suite_cth) -> {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite, {failed,{error,"Test failure"}}}}, - {?eh,cth,{'_',on_tc_fail,[ct_cth_empty_SUITE,init_per_suite, {failed,"Test failure"}, []]}}, + {?eh,cth,{'_',on_tc_fail,[ct_cth_empty_SUITE,init_per_suite, "Test failure", []]}}, {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case, {failed,{ct_cth_empty_SUITE,init_per_suite, @@ -800,7 +800,7 @@ test_events(skip_pre_suite_cth) -> {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist',{skip,"Test skip"},[]]}}, {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,{skipped,"Test skip"}}}, {?eh,cth,{'_',on_tc_skip, - [ct_cth_empty_SUITE,init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}}, + [ct_cth_empty_SUITE,init_per_suite,{tc_user_skip,"Test skip"},[]]}}, {?eh,tc_user_skip,{ct_cth_empty_SUITE,test_case,"Test skip"}}, {?eh,cth,{'_',on_tc_skip,[ct_cth_empty_SUITE,test_case,{tc_user_skip,"Test skip"},[]]}}, @@ -837,14 +837,14 @@ test_events(skip_pre_end_cth) -> {skipped,"Test skip"}}}], {?eh,cth,{'_',on_tc_skip,[ct_scope_per_group_cth_SUITE, {end_per_group,group1}, - {tc_user_skip,{skipped,"Test skip"}}, + {tc_user_skip,"Test skip"}, []]}}, {?eh,tc_start,{ct_scope_per_group_cth_SUITE,end_per_suite}}, {?eh,tc_done,{ct_scope_per_group_cth_SUITE,end_per_suite, {skipped,"Test skip"}}}, {?eh,cth,{'_',on_tc_skip,[ct_scope_per_group_cth_SUITE, end_per_suite, - {tc_user_skip,{skipped,"Test skip"}}, + {tc_user_skip,"Test skip"}, []]}}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,cth,{'_',terminate,[[]]}}, @@ -862,7 +862,7 @@ test_events(skip_post_suite_cth) -> {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}, {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,{skipped,"Test skip"}}}, {?eh,cth,{'_',on_tc_skip, - [ct_cth_empty_SUITE,init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}}, + [ct_cth_empty_SUITE,init_per_suite,{tc_user_skip,"Test skip"},[]]}}, {?eh,tc_user_skip,{ct_cth_empty_SUITE,test_case,"Test skip"}}, {?eh,cth,{'_',on_tc_skip,[ct_cth_empty_SUITE,test_case,{tc_user_skip,"Test skip"},[]]}}, @@ -896,7 +896,7 @@ test_events(skip_pre_init_tc_cth) -> {skipped,"Skipped in pre_init_per_testcase"}}}, {?eh,cth,{empty_cth,on_tc_skip, [ct_cth_empty_SUITE,test_case, - {tc_user_skip,{skipped,"Skipped in pre_init_per_testcase"}}, + {tc_user_skip,"Skipped in pre_init_per_testcase"}, []]}}, {?eh,test_stats,{0,0,{1,0}}}, {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}}, @@ -1185,11 +1185,11 @@ test_events(fail_n_skip_with_minimal_cth) -> {?eh,tc_done,{ct_cth_fail_one_skip_one_SUITE,test_case3,{skipped,"skip it"}}}, {?eh,cth,{empty_cth,on_tc_skip,[ct_cth_fail_one_skip_one_SUITE, {test_case2,group2}, - {tc_user_skip,{skipped,"skip it"}}, + {tc_user_skip,"skip it"}, []]}}, {?eh,cth,{empty_cth,on_tc_skip,[ct_cth_fail_one_skip_one_SUITE, {test_case3,group2}, - {tc_user_skip,{skipped,"skip it"}}, + {tc_user_skip,"skip it"}, []]}}, {?eh,tc_start,{ct_cth_fail_one_skip_one_SUITE,{end_per_group, group2,[parallel]}}}, @@ -1350,7 +1350,7 @@ test_events(no_init_suite_config) -> {failed,{error,{undef,'_'}}}}}, {?eh,cth,{empty_cth,on_tc_fail,[ct_no_init_suite_config_SUITE, init_per_suite, - {failed,{undef,'_'}},[]]}}, + {undef,'_'},[]]}}, {?eh,tc_auto_skip,{ct_no_init_suite_config_SUITE,test_case, {failed,{ct_no_init_suite_config_SUITE,init_per_suite, {'EXIT',{undef,'_'}}}}}}, @@ -1405,7 +1405,7 @@ test_events(no_init_config) -> {failed,{error,{undef,'_'}}}}}, {?eh,cth,{empty_cth,on_tc_fail,[ct_no_init_config_SUITE, {init_per_group,test_group}, - {failed,{undef,'_'}},[]]}}, + {undef,'_'},[]]}}, {?eh,tc_auto_skip,{ct_no_init_config_SUITE,{test_case_2,test_group}, {failed,{ct_no_init_config_SUITE,init_per_group, {'EXIT',{undef,'_'}}}}}}, @@ -1482,7 +1482,7 @@ test_events(no_end_config) -> {failed,{error,{undef,'_'}}}}}, {?eh,cth,{empty_cth,on_tc_fail,[ct_no_end_config_SUITE, {end_per_group,test_group}, - {failed,{undef,'_'}},[]]}}], + {undef,'_'},[]]}}], {?eh,tc_start,{ct_no_end_config_SUITE,end_per_suite}}, {?eh,cth,{empty_cth,pre_end_per_suite, [ct_no_end_config_SUITE,'$proplist',[]]}}, @@ -1619,7 +1619,7 @@ test_events(fallback) -> {skipped,"Skipped in init_per_testcase/2"}}}, {?eh,cth,{empty_cth,on_tc_skip, [fallback_nosuite,skip_case, - {tc_user_skip,{skipped,"Skipped in init_per_testcase/2"}}, + {tc_user_skip,"Skipped in init_per_testcase/2"}, []]}}, {?eh,test_stats,{2,0,{1,0}}}, {?eh,tc_start,{all_hook_callbacks_SUITE,end_per_suite}}, @@ -1671,7 +1671,7 @@ test_events(callbacks_on_skip) -> {skipped,"Skipped in init_per_suite/1"}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_init_SUITE,init_per_suite, - {tc_user_skip,{skipped,"Skipped in init_per_suite/1"}}, + {tc_user_skip,"Skipped in init_per_suite/1"}, []]}}, {?eh,tc_user_skip,{skip_init_SUITE,test_case,"Skipped in init_per_suite/1"}}, {?eh,cth,{empty_cth,on_tc_skip, @@ -1695,8 +1695,8 @@ test_events(callbacks_on_skip) -> {not_available,whatever}}}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_req_SUITE,init_per_suite, - {tc_auto_skip,{auto_skipped,{require_failed_in_suite0, - {not_available,whatever}}}}, + {tc_auto_skip,{require_failed_in_suite0, + {not_available,whatever}}}, []]}}, {?eh,tc_auto_skip,{skip_req_SUITE,test_case,{require_failed_in_suite0, {not_available,whatever}}}}, @@ -1724,8 +1724,7 @@ test_events(callbacks_on_skip) -> {?eh,cth,{empty_cth,on_tc_skip, [skip_fail_SUITE,init_per_suite, {tc_auto_skip, - {auto_skipped, - {failed,{error,{suite0_failed,bad_return_value}}}}}, + {failed,{error,{suite0_failed,bad_return_value}}}}, []]}}, {?eh,tc_auto_skip,{skip_fail_SUITE,test_case, {failed,{error,{suite0_failed,bad_return_value}}}}}, @@ -1764,8 +1763,7 @@ test_events(callbacks_on_skip) -> {?eh,cth,{empty_cth,on_tc_skip, [skip_group_SUITE, {init_per_group,test_group_1}, - {tc_auto_skip, - {auto_skipped,{require_failed,{not_available,whatever}}}}, + {tc_auto_skip,{require_failed,{not_available,whatever}}}, []]}}, {?eh,tc_auto_skip,{skip_group_SUITE,{test_case,test_group_1}, {require_failed,{not_available,whatever}}}}, @@ -1796,8 +1794,7 @@ test_events(callbacks_on_skip) -> {?eh,cth,{empty_cth,on_tc_skip, [skip_group_SUITE, {init_per_group,test_group_2}, - {tc_auto_skip, - {auto_skipped,{group0_failed,bad_return_value}}}, + {tc_auto_skip,{group0_failed,bad_return_value}}, []]}}, {?eh,tc_auto_skip,{skip_group_SUITE,{test_case,test_group_2}, {group0_failed,bad_return_value}}}, @@ -1829,7 +1826,7 @@ test_events(callbacks_on_skip) -> {?eh,cth,{empty_cth,on_tc_skip, [skip_group_SUITE, {init_per_group,test_group_3}, - {tc_user_skip,{skipped,"Skipped in init_per_group/2"}}, + {tc_user_skip,"Skipped in init_per_group/2"}, []]}}, {?eh,tc_user_skip,{skip_group_SUITE, {test_case,test_group_3}, @@ -1899,7 +1896,7 @@ test_events(callbacks_on_skip) -> {skipped,"Skipped in init_per_testcase/2"}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_case_SUITE,skip_in_init, - {tc_user_skip,{skipped,"Skipped in init_per_testcase/2"}}, + {tc_user_skip,"Skipped in init_per_testcase/2"}, []]}}, {?eh,test_stats,{0,0,{5,4}}}, @@ -1919,7 +1916,7 @@ test_events(callbacks_on_skip) -> {auto_skipped,{failed,'_'}}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_case_SUITE,fail_in_init, - {tc_auto_skip,{auto_skipped,{failed,'_'}}}, + {tc_auto_skip,{failed,'_'}}, []]}}, {?eh,test_stats,{0,0,{5,5}}}, @@ -1939,7 +1936,7 @@ test_events(callbacks_on_skip) -> {auto_skipped,{failed,'_'}}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_case_SUITE,exit_in_init, - {tc_auto_skip,{auto_skipped,{failed,'_'}}}, + {tc_auto_skip,{failed,'_'}}, []]}}, {?eh,test_stats,{0,0,{5,6}}}, @@ -2026,7 +2023,7 @@ test_events(callbacks_on_skip) -> {skipped,"Skipped in test case function"}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_case_SUITE,skip_in_case, - {tc_user_skip,{skipped,"Skipped in test case function"}}, + {tc_user_skip,"Skipped in test case function"}, []]}}, {?eh,test_stats,{2,0,{6,6}}}, @@ -2037,8 +2034,7 @@ test_events(callbacks_on_skip) -> {auto_skipped,{require_failed,{not_available,whatever}}}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_case_SUITE,req_auto_skip, - {tc_auto_skip, - {auto_skipped,{require_failed,{not_available,whatever}}}}, + {tc_auto_skip,{require_failed,{not_available,whatever}}}, []]}}, {?eh,test_stats,{2,0,{6,7}}}, @@ -2049,8 +2045,7 @@ test_events(callbacks_on_skip) -> {auto_skipped,{testcase0_failed,bad_return_value}}}}, {?eh,cth,{empty_cth,on_tc_skip, [skip_case_SUITE,fail_auto_skip, - {tc_auto_skip, - {auto_skipped,{testcase0_failed,bad_return_value}}}, + {tc_auto_skip,{testcase0_failed,bad_return_value}}, []]}}, {?eh,test_stats,{2,0,{6,8}}}, @@ -2100,15 +2095,14 @@ test_events(failed_sequence) -> {error,failed_on_purpose},[]]}}, {?eh,tc_done,{seq_SUITE,test_case_1,{failed,{error,failed_on_purpose}}}}, {?eh,cth,{empty_cth,on_tc_fail, - [seq_SUITE,test_case_1,{failed,failed_on_purpose},[]]}}, + [seq_SUITE,test_case_1,failed_on_purpose,[]]}}, {?eh,test_stats,{0,1,{0,0}}}, {?eh,tc_start,{seq_SUITE,test_case_2}}, {?eh,tc_done,{seq_SUITE,test_case_2, {auto_skipped,{sequence_failed,seq1,test_case_1}}}}, {?eh,cth,{empty_cth,on_tc_skip, [seq_SUITE,test_case_2, - {tc_auto_skip, - {auto_skipped,{sequence_failed,seq1,test_case_1}}}, + {tc_auto_skip,{sequence_failed,seq1,test_case_1}}, []]}}, {?eh,test_stats,{0,1,{0,1}}}, {?eh,tc_start,{ct_framework,end_per_suite}}, @@ -2156,8 +2150,7 @@ test_events(repeat_force_stop) -> "Repeated test stopped by force_stop option"}}}, {?eh,cth,{empty_cth,on_tc_skip, [repeat_SUITE,test_case_2, - {tc_auto_skip, - {auto_skipped,"Repeated test stopped by force_stop option"}}, + {tc_auto_skip,"Repeated test stopped by force_stop option"}, []]}}, {?eh,test_stats,{1,0,{0,1}}}, {?eh,tc_start,{ct_framework,end_per_suite}}, @@ -2195,7 +2188,7 @@ test_events(config_clash) -> {failed,{error,{config_name_already_in_use,[aa]}}}}}, {?eh,cth,{empty_cth,on_tc_fail, [config_clash_SUITE,test_case_1, - {failed,{config_name_already_in_use,[aa]}}, + {config_name_already_in_use,[aa]}, []]}}, {?eh,test_stats,{0,1,{0,0}}}, {?eh,tc_start,{ct_framework,end_per_suite}}, |