From 2b4be8b8c210abb34740f0778434679b644a6525 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Tue, 19 Dec 2017 23:00:27 -0800 Subject: [PATCH] Fix all annotation testing issues on Windows (#2721) Signed-off-by: Alex Saveau --- .../AppGlideModuleWithExcludesTest.java | 15 +++++++++------ .../AppGlideModuleWithMultipleExcludesTest.java | 15 +++++++++------ .../EmptyAppAndLibraryGlideModulesTest.java | 17 ++++++++++------- .../compiler/EmptyAppGlideModuleTest.java | 15 +++++++++------ .../compiler/EmptyLibraryGlideModuleTest.java | 3 ++- .../compiler/GlideExtensionOptionsTest.java | 5 +++-- .../compiler/GlideExtensionWithOptionTest.java | 15 +++++++++------ .../compiler/GlideExtensionWithTypeTest.java | 15 +++++++++------ .../LegacyGlideExtensionOptionsTest.java | 5 +++-- .../LegacyGlideExtensionWithOptionTest.java | 15 +++++++++------ .../LegacyGlideExtensionWithTypeTest.java | 15 +++++++++------ .../MultipleEmptyLibraryGlideModuleTest.java | 3 ++- .../glide/annotation/compiler/test/Util.java | 13 +++++++++++-- 13 files changed, 94 insertions(+), 57 deletions(-) diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithExcludesTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithExcludesTest.java index f1319c13e9..42033b8a70 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithExcludesTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithExcludesTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.appResource; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyLibraryModule; import static com.bumptech.glide.annotation.compiler.test.Util.glide; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; @@ -39,7 +40,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideOptions.java").getCharContent(true))); } @Test @@ -47,7 +48,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequest.java").getCharContent(true))); } @Test @@ -55,7 +56,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequests.java").getCharContent(true))); } @Test @@ -63,7 +64,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideApp.java").getCharContent(true))); } @Test @@ -71,7 +72,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -79,7 +81,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithMultipleExcludesTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithMultipleExcludesTest.java index 29263481a5..13a77cca1a 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithMultipleExcludesTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/AppGlideModuleWithMultipleExcludesTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.appResource; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.glide; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; import static com.google.testing.compile.CompilationSubject.assertThat; @@ -39,7 +40,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideOptions.java").getCharContent(true))); } @Test @@ -47,7 +48,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequest.java").getCharContent(true))); } @Test @@ -55,7 +56,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequests.java").getCharContent(true))); } @Test @@ -63,7 +64,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideApp.java").getCharContent(true))); } @Test @@ -71,7 +72,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -79,7 +81,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppAndLibraryGlideModulesTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppAndLibraryGlideModulesTest.java index af7ffe4698..804686071b 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppAndLibraryGlideModulesTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppAndLibraryGlideModulesTest.java @@ -2,6 +2,7 @@ import static com.bumptech.glide.annotation.compiler.test.Util.annotation; import static com.bumptech.glide.annotation.compiler.test.Util.appResource; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule; import static com.bumptech.glide.annotation.compiler.test.Util.emptyLibraryModule; import static com.bumptech.glide.annotation.compiler.test.Util.glide; @@ -49,7 +50,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideOptions.java").getCharContent(true))); } @Test @@ -57,7 +58,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequest.java").getCharContent(true))); } @Test @@ -65,7 +66,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequests.java").getCharContent(true))); } @Test @@ -73,7 +74,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideApp.java").getCharContent(true))); } @Test @@ -81,7 +82,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -89,7 +91,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } @Test @@ -99,7 +102,7 @@ public void compilation_generatesExpectedIndexer() throws IOException { assertThat(compilation) .generatedSourceFile(annotation(expectedClassName)) .contentsAsUtf8String() - .isEqualTo(libraryResource(expectedClassName + ".java").getCharContent(true)); + .isEqualTo(asUnixChars(libraryResource(expectedClassName + ".java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppGlideModuleTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppGlideModuleTest.java index f852f4dbc5..0d70d94e47 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppGlideModuleTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyAppGlideModuleTest.java @@ -1,5 +1,6 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.glide; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; import static com.google.testing.compile.CompilationSubject.assertThat; @@ -42,7 +43,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideOptions.java").getCharContent(true))); } @Test @@ -50,7 +51,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideRequest.java").getCharContent(true))); } @Test @@ -58,7 +59,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideRequests.java").getCharContent(true))); } @Test @@ -66,7 +67,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideApp.java").getCharContent(true))); } @Test @@ -74,7 +75,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(forResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -82,7 +84,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(forResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(forResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyLibraryGlideModuleTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyLibraryGlideModuleTest.java index db6d337d19..8f330f9ddb 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyLibraryGlideModuleTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/EmptyLibraryGlideModuleTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.annotation; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.google.testing.compile.CompilationSubject.assertThat; import static com.google.testing.compile.Compiler.javac; @@ -43,7 +44,7 @@ public void compilation_generatesExpectedIndexer() throws IOException { assertThat(compilation) .generatedSourceFile(annotation(expectedClassName)) .contentsAsUtf8String() - .isEqualTo(forResource(expectedClassName + ".java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource(expectedClassName + ".java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionOptionsTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionOptionsTest.java index 8ee72aacf8..76ce82b98b 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionOptionsTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionOptionsTest.java @@ -1,5 +1,6 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; import static com.google.testing.compile.CompilationSubject.assertThat; @@ -94,7 +95,7 @@ String file() { } private void runTest(String subDir, Subject subject) throws IOException { - Compilation compilation = + Compilation compilation = javac() .withProcessors(new GlideAnnotationProcessor()) .compile( @@ -105,7 +106,7 @@ private void runTest(String subDir, Subject subject) throws IOException { assertThat(compilation) .generatedSourceFile(subpackage(subject.name())) .contentsAsUtf8String() - .isEqualTo(forResource(subDir, subject.file()).getCharContent(true)); + .isEqualTo(asUnixChars(forResource(subDir, subject.file()).getCharContent(true))); } private JavaFileObject extension(String subdir) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithOptionTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithOptionTest.java index ac56e2fa00..1c5528f19f 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithOptionTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithOptionTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.appResource; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule; import static com.bumptech.glide.annotation.compiler.test.Util.glide; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; @@ -46,7 +47,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideOptions.java").getCharContent(true))); } @Test @@ -54,7 +55,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideRequest.java").getCharContent(true))); } @Test @@ -62,7 +63,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequests.java").getCharContent(true))); } @Test @@ -70,7 +71,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideApp.java").getCharContent(true))); } @Test @@ -78,7 +79,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -86,7 +88,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithTypeTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithTypeTest.java index 832fad6001..c7f63e1759 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithTypeTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/GlideExtensionWithTypeTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.appResource; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule; import static com.bumptech.glide.annotation.compiler.test.Util.glide; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; @@ -45,7 +46,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideOptions.java").getCharContent(true))); } @Test @@ -53,7 +54,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequest.java").getCharContent(true))); } @Test @@ -61,7 +62,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideRequests.java").getCharContent(true))); } @Test @@ -69,7 +70,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideApp.java").getCharContent(true))); } @Test @@ -77,7 +78,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -85,7 +87,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionOptionsTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionOptionsTest.java index 2cc9e38b72..a222d50269 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionOptionsTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionOptionsTest.java @@ -1,5 +1,6 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; import static com.google.testing.compile.CompilationSubject.assertThat; @@ -83,7 +84,7 @@ String file() { } private void runTest(String subDir, Subject subject) throws IOException { - Compilation compilation = + Compilation compilation = javac() .withProcessors(new GlideAnnotationProcessor()) .compile( @@ -94,7 +95,7 @@ private void runTest(String subDir, Subject subject) throws IOException { assertThat(compilation) .generatedSourceFile(subpackage(subject.name())) .contentsAsUtf8String() - .isEqualTo(forResource(subDir, subject.file()).getCharContent(true)); + .isEqualTo(asUnixChars(forResource(subDir, subject.file()).getCharContent(true))); } private JavaFileObject extension(String subdir) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithOptionTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithOptionTest.java index 5f09e8f0b5..b59df722cc 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithOptionTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithOptionTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.appResource; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule; import static com.bumptech.glide.annotation.compiler.test.Util.glide; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; @@ -52,7 +53,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideOptions.java").getCharContent(true))); } @Test @@ -60,7 +61,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideRequest.java").getCharContent(true))); } @Test @@ -68,7 +69,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequests.java").getCharContent(true))); } @Test @@ -76,7 +77,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideApp.java").getCharContent(true))); } @Test @@ -84,7 +85,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -92,7 +94,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithTypeTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithTypeTest.java index 9688e8d341..aae339426d 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithTypeTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/LegacyGlideExtensionWithTypeTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.appResource; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.bumptech.glide.annotation.compiler.test.Util.emptyAppModule; import static com.bumptech.glide.annotation.compiler.test.Util.glide; import static com.bumptech.glide.annotation.compiler.test.Util.subpackage; @@ -45,7 +46,7 @@ public void compilation_generatesExpectedGlideOptionsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideOptions")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideOptions.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideOptions.java").getCharContent(true))); } @Test @@ -53,7 +54,7 @@ public void compilation_generatesExpectedGlideRequestClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequest")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideRequest.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideRequest.java").getCharContent(true))); } @Test @@ -61,7 +62,7 @@ public void compilation_generatesExpectedGlideRequestsClass() throws IOException assertThat(compilation) .generatedSourceFile(subpackage("GlideRequests")) .contentsAsUtf8String() - .isEqualTo(forResource("GlideRequests.java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource("GlideRequests.java").getCharContent(true))); } @Test @@ -69,7 +70,7 @@ public void compilationGeneratesExpectedGlideAppClass() throws IOException { assertThat(compilation) .generatedSourceFile(subpackage("GlideApp")) .contentsAsUtf8String() - .isEqualTo(appResource("GlideApp.java").getCharContent(true)); + .isEqualTo(asUnixChars(appResource("GlideApp.java").getCharContent(true))); } @Test @@ -77,7 +78,8 @@ public void compilation_generatesExpectedGeneratedAppGlideModuleImpl() throws IO assertThat(compilation) .generatedSourceFile(glide("GeneratedAppGlideModuleImpl")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedAppGlideModuleImpl.java").getCharContent(true))); } @Test @@ -85,7 +87,8 @@ public void compilation_generatesExpectedGeneratedRequestManagerFactory() throws assertThat(compilation) .generatedSourceFile(glide("GeneratedRequestManagerFactory")) .contentsAsUtf8String() - .isEqualTo(appResource("GeneratedRequestManagerFactory.java").getCharContent(true)); + .isEqualTo( + asUnixChars(appResource("GeneratedRequestManagerFactory.java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleEmptyLibraryGlideModuleTest.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleEmptyLibraryGlideModuleTest.java index 65b21812ab..02baba8e61 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleEmptyLibraryGlideModuleTest.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/MultipleEmptyLibraryGlideModuleTest.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.compiler.test.Util.annotation; +import static com.bumptech.glide.annotation.compiler.test.Util.asUnixChars; import static com.google.testing.compile.CompilationSubject.assertThat; import static com.google.testing.compile.Compiler.javac; @@ -45,7 +46,7 @@ public void compilation_generatesExpectedIndexerForModules() throws IOException assertThat(compilation) .generatedSourceFile(annotation(expectedClassName)) .contentsAsUtf8String() - .isEqualTo(forResource(expectedClassName + ".java").getCharContent(true)); + .isEqualTo(asUnixChars(forResource(expectedClassName + ".java").getCharContent(true))); } private JavaFileObject forResource(String name) { diff --git a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/test/Util.java b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/test/Util.java index f52a7574a4..19a1111a14 100644 --- a/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/test/Util.java +++ b/annotation/compiler/test/src/test/java/com/bumptech/glide/annotation/compiler/test/Util.java @@ -1,7 +1,6 @@ package com.bumptech.glide.annotation.compiler.test; import com.google.testing.compile.JavaFileObjects; -import java.io.File; import javax.tools.JavaFileObject; /** Test utilities. */ @@ -11,6 +10,12 @@ public final class Util { private static final String ANNOTATION_PACKAGE_NAME = "com.bumptech.glide.annotation.compiler"; private static final String DEFAULT_APP_DIR_NAME = "EmptyAppGlideModuleTest"; private static final String DEFAULT_LIBRARY_DIR_NAME = "EmptyLibraryGlideModuleTest"; + /** + * Hardcoded file separator to workaround {@code JavaFileObjects.forResource(...)} defaulting to + * the unix one. + */ + private static final String FILE_SEPARATOR = "/"; + private static final String LINE_SEPARATOR = "\n"; private Util() { // Utility class. @@ -33,7 +38,7 @@ public static JavaFileObject libraryResource(String className) { } public static JavaFileObject forResource(String directoryName, String name) { - return JavaFileObjects.forResource(directoryName + File.separator + name); + return JavaFileObjects.forResource(directoryName + FILE_SEPARATOR + name); } public static String annotation(String className) { @@ -48,6 +53,10 @@ public static String glide(String className) { return qualified(GLIDE_PACKAGE_NAME, className); } + public static CharSequence asUnixChars(CharSequence chars) { + return chars.toString().replace(System.lineSeparator(), LINE_SEPARATOR); + } + private static String qualified(String packageName, String className) { return packageName + '.' + className; }