diff options
author | 2016-07-25 08:26:14 +0000 | |
---|---|---|
committer | 2016-07-25 11:41:31 +0000 | |
commit | 56f94b6d2a685858372393c414a1d9cad74e6e91 (patch) | |
tree | 9db2a5230f00c3ec84d05d9d2fe81d2fe87745ea /src/test/java/com/google/devtools/build/android/ConvertersTest.java | |
parent | b669406789dd452161875d407d0ce6a3502de5f6 (diff) |
Fixed ConvertersTest on Windows
Recently, a new java test is added into Bazel, but failing on Windows because using the wrong path separator.
This change fixs it.
--
Change-Id: Ib73abac9c22b1d21180f76c13358a1173fde863c
Reviewed-on: https://bazel-review.googlesource.com/#/c/4131
MOS_MIGRATED_REVID=128331068
Diffstat (limited to 'src/test/java/com/google/devtools/build/android/ConvertersTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/android/ConvertersTest.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/test/java/com/google/devtools/build/android/ConvertersTest.java b/src/test/java/com/google/devtools/build/android/ConvertersTest.java index 130a7ec964..83bbe66677 100644 --- a/src/test/java/com/google/devtools/build/android/ConvertersTest.java +++ b/src/test/java/com/google/devtools/build/android/ConvertersTest.java @@ -24,6 +24,7 @@ import com.google.devtools.build.android.Converters.PathListConverter; import com.google.devtools.build.android.Converters.PathStringDictionaryConverter; import com.google.devtools.build.android.Converters.StringDictionaryConverter; import com.google.devtools.common.options.OptionsParsingException; +import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; @@ -41,8 +42,9 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class ConvertersTest { - @Rule - public final TemporaryFolder tmp = new TemporaryFolder(); + private static final String SEPARATOR = File.pathSeparator; + + @Rule public final TemporaryFolder tmp = new TemporaryFolder(); @Rule public final ExpectedException expected = ExpectedException.none(); @@ -90,9 +92,11 @@ public final class ConvertersTest { @Test public void testPathListConverter() throws Exception { PathListConverter converter = new PathListConverter(); - List<Path> result = converter.convert("foo:bar::baz:"); + List<Path> result = + converter.convert("foo" + SEPARATOR + "bar" + SEPARATOR + SEPARATOR + "baz" + SEPARATOR); assertThat(result) - .containsAllOf(Paths.get("foo"), Paths.get("bar"), Paths.get("baz")).inOrder(); + .containsAllOf(Paths.get("foo"), Paths.get("bar"), Paths.get("baz")) + .inOrder(); } @Test @@ -102,7 +106,7 @@ public final class ConvertersTest { expected.expect(OptionsParsingException.class); expected.expectMessage(String.format("%s is not a valid path: it does not exist.", arg)); ExistingPathListConverter converter = new ExistingPathListConverter(); - converter.convert(Joiner.on(":").join(existingFile.toString(), arg)); + converter.convert(Joiner.on(SEPARATOR).join(existingFile.toString(), arg)); } @Test @@ -162,7 +166,10 @@ public final class ConvertersTest { public void testExistingPathStringDictionaryConverter() throws Exception { Path existingFile = tmp.newFile("existing").toPath(); ExistingPathStringDictionaryConverter converter = new ExistingPathStringDictionaryConverter(); - Map<Path, String> result = converter.convert(String.format("%s:string", existingFile)); + Map<Path, String> result = + converter + // On Windows, the path starts like C:\foo\bar\..., we need to escape the colon. + .convert(String.format("%s:string", existingFile.toString().replace(":", "\\:"))); assertThat(result).containsExactly(existingFile, "string"); } } |