aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/kernel/src/logger.erl10
-rw-r--r--lib/kernel/src/logger_internal.hrl7
-rw-r--r--lib/kernel/test/logger_SUITE.erl2
-rw-r--r--lib/ssl/test/ssl_api_SUITE.erl6
-rw-r--r--lib/ssl/test/ssl_session_cache_SUITE.erl4
-rw-r--r--lib/ssl/test/tls_api_SUITE.erl6
-rw-r--r--lib/stdlib/src/filelib.erl32
-rw-r--r--lib/stdlib/test/filelib_SUITE.erl34
-rw-r--r--lib/syntax_tools/src/erl_syntax.erl48
-rw-r--r--lib/syntax_tools/test/syntax_tools_SUITE.erl38
-rw-r--r--lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl3
11 files changed, 146 insertions, 44 deletions
diff --git a/lib/kernel/src/logger.erl b/lib/kernel/src/logger.erl
index 38bd2f481c..fd02cf67bf 100644
--- a/lib/kernel/src/logger.erl
+++ b/lib/kernel/src/logger.erl
@@ -600,11 +600,11 @@ get_module_level() ->
%%%-----------------------------------------------------------------
%%% Misc
-spec compare_levels(Level1,Level2) -> eq | gt | lt when
- Level1 :: level(),
- Level2 :: level().
-compare_levels(Level,Level) when ?IS_LEVEL(Level) ->
+ Level1 :: level() | all | none,
+ Level2 :: level() | all | none.
+compare_levels(Level,Level) when ?IS_LEVEL_ALL(Level) ->
eq;
-compare_levels(Level1,Level2) when ?IS_LEVEL(Level1), ?IS_LEVEL(Level2) ->
+compare_levels(Level1,Level2) when ?IS_LEVEL_ALL(Level1), ?IS_LEVEL_ALL(Level2) ->
Int1 = logger_config:level_to_int(Level1),
Int2 = logger_config:level_to_int(Level2),
if Int1 < Int2 -> gt;
@@ -950,7 +950,7 @@ get_logger_type(Env) ->
get_logger_level() ->
case application:get_env(kernel,logger_level,info) of
- Level when ?IS_LEVEL(Level); Level=:=all; Level=:=none ->
+ Level when ?IS_LEVEL_ALL(Level) ->
Level;
Level ->
throw({logger_level, Level})
diff --git a/lib/kernel/src/logger_internal.hrl b/lib/kernel/src/logger_internal.hrl
index e53922e5d3..c2b2d419e7 100644
--- a/lib/kernel/src/logger_internal.hrl
+++ b/lib/kernel/src/logger_internal.hrl
@@ -86,7 +86,12 @@
L=:=warning orelse
L=:=notice orelse
L=:=info orelse
- L=:=debug)).
+ L=:=debug )).
+
+-define(IS_LEVEL_ALL(L),
+ ?IS_LEVEL(L) orelse
+ L=:=all orelse
+ L=:=none ).
-define(IS_MSG(Msg),
((is_tuple(Msg) andalso tuple_size(Msg)==2)
diff --git a/lib/kernel/test/logger_SUITE.erl b/lib/kernel/test/logger_SUITE.erl
index 035e5d8974..f8f3d27778 100644
--- a/lib/kernel/test/logger_SUITE.erl
+++ b/lib/kernel/test/logger_SUITE.erl
@@ -880,7 +880,7 @@ other_node(cleanup,_Config) ->
ok.
compare_levels(_Config) ->
- Levels = [emergency,alert,critical,error,warning,notice,info,debug],
+ Levels = [none,emergency,alert,critical,error,warning,notice,info,debug,all],
ok = compare(Levels),
{error,badarg} = ?TRY(logger:compare_levels(bad,bad)),
{error,badarg} = ?TRY(logger:compare_levels({bad},notice)),
diff --git a/lib/ssl/test/ssl_api_SUITE.erl b/lib/ssl/test/ssl_api_SUITE.erl
index fefecc0b65..14e5024b91 100644
--- a/lib/ssl/test/ssl_api_SUITE.erl
+++ b/lib/ssl/test/ssl_api_SUITE.erl
@@ -1251,8 +1251,9 @@ der_input(Config) when is_list(Config) ->
[_, _,_, _, Prop] = StatusInfo,
State = ssl_test_lib:state(Prop),
[CADb | _] = element(6, State),
-
+ ct:sleep(?SLEEP*2), %%Make sure there is no outstanding clean cert db msg in manager
Size = ets:info(CADb, size),
+ ct:pal("Size ~p", [Size]),
SeverVerifyOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),
{ServerCert, ServerKey, ServerCaCerts, DHParams} = der_input_opts([{dhfile, DHParamFile} |
@@ -1281,6 +1282,7 @@ der_input(Config) when is_list(Config) ->
ssl_test_lib:check_result(Server, ok, Client, ok),
ssl_test_lib:close(Server),
ssl_test_lib:close(Client),
+ %% Using only DER input should not increase file indexed DB
Size = ets:info(CADb, size).
%%--------------------------------------------------------------------
@@ -1902,7 +1904,7 @@ do_recv_close(Socket) ->
tls_close(Socket) ->
ok = ssl_test_lib:send_recv_result(Socket),
- case ssl:close(Socket, 5000) of
+ case ssl:close(Socket, 10000) of
ok ->
ok;
{error, closed} ->
diff --git a/lib/ssl/test/ssl_session_cache_SUITE.erl b/lib/ssl/test/ssl_session_cache_SUITE.erl
index b71b15b028..553c2d247b 100644
--- a/lib/ssl/test/ssl_session_cache_SUITE.erl
+++ b/lib/ssl/test/ssl_session_cache_SUITE.erl
@@ -28,7 +28,7 @@
-include_lib("common_test/include/ct.hrl").
-define(DELAY, 500).
--define(SLEEP, 500).
+-define(SLEEP, 1000).
-define(TIMEOUT, 60000).
-define(LONG_TIMEOUT, 600000).
-define(MAX_TABLE_SIZE, 5).
@@ -207,7 +207,7 @@ session_cleanup(Config) when is_list(Config) ->
end,
%% Make sure session is registered
- ct:sleep(?SLEEP),
+ ct:sleep(?SLEEP*2),
{status, _, _, StatusInfo} = sys:get_status(whereis(ssl_manager)),
[_, _,_, _, Prop] = StatusInfo,
diff --git a/lib/ssl/test/tls_api_SUITE.erl b/lib/ssl/test/tls_api_SUITE.erl
index 5a74ec1892..7239d4cb90 100644
--- a/lib/ssl/test/tls_api_SUITE.erl
+++ b/lib/ssl/test/tls_api_SUITE.erl
@@ -794,16 +794,16 @@ tls_downgrade_result(Socket, Pid) ->
{tcp, TCPSocket, <<"Downgraded">>} ->
ok;
{tcp_closed, TCPSocket} ->
- ct:fail("Peer timed out, downgrade aborted"),
+ ct:fail("Did not receive TCP data"),
ok;
Other ->
{error, Other}
end;
{error, timeout} ->
- ct:fail("Timed out, downgrade aborted"),
+ ct:comment("Timed out, downgrade aborted"),
ok;
Fail ->
- {error, Fail}
+ ct:fail(Fail)
end.
tls_shutdown_result(Socket, server) ->
diff --git a/lib/stdlib/src/filelib.erl b/lib/stdlib/src/filelib.erl
index de839be5cf..d1a5a4dc35 100644
--- a/lib/stdlib/src/filelib.erl
+++ b/lib/stdlib/src/filelib.erl
@@ -281,6 +281,14 @@ do_wildcard_2([], _, Result, _Mod) ->
do_wildcard_3(Base, [[double_star]|Rest], Result, Mod) ->
do_double_star(".", [Base], Rest, Result, Mod, true);
+do_wildcard_3(Base, [".."|Rest], Result, Mod) ->
+ case do_is_dir(Base, Mod) of
+ true ->
+ Matches = [filename:join(Base, "..")],
+ do_wildcard_2(Matches, Rest, Result, Mod);
+ false ->
+ Result
+ end;
do_wildcard_3(Base0, [Pattern|Rest], Result, Mod) ->
case do_list_dir(Base0, Mod) of
{ok, Files} ->
@@ -387,15 +395,29 @@ compile_wildcard(Pattern0, Cwd0) ->
end.
compile_wildcard_2([Part|Rest], Root) ->
- case compile_part(Part) of
- Part ->
- compile_wildcard_2(Rest, compile_join(Root, Part));
- Pattern ->
- compile_wildcard_3(Rest, [Pattern,Root])
+ Pattern = compile_part(Part),
+ case is_literal_pattern(Pattern) of
+ true ->
+ %% Add this literal pattern to the literal pattern prefix.
+ %% This is an optimization to avoid listing all files of
+ %% a directory only to discard all but one. For example,
+ %% without this optimizaton, there would be three
+ %% redundant directory listings when executing this
+ %% wildcard: "./lib/compiler/ebin/*.beam"
+ compile_wildcard_2(Rest, compile_join(Root, Pattern));
+ false ->
+ %% This is the end of the literal prefix. Compile the
+ %% rest of the pattern.
+ compile_wildcard_3(Rest, [Pattern,Root])
end;
compile_wildcard_2([], {root,PrefixLen,Root}) ->
{{exists,Root},PrefixLen}.
+is_literal_pattern([H|T]) ->
+ is_integer(H) andalso is_literal_pattern(T);
+is_literal_pattern([]) ->
+ true.
+
compile_wildcard_3([Part|Rest], Result) ->
compile_wildcard_3(Rest, [compile_part(Part)|Result]);
compile_wildcard_3([], Result) ->
diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl
index 7403d52881..527d083eaa 100644
--- a/lib/stdlib/test/filelib_SUITE.erl
+++ b/lib/stdlib/test/filelib_SUITE.erl
@@ -79,9 +79,11 @@ wildcard_one(Config) when is_list(Config) ->
do_wildcard_1(Dir,
fun(Wc) ->
L = filelib:wildcard(Wc),
+ L = filelib:wildcard(disable_prefix_opt(Wc)),
L = filelib:wildcard(Wc, erl_prim_loader),
L = filelib:wildcard(Wc, "."),
L = filelib:wildcard(Wc, Dir),
+ L = filelib:wildcard(disable_prefix_opt(Wc), Dir),
L = filelib:wildcard(Wc, Dir++"/.")
end),
file:set_cwd(OldCwd),
@@ -119,6 +121,14 @@ wcc(Wc, Error) ->
{'EXIT',{{badpattern,Error},
[{filelib,wildcard,2,_}|_]}} = (catch filelib:wildcard(Wc, ".")).
+disable_prefix_opt([C|Wc]) when $a =< C, C =< $z; C =:= $@ ->
+ %% There is an optimization for patterns that have a literal prefix
+ %% (such as "lib/compiler/ebin/*"). Test that we'll get the same result
+ %% if we disable that optimization.
+ [$[, C, $] | Wc];
+disable_prefix_opt(Wc) ->
+ Wc.
+
do_wildcard_1(Dir, Wcf0) ->
do_wildcard_2(Dir, Wcf0),
Wcf = fun(Wc0) ->
@@ -300,6 +310,30 @@ do_wildcard_10(Dir, Wcf) ->
end,
del(Files),
+ wildcard_11(Dir, Wcf).
+
+%% ERL-ERL-1029/OTP-15987: Fix problems with "@/.." and ".." in general.
+wildcard_11(Dir, Wcf) ->
+ Dirs0 = ["@","@dir","dir@"],
+ Dirs = [filename:join(Dir, D) || D <- Dirs0],
+ _ = [ok = file:make_dir(D) || D <- Dirs],
+ Files0 = ["@a","b@","x","y","z"],
+ Files = mkfiles(Files0, Dir),
+
+ ["@","@a","@dir","b@","dir@","x","y","z"] = Wcf("*"),
+ ["@"] = Wcf("@"),
+ ["@","@a","@dir"] = Wcf("@*"),
+ ["@/..","@dir/.."] = Wcf("@*/.."),
+ ["@/../@","@/../@a","@/../@dir",
+ "@dir/../@","@dir/../@a","@dir/../@dir"] = Wcf("@*/../@*"),
+
+ %% Non-directories followed by "/.." should not match any files.
+ [] = Wcf("@a/.."),
+ [] = Wcf("x/.."),
+
+ %% Cleanup.
+ del(Files),
+ [ok = file:del_dir(D) || D <- Dirs],
ok.
fold_files(Config) when is_list(Config) ->
diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl
index 1be644c620..09ef0bf7a5 100644
--- a/lib/syntax_tools/src/erl_syntax.erl
+++ b/lib/syntax_tools/src/erl_syntax.erl
@@ -2192,11 +2192,11 @@ revert_map_field_assoc(Node) ->
-spec map_field_assoc_name(syntaxTree()) -> syntaxTree().
map_field_assoc_name(Node) ->
- case Node of
+ case unwrap(Node) of
{map_field_assoc, _, Name, _} ->
Name;
- _ ->
- (data(Node))#map_field_assoc.name
+ Node1 ->
+ (data(Node1))#map_field_assoc.name
end.
@@ -2208,11 +2208,11 @@ map_field_assoc_name(Node) ->
-spec map_field_assoc_value(syntaxTree()) -> syntaxTree().
map_field_assoc_value(Node) ->
- case Node of
+ case unwrap(Node) of
{map_field_assoc, _, _, Value} ->
Value;
- _ ->
- (data(Node))#map_field_assoc.value
+ Node1 ->
+ (data(Node1))#map_field_assoc.value
end.
@@ -2250,11 +2250,11 @@ revert_map_field_exact(Node) ->
-spec map_field_exact_name(syntaxTree()) -> syntaxTree().
map_field_exact_name(Node) ->
- case Node of
+ case unwrap(Node) of
{map_field_exact, _, Name, _} ->
Name;
- _ ->
- (data(Node))#map_field_exact.name
+ Node1 ->
+ (data(Node1))#map_field_exact.name
end.
@@ -2266,11 +2266,11 @@ map_field_exact_name(Node) ->
-spec map_field_exact_value(syntaxTree()) -> syntaxTree().
map_field_exact_value(Node) ->
- case Node of
+ case unwrap(Node) of
{map_field_exact, _, _, Value} ->
Value;
- _ ->
- (data(Node))#map_field_exact.value
+ Node1 ->
+ (data(Node1))#map_field_exact.value
end.
@@ -5339,11 +5339,11 @@ revert_map_type_assoc(Node) ->
-spec map_type_assoc_name(syntaxTree()) -> syntaxTree().
map_type_assoc_name(Node) ->
- case Node of
+ case unwrap(Node) of
{type, _, map_field_assoc, [Name, _]} ->
Name;
- _ ->
- (data(Node))#map_type_assoc.name
+ Node1 ->
+ (data(Node1))#map_type_assoc.name
end.
@@ -5355,11 +5355,11 @@ map_type_assoc_name(Node) ->
-spec map_type_assoc_value(syntaxTree()) -> syntaxTree().
map_type_assoc_value(Node) ->
- case Node of
+ case unwrap(Node) of
{type, _, map_field_assoc, [_, Value]} ->
Value;
- _ ->
- (data(Node))#map_type_assoc.value
+ Node1 ->
+ (data(Node1))#map_type_assoc.value
end.
@@ -5397,11 +5397,11 @@ revert_map_type_exact(Node) ->
-spec map_type_exact_name(syntaxTree()) -> syntaxTree().
map_type_exact_name(Node) ->
- case Node of
+ case unwrap(Node) of
{type, _, map_field_exact, [Name, _]} ->
Name;
- _ ->
- (data(Node))#map_type_exact.name
+ Node1 ->
+ (data(Node1))#map_type_exact.name
end.
@@ -5413,11 +5413,11 @@ map_type_exact_name(Node) ->
-spec map_type_exact_value(syntaxTree()) -> syntaxTree().
map_type_exact_value(Node) ->
- case Node of
+ case unwrap(Node) of
{type, _, map_field_exact, [_, Value]} ->
Value;
- _ ->
- (data(Node))#map_type_exact.value
+ Node1 ->
+ (data(Node1))#map_type_exact.value
end.
diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl
index e1dd1bd73b..9baf36ce11 100644
--- a/lib/syntax_tools/test/syntax_tools_SUITE.erl
+++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl
@@ -24,7 +24,7 @@
%% Test cases
-export([app_test/1,appup_test/1,smoke_test/1,revert/1,revert_map/1,
- revert_map_type/1,
+ revert_map_type/1,wrapped_subtrees/1,
t_abstract_type/1,t_erl_parse_type/1,t_type/1, t_epp_dodger/1,
t_comment_scan/1,t_igor/1,t_erl_tidy/1,t_prettypr/1]).
@@ -32,6 +32,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[app_test,appup_test,smoke_test,revert,revert_map,revert_map_type,
+ wrapped_subtrees,
t_abstract_type,t_erl_parse_type,t_type,t_epp_dodger,
t_comment_scan,t_igor,t_erl_tidy,t_prettypr].
@@ -143,6 +144,41 @@ revert_map_type(Config) when is_list(Config) ->
Form2 = erl_syntax:revert(Mapped2),
?t:timetrap_cancel(Dog).
+%% Read with erl_parse, wrap each tree node with erl_syntax and check that
+%% erl_syntax:subtrees can access the wrapped node.
+wrapped_subtrees(Config) when is_list(Config) ->
+ Dog = ?t:timetrap(?t:minutes(2)),
+ Wc = filename:join([code:lib_dir(stdlib),"src","*.erl"]),
+ Fs = filelib:wildcard(Wc) ++ test_files(Config),
+ Path = [filename:join(code:lib_dir(stdlib), "include"),
+ filename:join(code:lib_dir(kernel), "include")],
+ io:format("~p files\n", [length(Fs)]),
+ Map = fun (File) -> wrapped_subtrees_file(File, Path) end,
+ case p_run(Map, Fs) of
+ 0 -> ok;
+ N -> ?t:fail({N,errors})
+ end,
+ ?t:timetrap_cancel(Dog).
+
+wrapped_subtrees_file(File, Path) ->
+ case epp:parse_file(File, Path, []) of
+ {ok,Fs0} ->
+ lists:foreach(fun wrap_each/1, Fs0)
+ end.
+
+wrap_each(Tree) ->
+ % only `wrap` top-level erl_parse node
+ Tree1 = erl_syntax:set_pos(Tree, erl_syntax:get_pos(Tree)),
+ % assert ability to access subtrees of wrapped node with erl_syntax:subtrees/1
+ case erl_syntax:subtrees(Tree1) of
+ [] -> ok;
+ List ->
+ GrpsF = fun(Group) ->
+ lists:foreach(fun wrap_each/1, Group)
+ end,
+ lists:foreach(GrpsF, List)
+ end.
+
%% api tests
t_type(Config) when is_list(Config) ->
diff --git a/lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl b/lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl
index e4f8a1c3de..b23acdb39e 100644
--- a/lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl
+++ b/lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl
@@ -37,6 +37,9 @@
-record(par, {a :: undefined | ?MODULE}).
+-record(mt, {e :: #{any() := any()},
+ a :: #{any() => any()}}).
+
-record(r0, {}).
-record(r,