]> source.dussan.org Git - jgit.git/commitdiff
ConfigTest: fix on Windows 46/111846/5
authorMarc Strapetz <marc.strapetz@syntevo.com>
Mon, 20 Nov 2017 17:21:22 +0000 (18:21 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 4 Dec 2017 22:38:22 +0000 (23:38 +0100)
Change-Id: I37a2ef611aef97faf1b891a9660c1745435a915d
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java

index 748848e97fa4f92a487ad0c15131fcfb13458d36..7902bb53032a02dba9b939ce7a8bec6e72680fe1 100644 (file)
@@ -818,7 +818,7 @@ public class ConfigTest {
        @Test
        public void testIncludeTooManyRecursions() throws IOException {
                File config = tmp.newFile("config");
-               String include = "[include]\npath=" + config.toPath() + "\n";
+               String include = "[include]\npath=" + pathToString(config) + "\n";
                Files.write(config.toPath(), include.getBytes());
                FileBasedConfig fbConfig = new FileBasedConfig(null, config,
                                FS.DETECTED);
@@ -838,8 +838,8 @@ public class ConfigTest {
                File other = tmp.newFile("config.other");
 
                String fooBar = "[foo]\nbar=true\n";
-               String includeMore = "[include]\npath=" + more.toPath() + "\n";
-               String includeOther = "path=" + other.toPath() + "\n";
+               String includeMore = "[include]\npath=" + pathToString(more) + "\n";
+               String includeOther = "path=" + pathToString(other) + "\n";
                String fooPlus = fooBar + includeMore + includeOther;
                Files.write(config.toPath(), fooPlus.getBytes());
 
@@ -849,12 +849,20 @@ public class ConfigTest {
                String otherMore = "[other]\nmore=bar\n";
                Files.write(other.toPath(), otherMore.getBytes());
 
-               Config parsed = parse("[include]\npath=" + config.toPath() + "\n");
+               Config parsed = parse("[include]\npath=" + pathToString(config) + "\n");
                assertTrue(parsed.getBoolean("foo", "bar", false));
                assertEquals("bar", parsed.getString("foo", null, "more"));
                assertEquals("bar", parsed.getString("other", null, "more"));
        }
 
+       private static String pathToString(File file) {
+               final String path = file.getPath();
+               if (SystemReader.getInstance().isWindows()) {
+                       return path.replace('\\', '/');
+               }
+               return path;
+       }
+
        private static void assertReadLong(long exp) throws ConfigInvalidException {
                assertReadLong(exp, String.valueOf(exp));
        }