Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit bab1d6b

Browse files
committed
rabbit_ct_helpers: Rename config_to_testcase_name() to testcase_absname()
Also, accept an empty string to the testcase name, so the path to the group is formatted. Finally, optionally accept the separator to use in the path.
1 parent 4ebfc27 commit bab1d6b

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/rabbit_ct_helpers.erl

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
config_to_testcase_name/2,
3030
testcases/1,
3131
testcase_number/3,
32+
testcase_absname/2, testcase_absname/3,
3233
testcase_started/2, testcase_finished/2,
3334
exec/1, exec/2,
3435
make/3,
@@ -320,20 +321,34 @@ testcase_finished(Config, Testcase) ->
320321
Config.
321322

322323
config_to_testcase_name(Config, Testcase) ->
324+
testcase_absname(Config, Testcase).
325+
326+
testcase_absname(Config, Testcase) ->
327+
testcase_absname(Config, Testcase, "/").
328+
329+
testcase_absname(Config, Testcase, Sep) ->
323330
Name = rabbit_misc:format("~s", [Testcase]),
324331
case get_config(Config, tc_group_properties) of
325332
[] ->
326333
Name;
327334
Props ->
328-
Name1 = rabbit_misc:format("~s/~s",
329-
[proplists:get_value(name, Props), Name]),
330-
config_to_testcase_name1(Name1, get_config(Config, tc_group_path))
335+
Name1 = case Name of
336+
"" ->
337+
rabbit_misc:format("~s",
338+
[proplists:get_value(name, Props)]);
339+
_ ->
340+
rabbit_misc:format("~s~s~s",
341+
[proplists:get_value(name, Props), Sep, Name])
342+
end,
343+
testcase_absname1(Name1,
344+
get_config(Config, tc_group_path), Sep)
331345
end.
332346

333-
config_to_testcase_name1(Name, [Props | Rest]) ->
334-
Name1 = rabbit_misc:format("~s/~s", [proplists:get_value(name, Props), Name]),
335-
config_to_testcase_name1(Name1, Rest);
336-
config_to_testcase_name1(Name, []) ->
347+
testcase_absname1(Name, [Props | Rest], Sep) ->
348+
Name1 = rabbit_misc:format("~s~s~s",
349+
[proplists:get_value(name, Props), Sep, Name]),
350+
testcase_absname1(Name1, Rest, Sep);
351+
testcase_absname1(Name, [], _) ->
337352
lists:flatten(Name).
338353

339354
testcases(Testsuite) ->

0 commit comments

Comments
 (0)