aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2014-09-18 16:50:22 +0200
committerSiri Hansen <[email protected]>2014-09-18 16:57:41 +0200
commit98a837d7f739090241bd6c883c29438434b66563 (patch)
tree30d80c9e605b42cde09582de63d01219f607fb4a /lib
parent6ec976bd70a657efea2d5d714e0d470aeb86bb50 (diff)
downloadotp-98a837d7f739090241bd6c883c29438434b66563.tar.gz
otp-98a837d7f739090241bd6c883c29438434b66563.tar.bz2
otp-98a837d7f739090241bd6c883c29438434b66563.zip
[ct] Fix path of cover export/import files
5a3c4668 accidentially changed the base directory for cover export and import files, if given as relative paths. This commit fixes this - the files are again expected to be given relative to the directory of the cover spec file itself, or else as absolute paths.
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/src/ct_cover.erl18
-rw-r--r--lib/common_test/test/ct_cover_SUITE.erl17
2 files changed, 25 insertions, 10 deletions
diff --git a/lib/common_test/src/ct_cover.erl b/lib/common_test/src/ct_cover.erl
index cf2860ae25..c7f446dee9 100644
--- a/lib/common_test/src/ct_cover.erl
+++ b/lib/common_test/src/ct_cover.erl
@@ -128,20 +128,20 @@ get_spec(File) ->
catch get_spec_test(File).
get_spec_test(File) ->
- FullName = filename:absname(File),
- case filelib:is_file(FullName) of
+ Dir = filename:dirname(File), % always abs path in here, set in ct_run
+ case filelib:is_file(File) of
true ->
- case file:consult(FullName) of
+ case file:consult(File) of
{ok,Terms} ->
Import =
case lists:keysearch(import, 1, Terms) of
{value,{_,Imps=[S|_]}} when is_list(S) ->
ImpsFN = lists:map(fun(F) ->
- filename:absname(F)
+ filename:absname(F,Dir)
end, Imps),
test_files(ImpsFN, ImpsFN);
{value,{_,Imp=[IC|_]}} when is_integer(IC) ->
- ImpFN = filename:absname(Imp),
+ ImpFN = filename:absname(Imp,Dir),
test_files([ImpFN], [ImpFN]);
_ ->
[]
@@ -149,9 +149,9 @@ get_spec_test(File) ->
Export =
case lists:keysearch(export, 1, Terms) of
{value,{_,Exp=[EC|_]}} when is_integer(EC) ->
- filename:absname(Exp);
+ filename:absname(Exp,Dir);
{value,{_,[Exp]}} ->
- filename:absname(Exp);
+ filename:absname(Exp,Dir);
_ ->
undefined
end,
@@ -179,7 +179,7 @@ get_spec_test(File) ->
E;
[CoverSpec] ->
CoverSpec1 = remove_excludes_and_dups(CoverSpec),
- {FullName,Nodes,Import,Export,CoverSpec1};
+ {File,Nodes,Import,Export,CoverSpec1};
_ ->
{error,multiple_apps_in_cover_spec}
end;
@@ -190,7 +190,7 @@ get_spec_test(File) ->
{error,{invalid_cover_spec,Error}}
end;
false ->
- {error,{cant_read_cover_spec_file,FullName}}
+ {error,{cant_read_cover_spec_file,File}}
end.
collect_apps([{level,Level}|Ts], Apps) ->
diff --git a/lib/common_test/test/ct_cover_SUITE.erl b/lib/common_test/test/ct_cover_SUITE.erl
index 47080b5577..87ba4ae1b9 100644
--- a/lib/common_test/test/ct_cover_SUITE.erl
+++ b/lib/common_test/test/ct_cover_SUITE.erl
@@ -76,7 +76,8 @@ all() ->
cover_node_option,
ct_cover_add_remove_nodes,
otp_9956,
- cross
+ cross,
+ export_import
].
%%--------------------------------------------------------------------
@@ -199,6 +200,20 @@ cross(Config) ->
ok.
+export_import(Config) ->
+ DataDir = ?config(data_dir,Config),
+ false = check_cover(Config),
+ CoverSpec1 =
+ default_cover_file_content() ++ [{export,"export_import.coverdata"}],
+ CoverFile1 = create_cover_file(export_import1,CoverSpec1,Config),
+ {ok,Events1} = run_test(export_import1,default,[{cover,CoverFile1}],Config),
+ check_calls(Events1,1),
+ CoverSpec2 =
+ default_cover_file_content() ++ [{import,"export_import.coverdata"}],
+ CoverFile2 = create_cover_file(export_import2,CoverSpec2,Config),
+ {ok,Events2} = run_test(export_import2,default,[{cover,CoverFile2}],Config),
+ check_calls(Events2,2),
+ ok.
%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS