Browse Source

ConfigTest: fix on Windows

Change-Id: I37a2ef611aef97faf1b891a9660c1745435a915d
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.10
Marc Strapetz 7 years ago committed by Matthias Sohn
parent
commit
e1adfee5f5
  1. 16
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java

16
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java

@ -818,7 +818,7 @@ public class ConfigTest {
@Test @Test
public void testIncludeTooManyRecursions() throws IOException { public void testIncludeTooManyRecursions() throws IOException {
File config = tmp.newFile("config"); 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()); Files.write(config.toPath(), include.getBytes());
FileBasedConfig fbConfig = new FileBasedConfig(null, config, FileBasedConfig fbConfig = new FileBasedConfig(null, config,
FS.DETECTED); FS.DETECTED);
@ -838,8 +838,8 @@ public class ConfigTest {
File other = tmp.newFile("config.other"); File other = tmp.newFile("config.other");
String fooBar = "[foo]\nbar=true\n"; String fooBar = "[foo]\nbar=true\n";
String includeMore = "[include]\npath=" + more.toPath() + "\n"; String includeMore = "[include]\npath=" + pathToString(more) + "\n";
String includeOther = "path=" + other.toPath() + "\n"; String includeOther = "path=" + pathToString(other) + "\n";
String fooPlus = fooBar + includeMore + includeOther; String fooPlus = fooBar + includeMore + includeOther;
Files.write(config.toPath(), fooPlus.getBytes()); Files.write(config.toPath(), fooPlus.getBytes());
@ -849,12 +849,20 @@ public class ConfigTest {
String otherMore = "[other]\nmore=bar\n"; String otherMore = "[other]\nmore=bar\n";
Files.write(other.toPath(), otherMore.getBytes()); 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)); assertTrue(parsed.getBoolean("foo", "bar", false));
assertEquals("bar", parsed.getString("foo", null, "more")); assertEquals("bar", parsed.getString("foo", null, "more"));
assertEquals("bar", parsed.getString("other", 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 { private static void assertReadLong(long exp) throws ConfigInvalidException {
assertReadLong(exp, String.valueOf(exp)); assertReadLong(exp, String.valueOf(exp));
} }

Loading…
Cancel
Save