History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRVY-581
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Dmitry Krasilschikov
Reporter: Guillaume HOLLER
Votes: 2
Watchers: 5
Operations

If you were logged in you would be able to see more operations.
Groovy

unit test of GroovyTestCase use invalid generated classes

Created: 17 Oct 07 15:19   Updated: 30 Oct 07 19:11
Component/s: None
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. Zip Archive groovyTest.zip (277 kb)

Environment:
intelliJ 7 final
up to date version of Groovy Plugin (as of october 16 2007)


 Description  « Hide
This bug seems related to GRVY-171 which has strangely been considered resolved as obsolete.

The behavior is consistently reproducible

When testing GroovyTestCase, the test has expected behavior the first time , or just after all test or production classes on which the test depends has been modified.

But after that, the test passes (green) obviously without executing anything .

Looking at $HOME/.IntellijIdea70/system/compiler/.generated/Groovy_to_java_source_code_generator, we see that some java source files have been generated from Groovy classes whose method contain empty behavior. It seems that, if code has not been modified, this strange generated source files are used to compile to classes (I don't know how it was done the first time).

You will find as an attachement the very basic groovy project used for testing



 All   Comments   Work Log   Change History      Sort Order:
Guillaume HOLLER - 19 Oct 07 11:44
Commenting out in GroovyLoader class adding groovy to java source generator to compilers list solved the issue.

It worked fine for me after that, although I suspect it may cause problems in other area, like java/groovy seamless integration.


Guillaume HOLLER - 19 Oct 07 20:30
It seems that this issue is related to GRVY-584.

The previous workaround, as expected, works fine until you have java classes that reference groovy classes. In that case, a full recompile would break with class not found on the depended on groovy classes. I have in that case to separately compile groovy files (first) and java files, and this could not work well in some cases (java class references goovy class which references another project java class, for example). So, this is unrealistic for real world project with mix and matches of java and groovy sources.

After further investigations, I have found that actually the problem is more on a strange behavior of the java compiler for groovy generated classes.

If a groovy class, say Hello.groovy has been modified lately, the following compilation steps take place:
1) generation of Hello.java from Hello.groovy
2) javac compilation to Hello.class from Hello.java
3) groovyc compilation to Hello.class from Hello.groovy, overriding the previous dummy Hello.class

So, the first time, we obtain the correct Hello.class

If the compilation process is launched again on unmodified Hello.groovy, steps one and three are skipped, as expected, but step two is still executed, resulting in the dummy Hello.class to replace the correct one. It seems, that when a java source is resulting from source generation, it is systematically added to the compilation list.


Todd Wells - 22 Oct 07 18:54
I encountered this bug almost immediately when trying to use GroovyTestCase... in my opinion it is a critical bug and should be increased in priority, since it completely inhibits reliable testing of Groovy classes.

Hans Dockter - 30 Oct 07 14:25
Same with me. I more or less have to stop developing with JetGroovy until this is fixed.

Eugene Vigdorchik - 30 Oct 07 18:59
Guys, this is a bug in idea core, that will be fixed in 7.0.2

Hans Dockter - 30 Oct 07 19:06
Hi Eugene,

thanks for shedding light on this. Any idea when 7.0.2 is to be expected?


Eugene Vigdorchik - 30 Oct 07 19:10
In a couple of weeks I think.