diff --git a/javatests/dagger/internal/codegen/ComponentHierarchyValidationTest.java b/javatests/dagger/internal/codegen/ComponentHierarchyValidationTest.java index c55b394551f..ea3f983fe6f 100644 --- a/javatests/dagger/internal/codegen/ComponentHierarchyValidationTest.java +++ b/javatests/dagger/internal/codegen/ComponentHierarchyValidationTest.java @@ -71,9 +71,11 @@ public void singletonSubcomponent() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("conflicting scopes"); - subject.hasErrorContaining("test.Parent also has @Singleton"); + subject.hasErrorContaining( + String.join( + "\n", + "test.Child has conflicting scopes:", + " test.Parent also has @Singleton")); }); // Check that compiling with disableInterComponentScopeValidation=none flag succeeds. @@ -178,9 +180,11 @@ public void producerModuleRepeated() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("test.Child repeats @ProducerModules:"); - subject.hasErrorContaining("test.Parent also installs: test.RepeatedProducerModule") + subject.hasErrorContaining( + String.join( + "\n", + "test.Child repeats @ProducerModules:", + "test.Parent also installs: test.RepeatedProducerModule")) .onSource(component) .onLineContaining("interface Parent"); }); @@ -304,14 +308,13 @@ public void repeatedModulesWithScopes() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining( - "test.Child repeats modules with scoped bindings or declarations:"); - subject.hasErrorContaining("- test.Parent also includes:"); - subject.hasErrorContaining( - " - test.ModuleWithScopedProvides with scopes: @test.TestScope"); subject.hasErrorContaining( - " - test.ModuleWithScopedBinds with scopes: @test.TestScope"); + String.join( + "\n", + "test.Child repeats modules with scoped bindings or declarations:", + "- test.Parent also includes:", + " - test.ModuleWithScopedProvides with scopes: @test.TestScope", + " - test.ModuleWithScopedBinds with scopes: @test.TestScope")); }); } diff --git a/javatests/dagger/internal/codegen/ConflictingEntryPointsTest.java b/javatests/dagger/internal/codegen/ConflictingEntryPointsTest.java index ba66682425f..45d29210dbe 100644 --- a/javatests/dagger/internal/codegen/ConflictingEntryPointsTest.java +++ b/javatests/dagger/internal/codegen/ConflictingEntryPointsTest.java @@ -78,10 +78,12 @@ public void covariantType() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("can only implement the method once. Found:"); - subject.hasErrorContaining(" Long test.Base1.foo()"); - subject.hasErrorContaining(" Number test.Base2.foo()") + subject.hasErrorContaining( + String.join( + "\n", + "can only implement the method once. Found:", + " Long test.Base1.foo()", + " Number test.Base2.foo()")) .onSource(component) .onLineContaining("interface TestComponent"); }); @@ -128,10 +130,12 @@ public void covariantTypeFromGenericSupertypes() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("can only implement the method once. Found:"); - subject.hasErrorContaining(" Long test.Base1.foo()"); - subject.hasErrorContaining(" Number test.Base2.foo()") + subject.hasErrorContaining( + String.join( + "\n", + "can only implement the method once. Found:", + " Long test.Base1.foo()", + " Number test.Base2.foo()")) .onSource(component) .onLineContaining("interface TestComponent"); }); @@ -181,10 +185,12 @@ public void differentQualifier() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("can only implement the method once. Found:"); - subject.hasErrorContaining(" Object test.Base1.foo()"); - subject.hasErrorContaining(" @Named(\"foo\") Object test.Base2.foo()") + subject.hasErrorContaining( + String.join( + "\n", + "can only implement the method once. Found:", + " Object test.Base1.foo()", + " @Named(\"foo\") Object test.Base2.foo()")) .onSource(component) .onLineContaining("interface TestComponent"); }); diff --git a/javatests/dagger/internal/codegen/DependencyCycleValidationTest.java b/javatests/dagger/internal/codegen/DependencyCycleValidationTest.java index dec1c3b5201..e759bdc775e 100644 --- a/javatests/dagger/internal/codegen/DependencyCycleValidationTest.java +++ b/javatests/dagger/internal/codegen/DependencyCycleValidationTest.java @@ -85,19 +85,23 @@ public void cyclicDependency() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.A(cParam)"); - subject.hasErrorContaining(" Outer.A is injected at"); - subject.hasErrorContaining(" Outer.B(aParam)"); - subject.hasErrorContaining(" Outer.B is injected at"); - subject.hasErrorContaining(" Outer.C(bParam)"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.A(cParam)"); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" Outer.C is requested at"); - subject.hasErrorContaining(" Outer.CComponent.getC()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " Outer.C is injected at", + " Outer.A(cParam)", + " Outer.A is injected at", + " Outer.B(aParam)", + " Outer.B is injected at", + " Outer.C(bParam)", + " Outer.C is injected at", + " Outer.A(cParam)", + " ...", + "", + "The cycle is requested via:", + " Outer.C is requested at", + " Outer.CComponent.getC()")) .onSource(SIMPLE_CYCLIC_DEPENDENCY) .onLineContaining("interface CComponent"); }); @@ -187,23 +191,25 @@ public void cyclicDependencyWithModuleBindingValidation() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.A(cParam)"); - subject.hasErrorContaining(" Outer.A is injected at"); - subject.hasErrorContaining(" Outer.B(aParam)"); - subject.hasErrorContaining(" Outer.B is injected at"); - subject.hasErrorContaining(" Outer.C(bParam)"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.A(cParam)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.D(cParam)"); - subject.hasErrorContaining(" Outer.D is requested at"); - subject.hasErrorContaining(" Outer.DComponent.getD()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " Outer.C is injected at", + " Outer.A(cParam)", + " Outer.A is injected at", + " Outer.B(aParam)", + " Outer.B is injected at", + " Outer.C(bParam)", + " Outer.C is injected at", + " Outer.A(cParam)", + " ...", + "", + "The cycle is requested via:", + " Outer.C is injected at", + " Outer.D(cParam)", + " Outer.D is requested at", + " Outer.DComponent.getD()")) .onSource(component) .onLineContaining("interface DComponent"); }); @@ -257,23 +263,25 @@ public void cyclicDependencyNotBrokenByMapBinding() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.CModule.c(c)"); - subject.hasErrorContaining(" Map is injected at"); - subject.hasErrorContaining(" Outer.A(cMap)"); - subject.hasErrorContaining(" Outer.A is injected at"); - subject.hasErrorContaining(" Outer.B(aParam)"); - subject.hasErrorContaining(" Outer.B is injected at"); - subject.hasErrorContaining(" Outer.C(bParam)"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.CModule.c(c)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" Outer.C is requested at"); - subject.hasErrorContaining(" Outer.CComponent.getC()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " Outer.C is injected at", + " Outer.CModule.c(c)", + " Map is injected at", + " Outer.A(cMap)", + " Outer.A is injected at", + " Outer.B(aParam)", + " Outer.B is injected at", + " Outer.C(bParam)", + " Outer.C is injected at", + " Outer.CModule.c(c)", + " ...", + "", + "The cycle is requested via:", + " Outer.C is requested at", + " Outer.CComponent.getC()")) .onSource(component) .onLineContaining("interface CComponent"); }); @@ -325,23 +333,25 @@ public void cyclicDependencyWithSetBinding() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.CModule.c(c)"); - subject.hasErrorContaining(" Set is injected at"); - subject.hasErrorContaining(" Outer.A(cSet)"); - subject.hasErrorContaining(" Outer.A is injected at"); - subject.hasErrorContaining(" Outer.B(aParam)"); - subject.hasErrorContaining(" Outer.B is injected at"); - subject.hasErrorContaining(" Outer.C(bParam)"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.CModule.c(c)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" Outer.C is requested at"); - subject.hasErrorContaining(" Outer.CComponent.getC()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " Outer.C is injected at", + " Outer.CModule.c(c)", + " Set is injected at", + " Outer.A(cSet)", + " Outer.A is injected at", + " Outer.B(aParam)", + " Outer.B is injected at", + " Outer.C(bParam)", + " Outer.C is injected at", + " Outer.CModule.c(c)", + " ...", + "", + "The cycle is requested via:", + " Outer.C is requested at", + " Outer.CComponent.getC()")) .onSource(component) .onLineContaining("interface CComponent"); }); @@ -388,23 +398,25 @@ public void falsePositiveCyclicDependencyIndirectionDetected() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.A(cParam)"); - subject.hasErrorContaining(" Outer.A is injected at"); - subject.hasErrorContaining(" Outer.B(aParam)"); - subject.hasErrorContaining(" Outer.B is injected at"); - subject.hasErrorContaining(" Outer.C(bParam)"); - subject.hasErrorContaining(" Outer.C is injected at"); - subject.hasErrorContaining(" Outer.A(cParam)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" Provider is injected at"); - subject.hasErrorContaining(" Outer.D(cParam)"); - subject.hasErrorContaining(" Outer.D is requested at"); - subject.hasErrorContaining(" Outer.DComponent.getD()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " Outer.C is injected at", + " Outer.A(cParam)", + " Outer.A is injected at", + " Outer.B(aParam)", + " Outer.B is injected at", + " Outer.C(bParam)", + " Outer.C is injected at", + " Outer.A(cParam)", + " ...", + "", + "The cycle is requested via:", + " Provider is injected at", + " Outer.D(cParam)", + " Outer.D is requested at", + " Outer.DComponent.getD()")) .onSource(component) .onLineContaining("interface DComponent"); }); @@ -479,19 +491,21 @@ public void cyclicDependencyInSubcomponents() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" String is injected at"); - subject.hasErrorContaining(" CycleModule.object(string)"); - subject.hasErrorContaining(" Object is injected at"); - subject.hasErrorContaining(" CycleModule.string(object)"); - subject.hasErrorContaining(" String is injected at"); - subject.hasErrorContaining(" CycleModule.object(string)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" String is requested at"); - subject.hasErrorContaining(" Grandchild.entry()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " String is injected at", + " CycleModule.object(string)", + " Object is injected at", + " CycleModule.string(object)", + " String is injected at", + " CycleModule.object(string)", + " ...", + "", + "The cycle is requested via:", + " String is requested at", + " Grandchild.entry()")) .onSource(parent) .onLineContaining("interface Parent"); }); @@ -568,19 +582,21 @@ public void cyclicDependencyInSubcomponentsWithChildren() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" String is injected at"); - subject.hasErrorContaining(" CycleModule.object(string)"); - subject.hasErrorContaining(" Object is injected at"); - subject.hasErrorContaining(" CycleModule.string(object)"); - subject.hasErrorContaining(" String is injected at"); - subject.hasErrorContaining(" CycleModule.object(string)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" String is requested at"); - subject.hasErrorContaining(" Child.entry() [Parent → Child]") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " String is injected at", + " CycleModule.object(string)", + " Object is injected at", + " CycleModule.string(object)", + " String is injected at", + " CycleModule.object(string)", + " ...", + "", + "The cycle is requested via:", + " String is requested at", + " Child.entry() [Parent → Child]")) .onSource(parent) .onLineContaining("interface Parent"); }); @@ -626,19 +642,21 @@ public void circularBindsMethods() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" Object is injected at"); - subject.hasErrorContaining(" TestModule.bindQualified(unqualified)"); - subject.hasErrorContaining(" @SomeQualifier Object is injected at"); - subject.hasErrorContaining(" TestModule.bindUnqualified(qualified)"); - subject.hasErrorContaining(" Object is injected at"); - subject.hasErrorContaining(" TestModule.bindQualified(unqualified)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" Object is requested at"); - subject.hasErrorContaining(" TestComponent.unqualified()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " Object is injected at", + " TestModule.bindQualified(unqualified)", + " @SomeQualifier Object is injected at", + " TestModule.bindUnqualified(qualified)", + " Object is injected at", + " TestModule.bindQualified(unqualified)", + " ...", + "", + "The cycle is requested via:", + " Object is requested at", + " TestComponent.unqualified()")) .onSource(component) .onLineContaining("interface TestComponent"); }); @@ -675,17 +693,19 @@ public void selfReferentialBinds() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" Object is injected at"); - subject.hasErrorContaining(" TestModule.bindToSelf(sameKey)"); - subject.hasErrorContaining(" Object is injected at"); - subject.hasErrorContaining(" TestModule.bindToSelf(sameKey)"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" Object is requested at"); - subject.hasErrorContaining(" TestComponent.selfReferential()") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " Object is injected at", + " TestModule.bindToSelf(sameKey)", + " Object is injected at", + " TestModule.bindToSelf(sameKey)", + " ...", + "", + "The cycle is requested via:", + " Object is requested at", + " TestComponent.selfReferential()")) .onSource(component) .onLineContaining("interface TestComponent"); }); @@ -732,21 +752,23 @@ public void cycleFromMembersInjectionMethod_WithSameKeyAsMembersInjectionMethod( .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("Found a dependency cycle:"); - subject.hasErrorContaining(" test.B is injected at"); - subject.hasErrorContaining(" test.A.b"); - subject.hasErrorContaining(" test.A is injected at"); - subject.hasErrorContaining(" test.B.a"); - subject.hasErrorContaining(" test.B is injected at"); - subject.hasErrorContaining(" test.A.b"); - subject.hasErrorContaining(" ..."); - subject.hasErrorContaining(""); - subject.hasErrorContaining("The cycle is requested via:"); - subject.hasErrorContaining(" test.B is injected at"); - subject.hasErrorContaining(" test.A.b"); - subject.hasErrorContaining(" test.A is injected at"); - subject.hasErrorContaining(" CycleComponent.inject(test.A)") + subject.hasErrorContaining( + String.join( + "\n", + "Found a dependency cycle:", + " test.B is injected at", + " test.A.b", + " test.A is injected at", + " test.B.a", + " test.B is injected at", + " test.A.b", + " ...", + "", + "The cycle is requested via:", + " test.B is injected at", + " test.A.b", + " test.A is injected at", + " CycleComponent.inject(test.A)")) .onSource(component) .onLineContaining("interface CycleComponent"); }); diff --git a/javatests/dagger/internal/codegen/MapMultibindingValidationTest.java b/javatests/dagger/internal/codegen/MapMultibindingValidationTest.java index 5d5adabe1a4..68564b21a43 100644 --- a/javatests/dagger/internal/codegen/MapMultibindingValidationTest.java +++ b/javatests/dagger/internal/codegen/MapMultibindingValidationTest.java @@ -209,16 +209,15 @@ public void duplicateMapKeys_WrappedMapKey() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. subject.hasErrorContaining( - "\033[1;31m[Dagger/MapKeys]\033[0m The same map key is bound more than once for " - + "Map"); - subject.hasErrorContaining( - " @Provides @IntoMap @MapModule.WrappedMapKey(\"foo\") String " - + "MapModule.stringMapEntry1()"); - subject.hasErrorContaining( - " @Provides @IntoMap @MapModule.WrappedMapKey(\"foo\") String " - + "MapModule.stringMapEntry2()") + String.join( + "\n", + "\033[1;31m[Dagger/MapKeys]\033[0m The same map key is bound more than " + + "once for Map", + " @Provides @IntoMap @MapModule.WrappedMapKey(\"foo\") String " + + "MapModule.stringMapEntry1()", + " @Provides @IntoMap @MapModule.WrappedMapKey(\"foo\") String " + + "MapModule.stringMapEntry2()")) .onSource(component) .onLineContaining("interface TestComponent"); }); diff --git a/javatests/dagger/internal/codegen/ScopingValidationTest.java b/javatests/dagger/internal/codegen/ScopingValidationTest.java index a72375c1146..fe112a2bcfb 100644 --- a/javatests/dagger/internal/codegen/ScopingValidationTest.java +++ b/javatests/dagger/internal/codegen/ScopingValidationTest.java @@ -72,14 +72,15 @@ public void componentWithoutScopeIncludesScopedBindings_Fail() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. subject.hasErrorContaining( - "MyComponent (unscoped) may not reference scoped bindings:"); - subject.hasErrorContaining(" @Singleton class ScopedType"); - subject.hasErrorContaining(" ScopedType is requested at"); - subject.hasErrorContaining(" MyComponent.string()"); - subject.hasErrorContaining(""); - subject.hasErrorContaining(" @Provides @Singleton String ScopedModule.string()"); + String.join( + "\n", + "MyComponent (unscoped) may not reference scoped bindings:", + " @Singleton class ScopedType", + " ScopedType is requested at", + " MyComponent.string()", + "", + " @Provides @Singleton String ScopedModule.string()")); }); } @@ -157,11 +158,12 @@ public void bindsWithChildScope_inParentModule_notAllowed() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. subject.hasErrorContaining( - "Parent scoped with @Singleton may not reference bindings with different " - + "scopes:"); - subject.hasErrorContaining(" @Binds @ChildScope Foo ParentModule.bind(FooImpl)"); + String.join( + "\n", + "Parent scoped with @Singleton may not reference bindings with different " + + "scopes:", + " @Binds @ChildScope Foo ParentModule.bind(FooImpl)")); }); } @@ -232,23 +234,22 @@ public void componentWithScopeIncludesIncompatiblyScopedBindings_Fail() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining( - "MyComponent scoped with @Singleton may not reference bindings with different " - + "scopes:"); - subject.hasErrorContaining(" @PerTest class ScopedType"); - subject.hasErrorContaining(" ScopedType is requested at"); - subject.hasErrorContaining(" MyComponent.string()"); - subject.hasErrorContaining(""); - subject.hasErrorContaining(" @Provides @PerTest String ScopedModule.string()"); - subject.hasErrorContaining(""); - subject.hasErrorContaining( - String.format( - " @Provides @Per(%s) boolean ScopedModule.bool()", + subject + .hasErrorContaining( + String.join( + "\n", + "MyComponent scoped with @Singleton may not reference bindings with " + + "different scopes:", + " @PerTest class ScopedType", + " ScopedType is requested at", + " MyComponent.string()", + "", + " @Provides @PerTest String ScopedModule.string()", + "", // TODO(b/241293838): Remove dependency on backend once this bug is fixed. CompilerTests.backend(subject).equals(XProcessingEnv.Backend.JAVAC) - ? "MyComponent.class" - : "MyComponent")) + ? " @Provides @Per(MyComponent.class) boolean ScopedModule.bool()" + : " @Provides @Per(MyComponent) boolean ScopedModule.bool()")) .onSource(componentFile) .onLineContaining("interface MyComponent"); }); @@ -259,20 +260,18 @@ public void componentWithScopeIncludesIncompatiblyScopedBindings_Fail() { .compile( subject -> { subject.hasErrorCount(2); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. - subject.hasErrorContaining("ScopedModule contains bindings with different scopes:"); - subject.hasErrorContaining(" @Provides @PerTest String ScopedModule.string()"); - subject.hasErrorContaining(""); - subject.hasErrorContaining( - " @Provides @Singleton float ScopedModule.floatingPoint()"); - subject.hasErrorContaining(""); subject.hasErrorContaining( - String.format( - " @Provides @Per(%s) boolean ScopedModule.bool()", + String.join( + "\n", + "ScopedModule contains bindings with different scopes:", + " @Provides @PerTest String ScopedModule.string()", + "", + " @Provides @Singleton float ScopedModule.floatingPoint()", + "", // TODO(b/241293838): Remove dependency on backend once this bug is fixed. CompilerTests.backend(subject).equals(XProcessingEnv.Backend.JAVAC) - ? "MyComponent.class" - : "MyComponent")) + ? " @Provides @Per(MyComponent.class) boolean ScopedModule.bool()" + : " @Provides @Per(MyComponent) boolean ScopedModule.bool()")) .onSource(moduleFile) .onLineContaining("class ScopedModule"); }); @@ -645,10 +644,11 @@ public void componentWithoutScopeCannotDependOnScopedComponent() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. subject.hasErrorContaining( - "test.UnscopedComponent (unscoped) cannot depend on scoped components:"); - subject.hasErrorContaining(" @Singleton test.ScopedComponent"); + String.join( + "\n", + "test.UnscopedComponent (unscoped) cannot depend on scoped components:", + " @Singleton test.ScopedComponent")); }); } @@ -703,10 +703,11 @@ public void componentWithSingletonScopeMayNotDependOnOtherScope() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. subject.hasErrorContaining( - "This @Singleton component cannot depend on scoped components:"); - subject.hasErrorContaining(" @test.SimpleScope test.SimpleScopedComponent"); + String.join( + "\n", + "This @Singleton component cannot depend on scoped components:", + " @test.SimpleScope test.SimpleScopedComponent")); }); } @@ -791,13 +792,14 @@ public void componentScopeWithMultipleScopedDependenciesMustNotCycle() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. subject.hasErrorContaining( - "test.ComponentShort depends on scoped components in a non-hierarchical scope " - + "ordering:"); - subject.hasErrorContaining(" @test.ScopeA test.ComponentLong"); - subject.hasErrorContaining(" @test.ScopeB test.ComponentMedium1"); - subject.hasErrorContaining(" @test.ScopeA test.ComponentShort"); + String.join( + "\n", + "test.ComponentShort depends on scoped components in a non-hierarchical " + + "scope ordering:", + " @test.ScopeA test.ComponentLong", + " @test.ScopeB test.ComponentMedium1", + " @test.ScopeA test.ComponentShort")); }); } @@ -873,13 +875,14 @@ public void componentScopeAncestryMustNotCycle() { .compile( subject -> { subject.hasErrorCount(1); - // TODO(b/243689574): Combine this to a single assertion once this bug is fixed. subject.hasErrorContaining( - "test.ComponentShort depends on scoped components in a non-hierarchical scope " - + "ordering:"); - subject.hasErrorContaining(" @test.ScopeA test.ComponentLong"); - subject.hasErrorContaining(" @test.ScopeB test.ComponentMedium"); - subject.hasErrorContaining(" @test.ScopeA test.ComponentShort"); + String.join( + "\n", + "test.ComponentShort depends on scoped components in a non-hierarchical " + + "scope ordering:", + " @test.ScopeA test.ComponentLong", + " @test.ScopeB test.ComponentMedium", + " @test.ScopeA test.ComponentShort")); }); // Test that compilation succeeds when transitive validation is disabled because the scope cycle