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 Feb 6, 2020
1 parent 7d61b89 commit 72ae328
Show file tree
Hide file tree
Showing 2 changed files with 18 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,9 @@ import org.spockframework.runtime.ConditionNotSatisfiedError
import org.spockframework.runtime.SpockException

class ExceptionsInConditions extends EmbeddedSpecification {
private static final String SCRIPT_EXECUTION_LINE_PATTERN = ~/[Ss]cript_?+\p{XDigit}++\.groovy:[\d]++/
private static final String NORMALIZED_SCRIPT_EXECUTION_LINE = "scriptXXX.groovy:X"

def "null pointer exception in condition"() {
when:
runner.runFeatureBody(
Expand All @@ -21,12 +24,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(SCRIPT_EXECUTION_LINE_PATTERN, NORMALIZED_SCRIPT_EXECUTION_LINE)
}

def "null pointer exception in method condition"() {
when:
runner.runFeatureBody(
Expand All @@ -43,9 +50,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 +80,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 +150,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 72ae328

Please sign in to comment.