Quantcast

Problem with @Unroll with groovy-1.8

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problem with @Unroll with groovy-1.8

Ken Kousen
I'm trying to run the basic spock-example that comes with the main distribution, using Groovy 1.8 and 0.5-spock-1.8.

On the spec DataDriven.groovy, I get the following error:

"Only classes and closures can be used for attribute 'value' in @spock.lang.Unroll'

The error is flagging the line
@Unroll("minimum of #a and #b is #c")

This worked fine with Groovy 1.7. Has something fundamental changed here? How do I fix it?

Thanks,

Ken Kousen

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Peter Niederwieser
Administrator
spock-core-0.5-groovy-1.8 was an experimental release based on Groovy 1.8 beta 2 (or 3?) and is outdated. If you want to use Spock with Groovy 1.8 at this time, please use spock-core-0.6-groovy-1.8-SNAPSHOT.
Not exactly sure why you get the error, but it's related to a change in spock-core-0.5-groovy-1.8 (use of Groovy 1.8's annotation closures for @Unroll) that has meanwhile been undone. So switching to 0.6-SNAPSHOT should solve your problem.

Cheers,
Peter

On 29.04.2011, at 18:25, Ken Kousen wrote:

> I'm trying to run the basic spock-example that comes with the main distribution, using Groovy 1.8 and 0.5-spock-1.8.
>
> On the spec DataDriven.groovy, I get the following error:
>
> "Only classes and closures can be used for attribute 'value' in @spock.lang.Unroll'
>
> The error is flagging the line
> @Unroll("minimum of #a and #b is #c")
>
> This worked fine with Groovy 1.7. Has something fundamental changed here? How do I fix it?

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Ken Kousen
I went to the build.gradle file for the spock-example and edited to:

groovy("org.codehaus.groovy:groovy-all:1.8.0")
testCompile "org.spockframework:spock-core:0.6-groovy-1.8-SNAPSHOT"

I got a bunch of new downloads, as expected, but the same error on the same class. It still doesn't understand a string argument for @Unroll.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Peter Niederwieser
Administrator
On Apr 30, 1:28 pm, Ken Kousen <[hidden email]> wrote:
> I went to the build.gradle file for the spock-example and edited to:
>
> groovy("org.codehaus.groovy:groovy-all:1.8.0")
> testCompile "org.spockframework:spock-core:0.6-groovy-1.8-SNAPSHOT"
>
> I got a bunch of new downloads, as expected, but the same error on the same
> class. It still doesn't understand a string argument for @Unroll.

Not sure what exactly you are doing (e.g. which version of the spock-
example project you are using), but if you clone Spock from GitHub and
check out the 'groovy-1.8' branch, all tests in spock-example should
pass (I made some fixes today). Note that the spock-example project
has its own Gradle build, and isn't currently built as part of the
overall Gradle build.

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Ken Kousen
Ah, I get it now. I cloned the repo, but I didn't switch branches to groovy-1.8 before running the build. Now I have it right.

I also see that the way you fixed the problem was to wrap the string inside a closure, i.e.,

@Unroll({"minimum of $a and $b is $c"})

Thanks for your help,

Ken

On Sat, Apr 30, 2011 at 5:01 PM, Peter Niederwieser <[hidden email]> wrote:
On Apr 30, 1:28 pm, Ken Kousen <[hidden email]> wrote:
> I went to the build.gradle file for the spock-example and edited to:
>
> groovy("org.codehaus.groovy:groovy-all:1.8.0")
> testCompile "org.spockframework:spock-core:0.6-groovy-1.8-SNAPSHOT"
>
> I got a bunch of new downloads, as expected, but the same error on the same
> class. It still doesn't understand a string argument for @Unroll.

Not sure what exactly you are doing (e.g. which version of the spock-
example project you are using), but if you clone Spock from GitHub and
check out the 'groovy-1.8' branch, all tests in spock-example should
pass (I made some fixes today). Note that the spock-example project
has its own Gradle build, and isn't currently built as part of the
overall Gradle build.

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.




