beckje01 / grails-code-coverage

Git Repo of the Grails Code Coverage plugin.
http://grails.org/plugin/code-coverage
16 stars 26 forks source link

code-coverage 2.0.3-1 not producing html output with grails 2.3.10 #30

Closed JarredOlson closed 10 years ago

JarredOlson commented 10 years ago

I attempted to upgrade an existing grails 2.3.10 project to use code-coverage 2.0.3-1. When I ran grails test-app -coverage nothing appeared when I viewed the coverage report at /target/test-reports/cobetura/index.html. I created a fresh grails 2.3.10 project and added 1 controller and the coverage plugin. Execute the same command as above and the same result happened. In both cases I removed the forked execution as well since I had read elsewhere that it caused issues. Adding -xml to the command seems to generate the coverage.xml file still but nothing shows in index.html. I can't upload a zip of my sample project so here is some git output for what I did on top of a clean grails 2.3.10 created app:

Removing forked execution for tests

--- a/grails-app/conf/BuildConfig.groovy +++ b/grails-app/conf/BuildConfig.groovy @@ -12,7 +12,7 @@ grails.project.fork = [ // compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

 // configure settings for the test-app JVM, uses the daemon by default

--- a/grails-app/conf/BuildConfig.groovy +++ b/grails-app/conf/BuildConfig.groovy @@ -66,6 +66,7 @@ grails.project.dependency.resolution = { runtime ":database-migration:1.4.0" runtime ":jquery:1.11.1" runtime ":resources:1.2.7"

+++ b/grails-app/controllers/sample/PersonController.groovy +package sample + +import java.util.Random + +class PersonController { +

beckje01 commented 10 years ago

Can you put your example in its own repo and give me a link to it?

psoares commented 10 years ago

Same problem for grails 2.3.8...

JarredOlson commented 10 years ago

@beckje01 here is a link to the repo. Thanks! https://github.com/JarredOlson/GrailsCoverageIssue

arielhdz commented 10 years ago

Same problem in grails 2.2.1

jmckay commented 10 years ago

I've noticed the same thing starting in grails 2.3.8. Coverage in my test app worked fine in 2.3.7. Here is the output I'm seeing under 2.3.8:

...
| Instrumenting classes for coverage
| Instrumenting classes for coverage...
INFO: Found ASM 3: /<my-home>/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar. 
      Possibly because grails-core (grails-plugin-databinding) uses it. 
      Removing from instrumentation classpath!
     [java] Failed to locateorg.apache.tools.ant.Main
     [java] ant.home: /<my-home>/.m2/repository/org/apache/ant/ant-launcher
     [java] Classpath: ...
...
| Tests PASSED - view reports in /<path-to-project>/test/target/test-reports
Aug 01, 2014 1:21:48 PM net.sourceforge.cobertura.coveragedata.ProjectData loadCoverageDataFromDatafile
INFO: Cobertura: Coverage data file /<path-to-project>/test/cobertura.ser either does not exist or is not readable.  Creating a new data file.
Aug 01, 2014 1:21:48 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler saveCoverageData
INFO: Cobertura: Saved information on 0 classes.
    [mkdir] Created dir: /<path-to-project>/test/target/test-reports/cobertura
[cobertura-report] Aug 01, 2014 12:21:48 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageDataCobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura-report] Report time: 64ms
[cobertura-report] INFO: Cobertura: Loaded information on 0 classes.
Done with post processing reports in 5ms
genuinefafa commented 10 years ago

Is there any advance in this issue? What can we do?

marcoscarceles commented 10 years ago

Digging out a bit it seems the problem could be when executing the Java task to instrument the classes, which produces this error:

     [java] Failed to locateorg.apache.tools.ant.Main
     [java] ant.home: /<my-home>/.m2/repository/org/apache/ant/ant-launcher
     [java] Classpath: ...

I couldn't figure out why yet :(

genuinefafa commented 10 years ago

I don't know how to enable more debugging. How can I do that?

Seeing your error make me wonder if latest version of Grails removed some dependency code-coverage depends upon. I'm pretty lost here. :worried:

shiftregister-vg commented 10 years ago

I'm having the same issue in 2.4.2. I noticed that running version 1.2.7 of the plugin produces the HTML but causes my tests to fail. If I swap to 2.0.3-1 then my tests pass but no html report.

One of the few differences I have seen is this:

| Instrumenting classes for coverage...
INFO: Found ASM 3: C:\Users\steve\.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar.
      Possibly because grails-core (grails-plugin-databinding) uses it.
      Removing from instrumentation classpath!
     [java] Java Result: 1

In 1.2.7 I don't see this output but in 2.0.3-1 I get it just before the tests run.

marcoscarceles commented 10 years ago

I logged the classpath on two test projects, on grails 2.3.7 and 2.3.8 and it seems that the ant jar is gone on the 2.3.8. On a test project this seems to do the trick: https://github.com/marcos-carceles/grails-code-coverage/commit/365ed4627db3d5b6a406b8532735dac1ba732003#diff-d41d8cd98f00b204e9800998ecf8427e

beckje01 commented 10 years ago

Thanks to the help from @marcos-carceles and one other change for 2.3.10 the latest version on master seems to be working correctly for 2.3.10 and 2.4.3.

@stevegood would you be willing to test the latest code in master with your project?

If I can have a few people confirm the fix I will release on Sunday.

genuinefafa commented 10 years ago

I've done some testing on my own apps,

| Instrumenting classes for coverage....
     [java] Buildfile: /private/var/folders/vp/vs2xzv0146z0ckzmd1cxk8hr0000gn/T/instrument-build-3551938871261699895.xml
     [java] instrument:
     [java] [cobertura-instrument] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
     [java] [cobertura-instrument] ago 16, 2014 9:36:00 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData
     [java] [cobertura-instrument] INFO: Cobertura: Loaded information on 47 classes.
     [java] [cobertura-instrument] WARN   instrumentClass, Unable to instrument file .... class
     [java] [cobertura-instrument] java.lang.IncompatibleClassChangeError: class net.sourceforge.cobertura.instrument.pass1.DetectIgnoredCodeClassVisitor has interface org.objectweb.asm.ClassVisitor as super class
     [java] [cobertura-instrument]  at java.lang.ClassLoader.defineClass1(Native Method)
     [java] [cobertura-instrument]  at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
     [java] [cobertura-instrument]  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
     [java] [cobertura-instrument]  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
     [java] [cobertura-instrument]  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
     [java] [cobertura-instrument]  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
     [java] [cobertura-instrument]  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
     [java] [cobertura-instrument]  at java.security.AccessController.doPrivileged(Native Method)
     [java] [cobertura-instrument]  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
     [java] [cobertura-instrument]  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
     [java] [cobertura-instrument]  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
     [java] [cobertura-instrument]  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:149)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)
     [java] [cobertura-instrument] WARN   instrumentClass, Unable to instrument file /.../target/classes/Searchable$_run_closure2.class
     [java] [cobertura-instrument] java.lang.IncompatibleClassChangeError: net/sourceforge/cobertura/instrument/pass1/DetectIgnoredCodeClassVisitor
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:149)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
     [java] [cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)

