aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-02-07 10:21:21 +0000
committerErlang/OTP <[email protected]>2010-02-07 10:21:21 +0000
commitea35770a586005025c770d514ffd4c3477075cf8 (patch)
tree09061f4f9aaebd7a89388806b6ed12a692f31f0d
parentc6bf34b7035a6292650babf2eb8af80c19256fab (diff)
parentc3902211043c449a2fc3830291ff2fd64d0cd4ee (diff)
downloadotp-ea35770a586005025c770d514ffd4c3477075cf8.tar.gz
otp-ea35770a586005025c770d514ffd4c3477075cf8.tar.bz2
otp-ea35770a586005025c770d514ffd4c3477075cf8.zip
Merge branch 'ta/code_clash_ez' into ccase/r13b04_dev
* ta/code_clash_ez: code_SUITE: add missing is_list(Config) guard Add tests for code:clash/0 Fix handling of archive (.ez) files in code:clash/0 OTP-8413 code:clash/0 now looks inside archives (.ez files). (Thanks to Tuncer Ayaz.)
-rw-r--r--lib/kernel/src/code.erl3
-rw-r--r--lib/kernel/test/code_SUITE.erl38
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ezbin0 -> 505 bytes
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam1
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam1
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/zork-0.8.ezbin0 -> 492 bytes
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam1
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam1
8 files changed, 41 insertions, 4 deletions
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index 89d893f8c1..ffe58ae7a9 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -465,7 +465,8 @@ search([{Dir, File} | Tail]) ->
build([]) -> [];
build([Dir|Tail]) ->
- Files = filter(objfile_extension(), Dir, file:list_dir(Dir)),
+ Files = filter(objfile_extension(), Dir,
+ erl_prim_loader:list_dir(Dir)),
[decorate(Files, Dir) | build(Tail)].
decorate([], _) -> [];
diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index 8e1e3d5390..37b9200942 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -26,7 +26,7 @@
delete/1, purge/1, soft_purge/1, is_loaded/1, all_loaded/1,
load_binary/1, dir_req/1, object_code/1, set_path_file/1,
sticky_dir/1, pa_pz_option/1, add_del_path/1,
- dir_disappeared/1, ext_mod_dep/1,
+ dir_disappeared/1, ext_mod_dep/1, clash/1,
load_cached/1, start_node_with_cache/1, add_and_rehash/1,
where_is_file_cached/1, where_is_file_no_cache/1,
purge_stacktrace/1, mult_lib_roots/1, bad_erl_libs/1,
@@ -48,7 +48,7 @@ all(suite) ->
delete, purge, soft_purge, is_loaded, all_loaded,
load_binary, dir_req, object_code, set_path_file,
pa_pz_option, add_del_path,
- dir_disappeared, ext_mod_dep,
+ dir_disappeared, ext_mod_dep, clash,
load_cached, start_node_with_cache, add_and_rehash,
where_is_file_no_cache, where_is_file_cached,
purge_stacktrace, mult_lib_roots, bad_erl_libs,
@@ -531,7 +531,7 @@ pa_pz_option(Config) when is_list(Config) ->
add_del_path(suite) ->
[];
add_del_path(doc) -> ["add_path, del_path should not cause priv_dir(App) to fail"];
-add_del_path(Config) ->
+add_del_path(Config) when is_list(Config) ->
DDir = ?config(data_dir,Config),
Dir1 = filename:join(DDir,"dummy_app-1.0/ebin"),
Dir2 = filename:join(DDir,"dummy_app-2.0/ebin"),
@@ -545,6 +545,38 @@ add_del_path(Config) ->
ok.
+clash(Config) when is_list(Config) ->
+ DDir = ?config(data_dir,Config)++"clash/",
+ P = code:get_path(),
+
+ %% test non-clashing entries
+
+ %% remove "." to prevent clash with test-server path
+ ?line true = code:del_path("."),
+ ?line true = code:add_path(DDir++"foobar-0.1/ebin"),
+ ?line true = code:add_path(DDir++"zork-0.8/ebin"),
+ ?line test_server:capture_start(),
+ ?line code:clash(),
+ ?line test_server:capture_stop(),
+ ?line OKMsg = test_server:capture_get(),
+ ?line lists:prefix("** Found 0 name clashes in code paths", OKMsg),
+ ?line true = code:set_path(P),
+
+ %% test clashing entries
+
+ %% remove "." to prevent clash with test-server path
+ ?line true = code:del_path("."),
+ ?line true = code:add_path(DDir++"foobar-0.1/ebin"),
+ ?line true = code:add_path(DDir++"foobar-0.1.ez/foobar-0.1/ebin"),
+ ?line test_server:capture_start(),
+ ?line code:clash(),
+ ?line test_server:capture_stop(),
+ ?line [ErrMsg1|_] = test_server:capture_get(),
+ ?line {match, [" hides "]} = re:run(ErrMsg1, "\\*\\* .*( hides ).*",
+ [{capture,all_but_first,list}]),
+ ?line true = code:set_path(P),
+ ok.
+
ext_mod_dep(suite) ->
[];
ext_mod_dep(doc) ->
diff --git a/lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ez b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ez
new file mode 100644
index 0000000000..33d8a59b92
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ez
Binary files differ
diff --git a/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam
new file mode 100644
index 0000000000..da87f32b9f
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam
@@ -0,0 +1 @@
+baz 298734
diff --git a/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam
new file mode 100644
index 0000000000..e4c70c267c
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam
@@ -0,0 +1 @@
+baz 86234
diff --git a/lib/kernel/test/code_SUITE_data/clash/zork-0.8.ez b/lib/kernel/test/code_SUITE_data/clash/zork-0.8.ez
new file mode 100644
index 0000000000..051fa1efe4
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/zork-0.8.ez
Binary files differ
diff --git a/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam
new file mode 100644
index 0000000000..7b292c0b44
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam
@@ -0,0 +1 @@
+baz 23784
diff --git a/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam
new file mode 100644
index 0000000000..7b2f6a850f
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam
@@ -0,0 +1 @@
+baz 3246238