Painless: more testing for script_stack#24168
Conversation
`script_stack` is super useful when debugging Painless scripts because it skips all the "weird" stuff involved that obfuscates where the actual error is. It skips Painless's internals and call site bootstrapping. It works fine, but it didn't have many tests. This converts a test that we had for line numbers into a test for the `script_stack`. The line numbers test was an indirect test for `script_stack`.
| runnable.run(); | ||
| } catch (Throwable e) { | ||
| if (e instanceof ScriptException) { | ||
| boolean hasEmptyScriptStack = ((ScriptException) e).getScriptStack().isEmpty(); |
There was a problem hiding this comment.
I was originally hunting down a case where we weren't producing the stack. I never found it but I figure something like this is nice to have around anyway.
| } catch (Throwable e) { | ||
| if (e instanceof ScriptException) { | ||
| boolean hasEmptyScriptStack = ((ScriptException) e).getScriptStack().isEmpty(); | ||
| if (shouldHaveScriptStack) { |
There was a problem hiding this comment.
This would read cleaner as:
if (shouldHaveScriptStack && hasEmptyScripStack) {
...
} else if (shouldHaveScriptStack == false && hasEmptyScriptStack == false) {
...
}
There was a problem hiding this comment.
I can do it that way, sure.
| exec("Double.parseDouble(params['missing'])"); | ||
| }); | ||
| // null deref at x.isEmpty(), the '.' is offset 30 (+1) | ||
| assertEquals(30 + 1, exception.getStackTrace()[0].getLineNumber()); |
There was a problem hiding this comment.
I don't think we should lose the line number testing?
There was a problem hiding this comment.
The line numbers don't line up in the def and String case. I can put something together to keep it but in general script_stack is the thing we expect people to use. The line numbers leak a lot of painless internals that we strip from script_stack and script_stack is built from them anyway. I can keep them but it'll be funky.
There was a problem hiding this comment.
I don't care what we test it with, but it is something we return to users, so it should remain tested.
|
@rjernst I pushed updates. |
`script_stack` is super useful when debugging Painless scripts because it skips all the "weird" stuff involved that obfuscates where the actual error is. It skips Painless's internals and call site bootstrapping. It works fine, but it didn't have many tests. This converts a test that we had for line numbers into a test for the `script_stack`. The line numbers test was an indirect test for `script_stack`.
|
Thanks for reviewing @rjernst! |
* master: Add BucketMetricValue interface (elastic#24188) Enable index-time sorting (elastic#24055) Clarify elasticsearch user uid:gid mapping in Docker docs Update field-names-field.asciidoc (elastic#24178) ElectMasterService.hasEnoughMasterNodes should return false if no masters were found Remove Ubuntu 12.04 (elastic#24161) [Test] Add unit tests for InternalHDRPercentilesTests (elastic#24157) Replicate write failures (elastic#23314) Rename variable in translog simple commit test Strengthen translog commit with open view test Stronger check in translog prepare and commit test Fix translog prepare commit and commit test ingest-node.asciidoc - Clarify json processor (elastic#21876) Painless: more testing for script_stack (elastic#24168)
script_stackis super useful when debugging Painless scriptsbecause it skips all the "weird" stuff involved that obfuscates
where the actual error is. It skips Painless's internals and
call site bootstrapping.
It works fine, but it didn't have many tests. This converts a
test that we had for line numbers into a test for the
script_stack. The line numbers test was an indirect testfor
script_stack.