Skip to content

Commit 003dad3

Browse files
committed
Merge branches 'vampire/mixin-spec-internals' and 'vampire/use-snapshot-id' into 'vampire/flexible-version-check'
3 parents e765ec5 + 5b338ae + a7631ad commit 003dad3

File tree

8 files changed

+362
-351
lines changed

8 files changed

+362
-351
lines changed

spock-core/src/main/java/org/spockframework/lang/SpecInternals.java

Lines changed: 0 additions & 324 deletions
Large diffs are not rendered by default.

spock-core/src/main/java/org/spockframework/mock/EmptyOrDummyResponse.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package org.spockframework.mock;
1616

17+
import org.spockframework.runtime.GroovyRuntimeUtil;
1718
import org.spockframework.runtime.extension.IDefaultValueProviderExtension;
1819
import org.spockframework.util.ReflectionUtil;
1920
import org.spockframework.util.ThreadSafe;
@@ -160,7 +161,8 @@ private Object createDummy(IMockInvocation invocation) {
160161
Class<?> type = invocation.getMethod().getReturnType();
161162
Type genericType = invocation.getMethod().getExactReturnType();
162163
Specification spec = invocation.getMockObject().getSpecification();
163-
return spec.createMock("dummy", genericType, MockNature.STUB, GroovyObject.class.isAssignableFrom(type) ?
164+
return GroovyRuntimeUtil.invokeMethod(spec, "createMock",
165+
"dummy", genericType, MockNature.STUB, GroovyObject.class.isAssignableFrom(type) ?
164166
MockImplementation.GROOVY : MockImplementation.JAVA, emptyMap(), null);
165167
}
166168
}

spock-core/src/main/java/org/spockframework/runtime/SpecialMethodCallTarget.java

Lines changed: 352 additions & 0 deletions
Large diffs are not rendered by default.

spock-core/src/main/java/org/spockframework/runtime/SpockEngineDescriptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515

1616
package org.spockframework.runtime;
1717

18+
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
1819
import org.junit.platform.engine.UniqueId;
1920
import org.junit.platform.engine.support.descriptor.EngineDescriptor;
2021
import org.junit.platform.engine.support.hierarchical.Node;
2122
import org.junit.platform.engine.support.hierarchical.ThrowableCollector;
23+
import spock.lang.Specification;
2224

2325
public class SpockEngineDescriptor extends EngineDescriptor implements Node<SpockExecutionContext> {
2426
private final RunContext runContext;
@@ -35,6 +37,7 @@ public SpockExecutionContext prepare(SpockExecutionContext context) throws Excep
3537

3638
@Override
3739
public SpockExecutionContext before(SpockExecutionContext context) throws Exception {
40+
DefaultGroovyMethods.mixin(Specification.class, SpecialMethodCallTarget.class);
3841
SpockExecution spockExecution = new SpockExecution(context.getStoreProvider());
3942
context.getRunContext().startExecution(spockExecution);
4043
return context;

spock-specs/src/test/groovy/org/spockframework/smoke/StackTraceFiltering.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,6 @@ thrown(RuntimeException)
302302
WrongExceptionThrownError e = thrown()
303303

304304
stackTraceLooksLike e, """
305-
org.spockframework.lang.SpecInternals|checkExceptionThrown|-
306-
org.spockframework.lang.SpecInternals|thrownImpl|-
307305
apackage.ASpec|a feature|5
308306
"""
309307

spock-specs/src/test/groovy/org/spockframework/smoke/ast/AstSpec.groovy

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -344,30 +344,10 @@ class Ext <T extends Serializable, V extends Cloneable> {
344344
snapshotter.assertThat(result.source).matchesSnapshot()
345345
}
346346
347-
@Requires({ GroovyRuntimeUtil.MAJOR_VERSION >= 4 })
348-
def "Primitive types are used in AST transformation Groovy >= 4"() {
349-
when:
350-
def result = compiler.transpileWithImports('''
351-
class TestSpec extends Specification {
352-
def 'test'() {
353-
expect:
354-
true
355-
when:
356-
true
357-
then:
358-
thrown(RuntimeException)
359-
}
360-
}
361-
''',
362-
EnumSet.of(Show.METHODS),
363-
CompilePhase.OUTPUT)
364-
365-
then:
366-
textSnapshotter.assertThat(result.source).matchesSnapshot()
367-
}
347+
def "Primitive types are used in AST transformation"() {
348+
given:
349+
def snapshotId = (GroovyRuntimeUtil.MAJOR_VERSION >= 4) ? "groovy4" : ""
368350
369-
@Requires({ GroovyRuntimeUtil.MAJOR_VERSION <= 3 })
370-
def "Primitive types are used in AST transformation Groovy <= 3"() {
371351
when:
372352
def result = compiler.transpileWithImports('''
373353
class TestSpec extends Specification {
@@ -385,6 +365,6 @@ class TestSpec extends Specification {
385365
CompilePhase.OUTPUT)
386366
387367
then:
388-
textSnapshotter.assertThat(result.source).matchesSnapshot()
368+
textSnapshotter.assertThat(result.source).matchesSnapshot(snapshotId)
389369
}
390370
}

0 commit comments

Comments
 (0)