-
Notifications
You must be signed in to change notification settings - Fork 25k
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
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`.
try { | ||
runnable.run(); | ||
} catch (Throwable e) { | ||
if (e instanceof ScriptException) { | ||
boolean hasEmptyScriptStack = ((ScriptException) e).getScriptStack().isEmpty(); |
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 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.
try { | ||
runnable.run(); | ||
} catch (Throwable e) { | ||
if (e instanceof ScriptException) { | ||
boolean hasEmptyScriptStack = ((ScriptException) e).getScriptStack().isEmpty(); | ||
if (shouldHaveScriptStack) { |
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 would read cleaner as:
if (shouldHaveScriptStack && hasEmptyScripStack) {
...
} else if (shouldHaveScriptStack == false && hasEmptyScriptStack == false) {
...
}
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 can do it that way, sure.
}); | ||
// null deref at x.isEmpty(), the '.' is offset 30 (+1) | ||
assertEquals(30 + 1, exception.getStackTrace()[0].getLineNumber()); |
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 don't think we should lose the line number testing?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_stack
is 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
.