import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
@Test
public void testBlame() throws IOException {
- File projectDir = temp.newFolder();
+ File projectDir = createNewTempFolder();
javaUnzip("dummy-git.zip", projectDir);
JGitBlameCommand jGitBlameCommand = newJGitBlameCommand();
@Test
public void properFailureIfNotAGitProject() throws IOException {
- File projectDir = temp.newFolder();
+ File projectDir = createNewTempFolder();
javaUnzip("dummy-git.zip", projectDir);
JGitBlameCommand jGitBlameCommand = newJGitBlameCommand();
@Test
public void testBlameOnNestedModule() throws IOException {
- File projectDir = temp.newFolder();
+ File projectDir = createNewTempFolder();
javaUnzip("dummy-git-nested.zip", projectDir);
JGitBlameCommand jGitBlameCommand = newJGitBlameCommand();
@Test
public void dontFailOnModifiedFile() throws IOException {
- File projectDir = temp.newFolder();
+ File projectDir = createNewTempFolder();
javaUnzip("dummy-git.zip", projectDir);
JGitBlameCommand jGitBlameCommand = newJGitBlameCommand();
@Test
public void dontFailOnNewFile() throws IOException {
- File projectDir = temp.newFolder();
+ File projectDir = createNewTempFolder();
javaUnzip("dummy-git.zip", projectDir);
JGitBlameCommand jGitBlameCommand = newJGitBlameCommand();
@Test
public void return_early_when_shallow_clone_detected() throws IOException {
- File projectDir = temp.newFolder();
+ File projectDir = createNewTempFolder();
javaUnzip("shallow-git.zip", projectDir);
File baseDir = new File(projectDir, "shallow-git");
@Test
public void return_early_when_clone_with_reference_detected() throws IOException {
- File projectDir = temp.newFolder();
+ File projectDir = createNewTempFolder();
javaUnzip("dummy-git-reference-clone.zip", projectDir);
Path baseDir = projectDir.toPath().resolve("dummy-git2");
verifyZeroInteractions(analysisWarnings);
}
+ private File createNewTempFolder() throws IOException {
+ //This is needed for Windows, otherwise the created File point to invalid (shortened by Windows) temp folder path
+ return temp.newFolder().toPath().toRealPath(LinkOption.NOFOLLOW_LINKS).toFile();
+ }
+
private JGitBlameCommand newJGitBlameCommand() {
return new JGitBlameCommand(new PathResolver(), mock(AnalysisWarnings.class));
}