Skip to content

Commit

Permalink
Rename spk.dsld to spock_tests.dsld and enhance it
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Milles <[email protected]>
  • Loading branch information
leonard84 and eric-milles committed Oct 11, 2023
1 parent 3f893d0 commit 63a73f8
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package dsld

import org.codehaus.groovy.ast.*
import org.codehaus.groovy.ast.expr.*

assertVersion(groovyEclipse: "2.7.2") // tested against this version
Expand Down Expand Up @@ -50,3 +51,29 @@ contribute(
}
}


// From https://issues.apache.org/jira/browse/GROOVY-9510
// Properly resolve the delegatesTo for the closures of these extensions
def hasPrecondition = { annotatedBy(name('spock.lang.Requires') | name('spock.lang.IgnoreIf') | name('spock.lang.PendingFeatureIf')) }

contribute(inClosure() & isThisType() & bind(classes: enclosingClass(subType('spock.lang.Specification')))
& (enclosingClass(conditions: hasPrecondition()) | enclosingMethod(conditions: hasPrecondition()))) {
for (AnnotationNode pre : conditions) {
def condition = pre.getMember('value')
if (condition.getCode().is(currentNode)) {
delegateType = resolver.resolve("org.spockframework.runtime.extension.builtin.PreconditionContext<${classes[0].getName()}>")
return
}
}
}

contribute(inClosure() & isThisType() & bind(classes: enclosingClass(subType('spock.lang.Specification')))
& (enclosingClass(annotations: annotatedBy('spock.lang.Retry')) | enclosingMethod(annotations: annotatedBy('spock.lang.Retry')))) {
for (AnnotationNode retry : annotations) {
def condition = retry.getMember('condition')
if (condition.getCode().is(currentNode)) {
delegateType = resolver.resolve("org.spockframework.runtime.extension.builtin.RetryConditionContext<${classes[0].getName()}>")
return
}
}
}

0 comments on commit 63a73f8

Please sign in to comment.