I really don't understand how to get more debugging information.

beckje01 commented 10 years ago

@genuinefafa what command are you running right now?

beckje01 commented 10 years ago

Also if you could uncomment https://github.com/beckje01/grails-code-coverage/blob/master/scripts/_Events.groovy#L252 and run that will give lots of details but it would be best to email me that output.

I tried with the test app https://github.com/JarredOlson/GrailsCoverageIssue bumped up to 2.3.11 and didn't get the issue.

genuinefafa commented 10 years ago

I did grails clean and a grails compile and then grails test-app -coverage --verbose --stacktrace

I'm using test ":code-coverage:2.0.3-2-SNAPSHOT" on BuildConfig

I just double check it.

@beckje01 what email? my skype is the same as my user

ps: I'm doing those modifications now, i'll be back :8ball:

beckje01 commented 10 years ago

Tested and confirmed working.

shiftregister-vg commented 10 years ago

I confirmed that everything is working in 2.4.2 using the content of master branch.

beckje01 commented 10 years ago

@stevegood Great thanks it should be live in the plugin portal now

psoares commented 10 years ago

Works for me too in grails 2.3.8. I'm using the forked mode and it seems to work fine too... is it supposed to work ? In which case, maybe the plugin documentation in the portal needs to be updated ?!....

Thanks a lot !

2014-08-16 22:33 GMT-04:00 Jeff Beck notifications@github.com:

@stevegood https://github.com/stevegood Great thanks it should be live in the plugin portal now

— Reply to this email directly or view it on GitHub https://github.com/beckje01/grails-code-coverage/issues/30#issuecomment-52411856 .

satan1999 commented 10 years ago

I am using grails 2.4.3 and ':code-coverage:2.0.3-2'

When i run test-app -coverage -xml in local machine, it looks fine.

When i run test-coverage in jeakins(cobertura 1.9.5, the grails.project.fork was commented out ) , i got the following logs

[java] [cobertura-instrument] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file [java] [cobertura-instrument] 21/10/2014 12:08:39 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData [java] [cobertura-instrument] SEVERE: Cobertura: Error reading from object stream. [java] [cobertura-instrument] java.lang.NullPointerException [java] [cobertura-instrument] at net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler.loadCoverageData(CoverageDataFileHandler.java:85) [java] [cobertura-instrument] at net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler.loadCoverageData(CoverageDataFileHandler.java:61) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:381) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.main(Main.java:421) [java] [cobertura-instrument] WARN instrumentClass, Unable to instrument file /var/lib/jenkins/jobs/API-CI-TestSuite/workspace/target/classes/SecurityConfig$_run_closure1.class [java] [cobertura-instrument] java.lang.NullPointerException [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.tp.ClassMap.applyOnProjectData(ClassMap.java:364) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:187) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399) [java] [cobertura-instrument] at net.sourceforge.cobertura.instrument.Main.main(Main.java:421) . . . [cobertura-report] INFO: Cobertura: Loaded information on 0 classes.