Skip to content

Commit

Permalink
[Groovy3] Upgrade Groovy 3 to 3.0.0-rc-3
Browse files Browse the repository at this point in the history
Groovy script execution line in stacktrace format has changed since RC2:
script15791055931181262955476.groovy:3 ->
Script_eb303fa8835e8a0c4ec6558372940b3d.groovy:3
  • Loading branch information
szpak committed Jan 15, 2020
1 parent 06268be commit 756cb6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ext {
minGroovyVersion = "2.5.0"
maxGroovyVersion = "2.9.99"
} else if (variant == 3.0) {
groovyVersion = "3.0.0-rc-2"
groovyVersion = "3.0.0-rc-3"
minGroovyVersion = "3.0.0"
maxGroovyVersion = "3.9.99"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.spockframework.runtime.ConditionNotSatisfiedError
import org.spockframework.runtime.SpockException

class ExceptionsInConditions extends EmbeddedSpecification {
private static final String NORMALIZED_SCRIPT_EXECUTION_LINE = "scriptXXX.groovy:X"

def "null pointer exception in condition"() {
when:
runner.runFeatureBody(
Expand All @@ -21,12 +23,16 @@ class ExceptionsInConditions extends EmbeddedSpecification {
map.get("key").length() == 0
| | |
[:] null java.lang.NullPointerException: Cannot invoke method length() on null object
\tat apackage.ASpec.a feature(scriptXXXXXXXXXXXXXXXXXXXXXXX.groovy:X)
\tat apackage.ASpec.a feature($NORMALIZED_SCRIPT_EXECUTION_LINE)
""".stripIndent()
e.getCondition().getRendering().replaceAll("(?<! )\\d", "X") == expected
unifyScriptExecutionLineInStacktrace(e.getCondition().getRendering()) == expected
e.getCause() instanceof NullPointerException
}

private String unifyScriptExecutionLineInStacktrace(String stacktrace) {
return stacktrace.replaceAll("[Ss]cript_?[\\da-f]+.groovy:[\\d]+", NORMALIZED_SCRIPT_EXECUTION_LINE)
}

def "null pointer exception in method condition"() {
when:
runner.runFeatureBody(
Expand All @@ -43,9 +49,9 @@ class ExceptionsInConditions extends EmbeddedSpecification {
map.get("key").isEmpty()
| | |
[:] null java.lang.NullPointerException: Cannot invoke method isEmpty() on null object
\tat apackage.ASpec.a feature(scriptXXXXXXXXXXXXXXXXXXXXXXX.groovy:X)
\tat apackage.ASpec.a feature($NORMALIZED_SCRIPT_EXECUTION_LINE)
""".stripIndent()
e.getCondition().getRendering().replaceAll("\\d", "X") == expected
unifyScriptExecutionLineInStacktrace(e.getCondition().getRendering()) == expected
e.getCause() instanceof NullPointerException
}

Expand Down Expand Up @@ -73,10 +79,10 @@ class ExceptionsInConditions extends EmbeddedSpecification {
| |
| [:]
java.lang.IllegalArgumentException: key does not exists
\tat apackage.ASpec.a feature_closureX(scriptXXXXXXXXXXXXXXXXXXXXXX.groovy:X)
\tat apackage.ASpec.a feature(scriptXXXXXXXXXXXXXXXXXXXXXX.groovy:XX)
\tat apackage.ASpec.a feature_closure1($NORMALIZED_SCRIPT_EXECUTION_LINE)
\tat apackage.ASpec.a feature($NORMALIZED_SCRIPT_EXECUTION_LINE)
""".stripIndent()
e.getCondition().getRendering().replaceAll("(?<! )\\d", "X") == expected
unifyScriptExecutionLineInStacktrace(e.getCondition().getRendering()) == expected

e.getCause() instanceof IllegalArgumentException
}
Expand Down Expand Up @@ -143,12 +149,12 @@ class ExceptionsInConditions extends EmbeddedSpecification {
ConditionNotSatisfiedError e = thrown()
def expected = """\
Condition failed with Exception:
map.get("key").b.c.d.e()
| | |
[:] null java.lang.NullPointerException: Cannot get property 'b' on null object
\tat apackage.ASpec.a feature(scriptXXXXXXXXXXXXXXXXXXXXXX.groovy:X)
\tat apackage.ASpec.a feature($NORMALIZED_SCRIPT_EXECUTION_LINE)
""".stripIndent()
e.getMessage().replaceAll("\\d", "X") == expected
unifyScriptExecutionLineInStacktrace(e.getMessage()) == expected
}
}

0 comments on commit 756cb6b

Please sign in to comment.