aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar/scanner
diff options
context:
space:
mode:
authorKlaudio Sinani <klaudio.sinani@sonarsource.com>2022-11-08 14:48:31 +0100
committersonartech <sonartech@sonarsource.com>2022-11-08 20:02:59 +0000
commitb2904b7b5133f62d75b96d43c36fe1464c05d8b0 (patch)
treea87a895869928d6ba329e5c07f8628f0e1249c3d /sonar-scanner-engine/src/test/java/org/sonar/scanner
parentd488345162101994b8e6f9fbe51dd4ed34ff679d (diff)
downloadsonarqube-b2904b7b5133f62d75b96d43c36fe1464c05d8b0.tar.gz
sonarqube-b2904b7b5133f62d75b96d43c36fe1464c05d8b0.zip
SONAR-17571 Ensure file existence prior to file size assessment
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
index 687d65a1017..59d6ff9b60d 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
@@ -27,6 +27,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Random;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
@@ -439,6 +440,24 @@ public class FileSystemMediumTest {
}
@Test
+ public void analysisFailsIfFileDoesNotExist() throws IOException {
+ File srcDir = new File(baseDir, "src");
+ srcDir.mkdir();
+
+ File target = writeFile(srcDir, "target.xoo", 1024 * 1024 + 1);
+ Path link = Paths.get(srcDir.getPath(), "target_link.xoo");
+ Files.createSymbolicLink(link, target.toPath());
+ Files.delete(target.toPath());
+
+ AnalysisBuilder analysis = tester.newAnalysis()
+ .properties(builder.build());
+
+ assertThatThrownBy(analysis::execute)
+ .isExactlyInstanceOf(IllegalStateException.class)
+ .hasMessageEndingWith(format("Unable to read file %s", link));
+ }
+
+ @Test
public void test_inclusions_on_multi_modules() throws IOException {
File baseDir = temp.getRoot();
File baseDirModuleA = new File(baseDir, "moduleA");