Uh oh!
There was an error while loading. Please reload this page.
Raise in executor in tests - #881
Conversation
| request_time = Benchmark.realtime do | ||
| response = run(request) | ||
| rescue StandardError, LoadError => e | ||
| raise e if $RUBY_LSP_TEST |
There was a problem hiding this comment.
Wasn't sure if there was a more 'standard' way to name such a thing.
There was a problem hiding this comment.
I think it is better to make this just:
| raiseeif $RUBY_LSP_TEST | |
| raiseif $RUBY_LSP_TEST |
so that the original source of the exception is kept, and it doesn't look like the exception was raised here. Ref: https://www.exceptionalcreatures.com/guides/advanced-rescue-and-raise#reraising-exceptions
| end_position = { | ||
| line: 0, | ||
| character: document.source.rindex('"'), | ||
| character: document.source.rindex('o'), |
There was a problem hiding this comment.
There is no " in the code above so this was returning nil.
vinistock
left a comment
There was a problem hiding this comment.
I think a better approach to surface this in executor tests would be to add a test helper that will execute a request and raise in tests if there's an error. Changing the actual runtime with a global variable is not really something we'd like to do.
How about something like this in executor_test
defrun_request(method:,params: {})result=@executor.execute({method: method,params: params})error=result.errorraiseerroriferrorresult.responseend |
andyw8
commented
Aug 10, 2023
@vinistock yeah I like that approached, updated. |
| error = result.error | ||
| raise error if error | ||
| result |
There was a problem hiding this comment.
Given that result only has response and error, and we already check for the error here, should we just return result.response and avoid having to do it in each call site?
There was a problem hiding this comment.
Updated as per suggestion.
08525b7 to
b575108CompareUh oh!
There was an error while loading. Please reload this page.
andyw8
commented
Aug 15, 2023
Updated with @st0012's suggestion. |
Motivation
We currently rescue
StandardErrorinexecutor, which covers a wide range of things, includingTypeError. That can result in test failure messages which are not very informative.And while working on a YARP migration with @bitwise-aiden we discovered a flawed test which was being masked due to the rescue.
(I'll fix the linting if we agree to ahead with this).
Implementation
Be loud if an error occurs while running the tests.
Automated Tests
Updated
Manual Tests
n/a