From 12210c782c0b0ba8ff788c7a2450cd459ca68f7b Mon Sep 17 00:00:00 2001 From: Hakan Nilsson Date: Thu, 21 Dec 2023 09:21:57 +0100 Subject: [PATCH] Fix ct tests --- apps/els_lsp/test/els_completion_SUITE.erl | 68 ++++++++++++++++++---- apps/els_lsp/test/els_hover_SUITE.erl | 28 ++++++++- 2 files changed, 82 insertions(+), 14 deletions(-) diff --git a/apps/els_lsp/test/els_completion_SUITE.erl b/apps/els_lsp/test/els_completion_SUITE.erl index 92a0417f2..e9cedfd7a 100644 --- a/apps/els_lsp/test/els_completion_SUITE.erl +++ b/apps/els_lsp/test/els_completion_SUITE.erl @@ -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 => <>, @@ -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, " @@ -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. diff --git a/apps/els_lsp/test/els_hover_SUITE.erl b/apps/els_lsp/test/els_hover_SUITE.erl index 95e7c08a2..babfed34b 100644 --- a/apps/els_lsp/test/els_hover_SUITE.erl +++ b/apps/els_lsp/test/els_hover_SUITE.erl @@ -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" @@ -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"