ConfigTest: Move pathToString to FileUtils
ConfigTest#pathToString is not visible to FileBasedConfigTest when bulding with bazel. Move it to FileUtils rather than messing about with the bazel build rules to make it visible. Change-Id: Idcfd4822699dac9dc4a426088a929a9cd31bf53f Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
26d78902f8
commit
df3a7c32a4
|
@ -53,6 +53,7 @@
|
||||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
import static org.eclipse.jgit.util.FileUtils.pathToString;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -855,14 +856,6 @@ public void testInclude() throws IOException, ConfigInvalidException {
|
||||||
assertEquals("bar", parsed.getString("other", null, "more"));
|
assertEquals("bar", parsed.getString("other", null, "more"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public 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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.jgit.storage.file;
|
package org.eclipse.jgit.storage.file;
|
||||||
|
|
||||||
|
import static org.eclipse.jgit.util.FileUtils.pathToString;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -52,7 +53,6 @@
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
import org.eclipse.jgit.lib.ConfigTest;
|
|
||||||
import org.eclipse.jgit.util.FS;
|
import org.eclipse.jgit.util.FS;
|
||||||
import org.eclipse.jgit.util.FileUtils;
|
import org.eclipse.jgit.util.FileUtils;
|
||||||
import org.eclipse.jgit.util.IO;
|
import org.eclipse.jgit.util.IO;
|
||||||
|
@ -164,7 +164,7 @@ public void testIncludeAbsolute()
|
||||||
final File includedFile = createFile(CONTENT1.getBytes());
|
final File includedFile = createFile(CONTENT1.getBytes());
|
||||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
bos.write("[include]\npath=".getBytes());
|
bos.write("[include]\npath=".getBytes());
|
||||||
bos.write(ConfigTest.pathToString(includedFile).getBytes());
|
bos.write(pathToString(includedFile).getBytes());
|
||||||
|
|
||||||
final File file = createFile(bos.toByteArray());
|
final File file = createFile(bos.toByteArray());
|
||||||
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
|
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
|
||||||
|
|
|
@ -869,4 +869,18 @@ public static File canonicalize(File file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a path to String, replacing separators as necessary.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return file's path as a String
|
||||||
|
* @since 4.10
|
||||||
|
*/
|
||||||
|
public static String pathToString(File file) {
|
||||||
|
final String path = file.getPath();
|
||||||
|
if (SystemReader.getInstance().isWindows()) {
|
||||||
|
return path.replace('\\', '/');
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue