aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2019-03-05 18:10:07 +0100
committerSonarTech <sonartech@sonarsource.com>2019-03-08 20:20:55 +0100
commit1cb0cb0a38cf5c82b85aec5b59e52db13338d060 (patch)
tree07f627bf0975a5bea8545f8b59784e945a4e5fb1 /sonar-scanner-engine
parentf6b2a269c44043f1c230b646dbb8662aed3fa5a4 (diff)
downloadsonarqube-1cb0cb0a38cf5c82b85aec5b59e52db13338d060.tar.gz
sonarqube-1cb0cb0a38cf5c82b85aec5b59e52db13338d060.zip
SONAR-11641 Add tests
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java
index c51d03d3785..4730fa8eadb 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java
@@ -282,6 +282,36 @@ public class CoverageMediumTest {
assertThat(result.coverageFor(file, 4)).isNull();
}
+ // SONAR-11641
+ @Test
+ public void dontFallbackOnExecutableLinesIfNoCoverageSaved() throws IOException {
+
+ File baseDir = temp.getRoot();
+ File srcDir = new File(baseDir, "src");
+ srcDir.mkdir();
+
+ File xooFile = new File(srcDir, "sample.xoo");
+ File measuresFile = new File(srcDir, "sample.xoo.measures");
+ File coverageFile = new File(srcDir, "sample.xoo.coverage");
+ FileUtils.write(xooFile, "function foo() {\n if (a && b) {\nalert('hello');\n}\n}", StandardCharsets.UTF_8);
+ FileUtils.write(measuresFile, "# The code analyzer disagree with the coverage tool and consider some lines to be executable\nexecutable_lines_data:2=1;3=1;4=0", StandardCharsets.UTF_8);
+ FileUtils.write(coverageFile, "# No lines to cover in this file according to the coverage tool", StandardCharsets.UTF_8);
+
+ AnalysisResult result = tester.newAnalysis()
+ .properties(ImmutableMap.<String, String>builder()
+ .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
+ .put("sonar.projectKey", "com.foo.project")
+ .put("sonar.sources", "src")
+ .build())
+ .execute();
+
+ InputFile file = result.inputFile("src/sample.xoo");
+ assertThat(result.coverageFor(file, 1)).isNull();
+ assertThat(result.coverageFor(file, 2)).isNull();
+ assertThat(result.coverageFor(file, 3)).isNull();
+ assertThat(result.coverageFor(file, 4)).isNull();
+ }
+
// SONAR-9557
@Test
public void exclusionsAndForceToZeroOnModules() throws IOException {