Skip to content

Commit

Permalink
Fix ct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plux committed Dec 21, 2023
1 parent 45963b8 commit 12210c7
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 14 deletions.
68 changes: 56 additions & 12 deletions apps/els_lsp/test/els_completion_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -634,18 +634,7 @@ exported_functions_arity(Config) ->
exported_types(Config) ->
TriggerKind = ?COMPLETION_TRIGGER_KIND_CHARACTER,
Uri = ?config(code_navigation_uri, Config),
Types = [
<<"date_time">>,
<<"fd">>,
<<"file_info">>,
<<"filename">>,
<<"filename_all">>,
<<"io_device">>,
<<"mode">>,
<<"name">>,
<<"name_all">>,
<<"posix">>
],
Types = file_exported_types(),
Expected = [
#{
insertText => <<T/binary, "()">>,
Expand Down Expand Up @@ -1677,6 +1666,30 @@ resolve_application_remote_otp(Config) ->
#{result := Result} = els_client:completionitem_resolve(Selected),
Value =
case has_eep48(file) of
true when ?OTP_RELEASE >= 26 ->
<<
"```erlang\nwrite(IoDevice, Bytes) -> ok | {error, "
"Reason}\nwhen\n IoDevice :: io_device() | io:device(),\n"
" Bytes :: iodata(),"
"\n Reason :: posix() | badarg | terminated.\n```\n\n"
"---\n\n"
"Writes `Bytes` to the file referenced by `IoDevice`\\."
" This function is the only way to write to a file opened in"
" `raw` mode \\(although it works for normally opened files"
" too\\)\\. Returns `ok` if successful, and"
" `{error, Reason}` otherwise\\.\n\nIf the file is opened"
" with `encoding` set to something else than `latin1`,"
" each byte written can result in many bytes being written"
" to the file, as the byte range 0\\.\\.255 can represent"
" anything between one and four bytes depending on value"
" and UTF encoding type\\. If you want to write"
" [`unicode:chardata()`](https://erlang.org/doc/man/unicode"
".html#type-chardata) to the `IoDevice` you should use"
" [`io:put_chars/2`](https://erlang.org/doc/man/io.html"
"#put_chars-2) instead\\.\n\nTypical error reasons:\n\n"
"* **`ebadf`** \n The file is not opened for writing\\.\n\n"
"* **`enospc`** \n No space is left on the device\\.\n"
>>;
true ->
<<
"```erlang\nwrite(IoDevice, Bytes) -> ok | {error, "
Expand Down Expand Up @@ -1979,3 +1992,34 @@ has_eep48(Module) ->

keywords() ->
els_completion_provider:keywords(test, test).

-if(OTP_RELEASE >= 26).
file_exported_types() ->
[
<<"date_time">>,
<<"fd">>,
<<"file_info">>,
<<"filename">>,
<<"filename_all">>,
<<"io_device">>,
<<"location">>,
<<"mode">>,
<<"name">>,
<<"name_all">>,
<<"posix">>
].
-else.
file_exported_types() ->
[
<<"date_time">>,
<<"fd">>,
<<"file_info">>,
<<"filename">>,
<<"filename_all">>,
<<"io_device">>,
<<"mode">>,
<<"name">>,
<<"name_all">>,
<<"posix">>
].
-endif.
28 changes: 26 additions & 2 deletions apps/els_lsp/test/els_hover_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,30 @@ remote_call_otp(Config) ->
Contents = maps:get(contents, Result),
Value =
case has_eep48(file) of
true when ?OTP_RELEASE >= 26 ->
<<
"```erlang\nwrite(IoDevice, Bytes) -> ok | {error, "
"Reason}\nwhen\n IoDevice :: io_device() | io:device(),\n"
" Bytes :: iodata(),"
"\n Reason :: posix() | badarg | terminated.\n```\n\n"
"---\n\n"
"Writes `Bytes` to the file referenced by `IoDevice`\\."
" This function is the only way to write to a file opened in"
" `raw` mode \\(although it works for normally opened files"
" too\\)\\. Returns `ok` if successful, and"
" `{error, Reason}` otherwise\\.\n\nIf the file is opened"
" with `encoding` set to something else than `latin1`,"
" each byte written can result in many bytes being written"
" to the file, as the byte range 0\\.\\.255 can represent"
" anything between one and four bytes depending on value"
" and UTF encoding type\\. If you want to write"
" [`unicode:chardata()`](https://erlang.org/doc/man/unicode"
".html#type-chardata) to the `IoDevice` you should use"
" [`io:put_chars/2`](https://erlang.org/doc/man/io.html"
"#put_chars-2) instead\\.\n\nTypical error reasons:\n\n"
"* **`ebadf`** \n The file is not opened for writing\\.\n\n"
"* **`enospc`** \n No space is left on the device\\.\n"
>>;
true ->
<<
"```erlang\nwrite(IoDevice, Bytes) -> ok | {error, Reason}\n"
Expand Down Expand Up @@ -541,8 +565,8 @@ nonexisting_type(Config) ->
#{result := Result} = els_client:hover(Uri, 22, 15),
%% The spec for `j' is shown instead of the type docs.
Value =
case list_to_integer(erlang:system_info(otp_release)) of
25 ->
case list_to_integer(erlang:system_info(otp_release)) >= 25 of
true ->
<<
"```erlang\nj(_ :: doesnt:exist()) -> ok.\n```\n\n"
"---\n\n\n"
Expand Down

0 comments on commit 12210c7

Please sign in to comment.