From 81354ca6651ff23ecff8dc93e1db13c115bb8369 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Mon, 20 Apr 2015 10:06:24 +0200
Subject: test suites: Unload modules compiled from .core or .S

The .core or .S files that are compiled in the test cases
may lack module_info/0,1 functions, which will cause problems if
we (for example) try to run eprof later. To avoid that problem,
unload each module directly after testing it.
---
 lib/compiler/test/core_SUITE.erl      |  5 ++++-
 lib/compiler/test/core_fold_SUITE.erl | 20 +++++++++++---------
 lib/compiler/test/guard_SUITE.erl     |  2 ++
 3 files changed, 17 insertions(+), 10 deletions(-)

(limited to 'lib/compiler')

diff --git a/lib/compiler/test/core_SUITE.erl b/lib/compiler/test/core_SUITE.erl
index 428ad65364..471f8dc558 100644
--- a/lib/compiler/test/core_SUITE.erl
+++ b/lib/compiler/test/core_SUITE.erl
@@ -87,4 +87,7 @@ try_it(Mod, Conf) ->
 compile_and_load(Src, Opts) ->
     {ok,Mod,Bin} = compile:file(Src, [from_core,report,time,binary|Opts]),
     {module,Mod} = code:load_binary(Mod, Mod, Bin),
-    ok = Mod:Mod().
+    ok = Mod:Mod(),
+    _ = code:delete(Mod),
+    _ = code:purge(Mod),
+    ok.
diff --git a/lib/compiler/test/core_fold_SUITE.erl b/lib/compiler/test/core_fold_SUITE.erl
index bc82eaf5aa..a722f97e81 100644
--- a/lib/compiler/test/core_fold_SUITE.erl
+++ b/lib/compiler/test/core_fold_SUITE.erl
@@ -231,15 +231,17 @@ eq(Config) when is_list(Config) ->
 
 %% OTP-7117.
 nested_call_in_case(Config) when is_list(Config) ->
-    ?line PrivDir = ?config(priv_dir, Config),
-    ?line Dir = filename:dirname(code:which(?MODULE)),
-    ?line Core = filename:join(Dir, "nested_call_in_case"),
-    ?line Opts = [from_core,{outdir,PrivDir}|test_lib:opt_opts(?MODULE)],
-    ?line io:format("~p", [Opts]),
-    ?line {ok,Mod} = c:c(Core, Opts),
-    ?line yes = Mod:a([1,2,3], 2),
-    ?line no = Mod:a([1,2,3], 4),
-    ?line {'EXIT',_} = (catch Mod:a(not_a_list, 42)),
+    PrivDir = ?config(priv_dir, Config),
+    Dir = filename:dirname(code:which(?MODULE)),
+    Core = filename:join(Dir, "nested_call_in_case"),
+    Opts = [from_core,{outdir,PrivDir}|test_lib:opt_opts(?MODULE)],
+    io:format("~p", [Opts]),
+    {ok,Mod} = c:c(Core, Opts),
+    yes = Mod:a([1,2,3], 2),
+    no = Mod:a([1,2,3], 4),
+    {'EXIT',_} = (catch Mod:a(not_a_list, 42)),
+    _ = code:delete(Mod),
+    _ = code:purge(Mod),
     ok.
 
 guard_try_catch(_Config) ->
diff --git a/lib/compiler/test/guard_SUITE.erl b/lib/compiler/test/guard_SUITE.erl
index 08279d9408..d91ee7ea08 100644
--- a/lib/compiler/test/guard_SUITE.erl
+++ b/lib/compiler/test/guard_SUITE.erl
@@ -1614,6 +1614,8 @@ t_tuple_size(Config) when is_list(Config) ->
     ?line {ok,Mod,Code} = compile:file(File, [from_asm,binary]),
     ?line code:load_binary(Mod, File, Code),
     ?line 14 = Mod:t({1,2,3,4}),
+    _ = code:delete(Mod),
+    _ = code:purge(Mod),
     
     ok.
 
-- 
cgit v1.2.3