--
Kenneth A. Kousen
President
Kousen IT, Inc.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Peter Niederwieser
Administrator
At the risk of confusing you further, until this moment I thought that I had undone this change shortly after the release of 0.5-groovy-1.8, but apparently I haven't. Can't say right now if this change (usage of annotation closures for @Unroll) will make it into 0.6-groovy-1.8, which I consider the first official release supporting 1.8.

Cheers,
Peter

On 01.05.2011, at 03:06, Kenneth Kousen wrote:

> Ah, I get it now. I cloned the repo, but I didn't switch branches to groovy-1.8 before running the build. Now I have it right.
>
> I also see that the way you fixed the problem was to wrap the string inside a closure, i.e.,
>
> @Unroll({"minimum of $a and $b is $c"})

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Robert Fletcher-2
I just got bitten by this today when trying to upgrade to the
groovy-1.8 version of Spock for Grails 1.4. This is a pretty
significant breaking change. I have hundreds if not thousands of
@Unroll calls scattered across numerous projects. I'm not sure I
understand what using a Closure parameter offer that's useful to
@Unroll to justify the change.

Rob

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Peter Niederwieser
Administrator
On Jun 3, 4:29 am, Robert Fletcher <[hidden email]>
wrote:
> I'm not sure I understand what using a Closure parameter offer that's useful to
> @Unroll to justify the change.

We had our reasons, but we also listen to our users (especially the
long-eared DJ's among them). Hereby I'm happy to announce that we've
decided to revert the change before the 0.6 release. So all your prior
investments in @Unroll are safe. You'll still be tempted to touch them
though, because the new recommended syntax is almost irresistible:

@Unroll
def "you'll want to #touch.touch.touch me #here"() { ... }

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Robert Fletcher-2
I've been playing with the new syntax and to some extent I can see the
advantages, particularly in that you can do more complex things with
params in a GString than were possible with the # expression.

However, the new proposal is fantastic news. That's what I've been
hoping @Unroll would be able to do all along!

On Sat, Jun 4, 2011 at 8:01 AM, Peter Niederwieser <[hidden email]> wrote:

> On Jun 3, 4:29 am, Robert Fletcher <[hidden email]>
> wrote:
>> I'm not sure I understand what using a Closure parameter offer that's useful to
>> @Unroll to justify the change.
>
> We had our reasons, but we also listen to our users (especially the
> long-eared DJ's among them). Hereby I'm happy to announce that we've
> decided to revert the change before the 0.6 release. So all your prior
> investments in @Unroll are safe. You'll still be tempted to touch them
> though, because the new recommended syntax is almost irresistible:
>
> @Unroll
> def "you'll want to #touch.touch.touch me #here"() { ... }
>
> Cheers,
> Peter
>
> --
> You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to [hidden email].
> For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

mbjarland
In reply to this post by Peter Niederwieser
Hi Peter, from one forum to another. The new syntax looks beautiful! The duplication in unrolled spock method declarations has been bugging me for a while. I.e it would be really nice to rewrite: 

  @Unroll("Expect value '#expectedValue' from manifest List property '#propertyName'")
  def "Expect value 'expectedValue' from manifest List property 'propertyName'"() { 
    ...some test code...
  }

as

  @Unroll
  def "Expect value '#expectedValue' from manifest List property '#propertyName'"() { 
    ...some test code...
  }

and it looks like this is exactly what your new unroll syntax does. This would be beautiful. 

Does the new syntax exist in a snapshot version? As per our discussion on the gradle forums I just upgraded to M6 and the latest "spock-core-0.6-groovy-1.8-20111202.050205-347" snapshot still seems to expect the "@Unroll( { ... } )" closure syntax. 

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spockframework/-/LggPku41nNUJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

Peter Niederwieser
Administrator
mbjarland wrote
Hi Peter, from one forum to another. The new syntax looks beautiful! [...]
Does the new syntax exist in a snapshot version?
No, the proposed new syntax hasn't been implemented yet.

Cheers,
Peter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with @Unroll with groovy-1.8

mbjarland
Ok, thanks. And no problem, I am happy to wait for the syntax. Just wanted to make sure I wasn't missing something that was already out there. And apologies for the cross post.

And thank you for a great BDD framework! And for fixing our gradle issues!
Loading...