-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make test suite work in OTP 25 #1402
Conversation
?assertMatch( | ||
#{ | ||
data := #{module := <<"file">>, function := <<"write">>, arity := 2}, | ||
documentation := #{kind := <<"markdown">>, value := _} | ||
}, | ||
Result | ||
), | ||
#{documentation := #{value := ActualValue}} = Result, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactor was made to make case the last part of the expression, so it can return {skip, _}
. A similar hoist was applied to all cases where I added skip.
(The data := #{module := <<"file">>, function := <<"write">>, arity := 2}
check is new though.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is no longer useful after the latest few commits in this branch.
%% If this should fail the test we should document requirements for | ||
%% the development environment so that OTP has the EEP-48 docs. | ||
{skip, "This OTP build does not have EEP-48 docs for the 'file' module"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you want this to fail instead of skipping. If so, I think the docs should be updated to ensure developers have the right stuff locally to run the test suite.
I have OTP 24 and 25 installed via asdf and code:get_doc(file)
yields a map with docs, but no functions have docs:
1> {ok, {docs_v1, 0, erlang, <<"application/erlang+html">>, none, _, ModDocs}} = code:get_doc(file).
2> [{F, A, Doc} || {{function, F, A}, _, _, Doc, _} <- ModDocs].
[{native_name_encoding,0,none},
{format_error,1,none},
{pid2name,1,none},
{get_cwd,0,none},
{get_cwd,1,none},
{set_cwd,1,none},
{delete,1,none},
{delete,2,none},
{rename,2,none},
{...}|...]
3> [{F, A, Doc} || {{function, F, A}, _, _, Doc, _} <- ModDocs, Doc =/= none].
[]
lists:any( | ||
fun | ||
({_, _, _, #{}, _}) -> true; | ||
({_, _, _, _, _}) -> false | ||
end, | ||
Docs | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and has_eep48/1
in the other suite were only updated to know when the cases can be skipped. If skipping is not wanted this can go away (or be used to improve test debugging).
Feel free to close this PR if there is too much else going on. I prefer to not be the one closing it since it is not targeting my repository. Maybe main has moved too much anyway by now (didn't look) for this to make sense. |
Hi @fabjan, sorry for not being responsive to Pull Requests in the past couple of months. The contribution looks good to me, but the CI jobs seem to have expired and I cannot find a way to restart them. If you could rebase/force-push this branch we can merge this one, assuming CI passes. |
No worries at all. Sure I'll give it a try! |
b29f6ab
to
d45b3c9
Compare
@fabjan It looks like a test suite is still failing on this one. |
Cheers, Time to look at this one now after the rebases and other PR was merged 👍 |
The test suites work locally for me with OTP 24 and 25.
d45b3c9
to
de4f89d
Compare
Alright let's see now how it plays. I got all green checks running locally on OTP 23 so my "fix" is a guess, but I think it is sound: de4f89d |
Can't get OTP 22 to work on my M1 Mac, so my attempts at making the test suites work for all releases are being made a little bit in the dark. |
@robertoaloi An attempt was made, but I think I have to give up on this PR. I don't know enough about how the test suite or the docs rendering feature was built to make a call on how to fix the test suite.
This PR was a much bigger task than I saw before me. It seems to make it work the test code needs a bigger refactor. |
Hi @fabjan I think it's ok to drop support for OTP 22. They just announced the RC1 for OTP 26. So, feel free to remove it from the pipeline. |
I bumped the Windows CI job to OTP 23 as well (it was at 22). Interestingly, it was green last time even though it seems like it tested nothing: https://github.com/erlang-ls/erlang_ls/actions/runs/4198452678/jobs/7282095992 Maybe now with OTP 23 it will run the tests and go red.. |
case has_eep48_edoc() of | ||
true -> | ||
case list_to_integer(erlang:system_info(otp_release)) of | ||
25 -> | ||
<< | ||
"## j/1\n\n---\n\n```erlang\n\n j(_) \n\n```\n\n" | ||
"```erlang\n-spec j(doesnt:exist()) -> ok.\n```" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a bug in els_eep48_docs:render
when running in OTP versions under 25, and that is why this current test code looks a bit weird (it checks if has_eep48_edoc() is true or false but uses the same test data regardless)
On OTP 24 locally on my machine, els_eep48_docs:render
returns {error, function_missing}
for this j
function that is hovered. On OTP 25 it returns some kind of doc chunks instead even of the function is not documented. Maybe OTP started automatically adding doc chunks for specs?
Anywho, I didn't want to make changes to the production code in this PR adding OTP 25 to CI, so not diving into if els_eep48_docs:render
should be improved (especially since it seems to me that it's under OTP 24 it is behaving badly).
Converted to draft until the useless diffs are cleaned up. But CI is all green now! |
It was not my intention to make it a minute, I just wanted a significant bump up from one second. 640 centiseconds ought to be enough for anyone.
@@ -78,12 +78,21 @@ init_per_testcase(TestCase, Config) -> | |||
|
|||
-spec end_per_testcase(atom(), config()) -> ok. | |||
end_per_testcase(TestCase, Config) -> | |||
lists:foreach( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that meck registers a module with the _meck
suffix is an implementation detail that we should not rely on. We should only unload els_docs
for those testcases where the module is mocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct way to do "unmock if mocked" is to use the meck
API instead. meck:mocked
returns a list of mocked modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice to know 👍
Thanks! |
* Fix EEP-48 case for the nonexisting_type test * Make hover docs fallback tests avoid EEP-48 docs * Fix hover suite formatting * Make nonexisting_type test work in OTP 24 and 25 * Improve mocking in eep48 fallback tests * Skip OTP EEP-48 tests if OTP is built without docs * Add OTP 25 to CI The test suites work locally for me with OTP 24 and 25. * Fix eep48 check in remote_call_otp test * Make tests work if els_eep48_docs is undefined * Remove OTP 22 from CI * fmt * Fix eep48 check in resolve_application_remote_otp * Make has_eep48 test helper more readable * Fix eep48 in resolve_type_application_remote_otp * Silence els_config warnings in PropEr suite * Increase halt_called wait timeout in PropEr suite * Cleanup WIP comment in nonexisting_type test * Comment the version check in nonexisting_type test * Clean up useless leftover diffs * Fix halt_called timeout in PropEr suite It was not my intention to make it a minute, I just wanted a significant bump up from one second. 640 centiseconds ought to be enough for anyone. * Only unload els_docs mock after cases that used it * fmt
Problem
The hover and completion provider test suites have some test cases for showing docs.
Some tests are testing the Erlang LS internal fallback docs provided if EEP-48 docs can not be extracted. These test cases don't work with newer OTP versions (because their expected values depend on the EEP-48 docs not being available).
Some of the tests are testing edoc extraction itself, and have conditional expectations depending on if EEP-48 docs are available or not. These tests assume that OTP >= 24 will always have EEP-48 docs for
file:write
ifcode:get_docs(file)
is not empty, but this is not the case (see e.g. #1402 (comment)). The test suites and the code in els_docs are not in agreement about when the docs are available.Proposed Solution
If the doc chunks are expected to be there in OTP for anyone running the test suite, perhaps we can document how to resolve that (as it is now, I don't know how to make the test suite pass locally).
Bonus Content