ASSERT-KTH / ASSERT-KTH/flacoco

Errors occur when running `mvn package -DskipTests` and localizing bugs with flacoco jar

Open
#120 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
38
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Dear Sirs,

I am very interested in this project and I am trying to package it on my pc for fault localization. I cloned this project and then ran `mvn package -DskipTests`, but it reports the following two types of compilation errors:

>[ERROR] /home/apr/tools/flacoco/src/main/java/fr/spoonlabs/flacoco/core/test/strategies/testrunner/TestRunnerStrategy.java:[11,24] package org.apache.log4j does not exist
[ERROR] /home/apr/tools/flacoco/src/main/java/fr/spoonlabs/flacoco/core/test/strategies/testrunner/TestRunnerStrategy.java:[29,13] cannot find symbol
[ERROR] symbol: class Logger

>[ERROR] /home/apr/tools/flacoco/src/main/java/fr/spoonlabs/flacoco/core/coverage/CoverageMatrix.java:[15,31] package org.jacoco.core.runtime does not exist

I think this could be resolved by adding the following dependencies into `pom.xml`:

```

log4j
log4j
1.2.17


org.jacoco
org.jacoco.core
0.8.7

```

With this workaround, I have used the `flacoco-1.0.1-SNAPSHOT-jar-with-dependencies.jar` to localize a bug in [https://github.com/alibaba/fastjson/commit/96d0ee532a37351a126ebef2d5071964c33a1ec7](https://github.com/alibaba/fastjson/commit/96d0ee532a37351a126ebef2d5071964c33a1ec7) with the following command:

```
flacocoPath=/home/apr/tools/flacoco/target/flacoco-1.0.1-SNAPSHOT-jar-with-dependencies.jar
projPath=/home/apr/fastjson

java -jar $flacocoPath --projectpath $projPath
```

It failed with the following error:
```
[1522] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.bvt.issue_1700.Issue1701
[1526] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.bvt.cglib.TestCglib
[1531] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.JsonIteratorImageTest
[1531] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.Issue3805
[1533] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.codec.Jackson2AfterBurnCodec
[1538] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.benchmark.jdk10.generated.StringBenchmark_testParseJsonComp_jmhTest
[1539] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.benchmark.jdk10.generated.StringBenchmark_jackson_testParseJson_jmhTest
[1539] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.benchmark.jdk10.generated.StringBenchmark_testParseJson_jmhTest
[1539] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.benchmark.jdk10.generated.StringBenchmark_jackson_testParseJsonComp_jmhTest
[1541] WARN TestMethodFilter - NoClassDefFoundError: class com.alibaba.json.test.JSONLibXmlTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/jacoco/agent/rt/RT
at eu.stamp_project.testrunner.EntryPoint.(EntryPoint.java:868)
at fr.spoonlabs.flacoco.core.coverage.framework.TestFrameworkStrategy.setupTestRunnerEntryPoint(TestFrameworkStrategy.java:32)
at fr.spoonlabs.flacoco.core.coverage.framework.JUnit4Strategy.execute(JUnit4Strategy.java:25)
at fr.spoonlabs.flacoco.core.coverage.CoverageRunner.getCoverageMatrix(CoverageRunner.java:49)
at fr.spoonlabs.flacoco.localization.spectrum.SpectrumRunner.computeCoverageMatrix(SpectrumRunner.java:56)
at fr.spoonlabs.flacoco.localization.spectrum.SpectrumRunner.run(SpectrumRunner.java:32)
at fr.spoonlabs.flacoco.api.Flacoco.run(Flacoco.java:31)
at fr.spoonlabs.flacoco.cli.FlacocoMain.call(FlacocoMain.java:157)
at fr.spoonlabs.flacoco.cli.FlacocoMain.call(FlacocoMain.java:27)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at fr.spoonlabs.flacoco.cli.FlacocoMain.main(FlacocoMain.java:148)
Caused by: java.lang.ClassNotFoundException: org.jacoco.agent.rt.RT
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 17 more
```

Then I used the jar from the maven repo:
```
projPath=/home/apr/fastjson
flacocoPath=/home/apr/.m2/repository/com/github/spoonlabs/flacoco/1.0.0/flacoco-1.0.0.jar

java -cp $flacocoPath:/home/apr/tools/flacoco/target/dependency/* fr.spoonlabs.flacoco.cli.FlacocoMain --projectpath $projPath
```

It also failed with the same error.

Notes:
+ the CLI usage of flacoco is obtained from [https://github.com/SpoonLabs/flacoco/wiki/CLI](https://github.com/SpoonLabs/flacoco/wiki/CLI) and [https://github.com/SpoonLabs/flacoco/wiki#usage-through-the-cli](https://github.com/SpoonLabs/flacoco/wiki#usage-through-the-cli), where it claims to use `fr.spoonlabs.flacoco.FlacocoMain` but actually we should use `fr.spoonlabs.flacoco.cli.FlacocoMain` seemingly.
+ the environment on my pc: JDK 8, maven 3.

It would be much appreciated if any advice could be provided. Thank you.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the Maven packaging and CLI commands, then inspect pom.xml and the reported references in TestRunnerStrategy.java and CoverageMatrix.java. Trace the CLI path through fr.spoonlabs.flacoco.cli.FlacocoMain and the failure through TestFrameworkStrategy.java and EntryPoint. Done means packaging succeeds and the documented CLI invocation runs without the reported missing-class errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, cli, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.