Hey,
We've just tried out latest Spock 2.0-M4, we're getting the following exception:
Task :compileTestGroovy
startup failed:
NestedAssertTest.groovy: -1: The current scope already contains a variable of the name $spock_errorCollector
@ line -1, column -1.
NestedAssertTest.groovy: -1: The current scope already contains a variable of the name $spock_valueRecorder
@ line -1, column -1.
2 errors
The cause seems to be that nestedasserts seem to generate conflicting code, irrespective of their level or other previously generated ones (can be "".with {} or whatever closure):
def nestedAssert() {
tap {
assert 0
tap { assert 0 }
}
}
The following reproducer can be used by running ./gradlew build:
https://github.com/paplorinc/spock-bug/blob/master/src/test/groovy/NestedAssertTest.groovy
This test also fails on the previous milestone M3. It passes on Spock 1.3, though, if this is where you come from. Did it ever pass on any 2.x version for you?
@leonard84, is this somehow contextually related to #783?
We've only tried with 1.3, where this was working before.
Hope the above pr fixes it for feature methods as well, because it is also a thing in 2.0-M4-groovy-3.0. this code does not compile in 2.0-M4 but works fine in 1.3
def test() {
expect:
with([1,2]) {
it.size() > 0
it.each { assert it > 0 }
}
}
Yes @rtretyak the PR fixes both.
In both was the problem only when you did not have any top-level condition and as with does return void it is not considered a condition.
As the merged PR does not contain any regression tests - is that a good idea? - I just built the current master and manually ran the tests presented by @paplorinc and @rtretyak this issue. They both pass now.
What do you mean?
Did you miss https://github.com/spockframework/spock/pull/1239/files#diff-47b16cca894a339507feda0cc9a675d00a438e4effddccda32291c9b8e0e3786 ?
Yes, because when glancing at the file list - I did not scroll to read the code - I was looking for *Test or *Spec. 馃槈

I just saw RecorderScope, did not notice smoke. Sorry for that. Strange naming, though.
Yeah, naming is not too consistent in some points in Spock sources :-D
Basically everything in spock-specs is either test or fixture
My bad entirely. But an additional re-test does not hurt, it was worth 5 minutes of my lifetime. :-)
Yes, definitely, thanks for verifying fixes, also an important contribution. :-)
The latest SNAPSHOT seems to have fixed these, thanks!