Skip to content

Commit

Permalink
fix: adjust unit tests to take odd lazy evaluation into account
Browse files Browse the repository at this point in the history
What's happening here is that the NamedDomainObjectContainer implementation used for targets is not triggering lazy evaluation when calling size. Thus, an inaccurate upper estimate is returned instead of the actual size. In our case, there are two lazy stubs created by calling "register" from the plugin and "named" from the script. These stubs are not considered to be one domain object (despite configuring the same) because they have not been evaluated yet.
  • Loading branch information
TheMrMilchmann committed Aug 14, 2024
1 parent 0f374a5 commit 159ec40
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class LWJGLPluginUnitTest {
project.pluginManager.apply(LWJGLPlugin::class.java)
val lwjgl3 = project.extensions.getByType(LWJGLExtension::class.java)

assertEquals(0, lwjgl3.targets.size)
assertEquals(0, lwjgl3.targets.asMap.size)
project.pluginManager.apply(JavaPlugin::class.java)
assertEquals(0, lwjgl3.targets.size)
assertEquals(0, lwjgl3.targets.asMap.size)
}

@Test
Expand All @@ -69,9 +69,9 @@ class LWJGLPluginUnitTest {
project.pluginManager.apply(LWJGLPlugin::class.java)
val lwjgl3 = project.extensions.getByType(LWJGLExtension::class.java)

assertEquals(0, lwjgl3.targets.size)
assertEquals(0, lwjgl3.targets.asMap.size)
project.pluginManager.apply(JavaPlugin::class.java)
assertEquals(1, lwjgl3.targets.size)
assertEquals(1, lwjgl3.targets.asMap.size)
}

@Test
Expand All @@ -81,9 +81,9 @@ class LWJGLPluginUnitTest {

val lwjgl3 = project.extensions.getByType(LWJGLExtension::class.java)

assertEquals(0, lwjgl3.targets.size)
assertEquals(0, lwjgl3.targets.asMap.size)
project.pluginManager.apply(JavaPlugin::class.java)
assertEquals(1, lwjgl3.targets.size)
assertEquals(1, lwjgl3.targets.asMap.size)
}

}

0 comments on commit 159ec40

Please sign in to comment.