Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-12-29 08:46:36 -0500
committerMichael Keppler2019-01-01 08:40:45 -0500
commitf634c72c5f71bddda477e2227c32e3aa1d134e46 (patch)
tree4d1be70341794e9468508793390000830b1ef9a6 /org.eclipse.egit.core.test/src
parent3e6afe375470bcc1abbf9d38aab6af30e3bda1ed (diff)
downloadegit-f634c72c5f71bddda477e2227c32e3aa1d134e46.tar.gz
egit-f634c72c5f71bddda477e2227c32e3aa1d134e46.tar.xz
egit-f634c72c5f71bddda477e2227c32e3aa1d134e46.zip
Fix path related failing tests on Windows
* DynamicVariablesTest: IPath.toString() uses a fixed separator "/", therefore the calculated variable value cannot be compared with the Windows file separator. * CommitFileRevisionTest: file revisions in commits are resolved using "/", therefore a relative Windows path cannot be located in the git storage. Change-Id: I9be225654fec285ddd1a4059fffac6058547b668 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/CommitFileRevisionTest.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/CommitFileRevisionTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/CommitFileRevisionTest.java
index 0e84b6b69..145d3013c 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/CommitFileRevisionTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/CommitFileRevisionTest.java
@@ -19,6 +19,7 @@ import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.List;
import org.eclipse.core.resources.IProject;
@@ -113,8 +114,7 @@ public class CommitFileRevisionTest extends GitTestCase {
assertEquals(1, content.size());
assertEquals("x", content.get(0));
// All right. Now get a CommitFileRevision and check its contents.
- String relativePath = repository.getWorkTree().toPath()
- .relativize(filePath).toString();
+ String relativePath = getRevisionPath(filePath);
CommitFileRevision fileRevision = new CommitFileRevision(repository,
head, relativePath);
ByteBuffer rawContent = null;
@@ -158,8 +158,7 @@ public class CommitFileRevisionTest extends GitTestCase {
assertEquals(1, content.size());
assertEquals("x", content.get(0));
// All right. Now get a CommitFileRevision and check its contents.
- String relativePath = repository.getWorkTree().toPath()
- .relativize(filePath).toString();
+ String relativePath = getRevisionPath(filePath);
CommitFileRevision fileRevision = new CommitFileRevision(repository,
head, relativePath);
ByteBuffer rawContent = null;
@@ -185,6 +184,15 @@ public class CommitFileRevisionTest extends GitTestCase {
}
}
+ /**
+ * @param filePath
+ * @return path with {@code /} as separator
+ */
+ private String getRevisionPath(Path filePath) {
+ return repository.getWorkTree().toPath().relativize(filePath).toString()
+ .replace('\\', '/');
+ }
+
@Test
public void testWithAttributesNotCheckedInButWithGlobalAttributes()
throws Exception {
@@ -222,8 +230,7 @@ public class CommitFileRevisionTest extends GitTestCase {
assertEquals(1, content.size());
assertEquals("x", content.get(0));
// All right. Now get a CommitFileRevision and check its contents.
- String relativePath = repository.getWorkTree().toPath()
- .relativize(filePath).toString();
+ String relativePath = getRevisionPath(filePath);
CommitFileRevision fileRevision = new CommitFileRevision(repository,
head, relativePath);
ByteBuffer rawContent = null;
@@ -281,8 +288,7 @@ public class CommitFileRevisionTest extends GitTestCase {
assertEquals(1, content.size());
assertEquals("x", content.get(0));
// All right. Now get a CommitFileRevision and check its contents.
- String relativePath = repository.getWorkTree().toPath()
- .relativize(filePath).toString();
+ String relativePath = getRevisionPath(filePath);
CommitFileRevision fileRevision = new CommitFileRevision(repository,
head, relativePath);
ByteBuffer rawContent = null;

Back to the top