I think the simplest thing would be to add the emma jar to the classpath and then add the necessary package(s) to the packages exported by the system bundle (i.e. via sling.system.packages). You can do this by adding emma as a dependency to the maven-launchpad-plugin and create a file called src/test/config/sling.properties with this line in it:

sling.system.packages.simple=com.vladium.emma.rt

Running launchpad via the maven-launchpad-plugin will then produce the coverage.ec file.

Here's where things get a bit messy. In order to produce an HTML report, it seems you need both the .ec file and the .em files produced during the instrumentation. So you need to do something like this: java -cp ~/.m2/repository/emma/emma/2.0.5312/emma-2.0.5312.jar emma report -r html -in coverage.ec,../../bundles/commons/json/target/coverage.em,../../bundles/commons/auth/target/coverage.em

(here I instrumented commons.json and commons.auth)

I'll have to think about how to codify this in the Maven build (a plugin which scans for these .em files and builds the parameter list? Attaching the .em files as artifacts?). But it DOES work: http://people.apache.org/~justin/coverage/ <http://people.apache.org/%7Ejustin/coverage/>

Let's move this back to a sling mailing list.

Justin

D. Stuart Freeman wrote:
That was going to be my next question :).  I was wondering whether it
would be better to make an emma bundle that exports the required classes,
or if I could do something like boot delegation and have the emma jar on
the classpath when I start sling.

On Thu, Jul 08, 2010 at 09:08:58PM -0400, Justin Edelson wrote:
D. Stuart -

Question for you: once you get the bundles instrumented, how do you get
them to resolve in Felix? I don't see an emma bundle which exports the
right package.

Justin

On 7/8/10 2:39 PM, D. Stuart Freeman wrote:
I'm trying to instrument some bundles with emma so that I can run
integration tests against them and get coverage stats out.

I've added the following to my project's base pom:

<build>
...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>emma-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <inherited>true</inherited>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>instrument</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>emma-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <classifier>emma</classifier>
              
<classesDirectory>${maven.build.dir}/generated-classes/emma/classes</classesDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
...
</build>

That seems to give me instrumented and uninstrumented artifacts, but the
bnd plugin seems to add emma as a bundle import even on the
uninstrumented artifacts.  Is there a way to configure it to only add the
emma dependency to the instrumented bundles?  Is there a better way to
build instrumented bundles?

In my search for ways to do this, I've found
http://www.eclemma.org/research/instrumentingosgi/index.html is there a
way to do something similar with Felix?

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Reply via email to