Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
JarredOlson opened this issue Jul 28, 2014 · 20 comments
Closed

Comments

@JarredOlson
Copy link

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
  • test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
  • //test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
    // configure settings for the run-app JVM
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the run-war JVM

Adding coverage plugin

--- 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"

  • test ":code-coverage:2.0.3-1"
    // Uncomment these (or add new ones) to enable additional resources capabilities
    //runtime ":zipped-resources:1.0.1"
    //runtime ":cached-resources:1.1"

Adding simple controller

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

  • def index() {
  • int randomNumber = new Random().nextInt(10)
  • if(randomNumber < 5) {
  •   render('Random number is less than 5')
    
  • } else {
  •   render('Random number is greater or equal to 5')
    
  • }
  • }
    +}
@beckje01
Copy link
Owner

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

@psoares
Copy link

psoares commented Jul 29, 2014

Same problem for grails 2.3.8...

@JarredOlson
Copy link
Author

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

@arielhdz
Copy link

Same problem in grails 2.2.1

@jmckay
Copy link

jmckay commented Aug 1, 2014

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
Copy link

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

@marcoscarceles
Copy link
Contributor

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
Copy link

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. 😟

@shiftregister-vg
Copy link

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
Copy link
Contributor

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:
marcoscarceles@365ed46#diff-d41d8cd98f00b204e9800998ecf8427e

beckje01 added a commit that referenced this issue Aug 16, 2014
@beckje01
Copy link
Owner

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
Copy link

I've done some testing on my own apps,

  • 2.4.2 app works excelent, hurrá! 😄
  • 2.3.11 doesn't 😧 (see following log)
| 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
Copy link
Owner

@genuinefafa what command are you running right now?

@beckje01
Copy link
Owner

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
Copy link

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 🎱

@beckje01
Copy link
Owner

Tested and confirmed working.

@shiftregister-vg
Copy link

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

@beckje01
Copy link
Owner

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

@psoares
Copy link

psoares commented Aug 19, 2014

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
#30 (comment)
.

@satan1999
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants