From eaaeb3dab48ba3dde62281e21f773148e30bc7fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 7 Apr 2017 10:31:41 +0200
Subject: Teach filelib_SUITE to work when STDLIB is cover-compiled

filelib_SUITE:find_source/1 would fail when running the tests
with STDLIB cover-compiled.
---
 lib/stdlib/test/filelib_SUITE.erl | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'lib')

diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl
index 87fba815d2..6133a3ded4 100644
--- a/lib/stdlib/test/filelib_SUITE.erl
+++ b/lib/stdlib/test/filelib_SUITE.erl
@@ -507,7 +507,12 @@ file_props_symlink(Config) ->
     end.
 
 find_source(Config) when is_list(Config) ->
-    BeamFile = code:which(lists),
+    %% filename:find_{file,source}() does not work if the files are
+    %% cover-compiled. To make sure that the test does not fail
+    %% when the STDLIB is cover-compiled, search for modules in
+    %% the compiler application.
+
+    BeamFile = code:which(compile),
     BeamName = filename:basename(BeamFile),
     BeamDir = filename:dirname(BeamFile),
     SrcName = filename:basename(BeamFile, ".beam") ++ ".erl",
@@ -530,7 +535,7 @@ find_source(Config) when is_list(Config) ->
     {error, not_found} = filelib:find_source(BeamName, BeamDir,
                                               [{".erl",".yrl",[{"",""}]}]),
 
-    {ok, ParserErl} = filelib:find_source(code:which(erl_parse)),
+    {ok, ParserErl} = filelib:find_source(code:which(core_parse)),
     {ok, ParserYrl} = filelib:find_source(ParserErl),
     "lry." ++ _ = lists:reverse(ParserYrl),
     {ok, ParserYrl} = filelib:find_source(ParserErl,
-- 
cgit v1.2.3