Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Feb 1, 2024
1 parent a0159f8 commit 4390d85
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ object ApolloCompiler {
codegenSchemaOptions: CodegenSchemaOptions,
irOptions: IrOptions,
codegenOptions: CodegenOptions,
layout: (CodegenSchema) -> SchemaAndOperationsLayout?,
layout: ((CodegenSchema) -> SchemaAndOperationsLayout)?,
operationOutputGenerator: OperationOutputGenerator?,
compilerJavaHooks: List<ApolloCompilerJavaHooks>?,
compilerKotlinHooks: List<ApolloCompilerKotlinHooks>?,
Expand Down Expand Up @@ -483,7 +483,7 @@ object ApolloCompiler {
downstreamUsedCoordinates = emptyMap(),
upstreamCodegenMetadata = emptyList(),
codegenOptions = codegenOptions,
layout = layout(codegenSchema),
layout = layout?.invoke(codegenSchema),
compilerJavaHooks = compilerJavaHooks,
compilerKotlinHooks = compilerKotlinHooks,
operationManifestFile = operationManifestFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ abstract class ApolloGenerateSourcesBaseTask : DefaultTask() {
}


fun ApolloGenerateSourcesBaseTask.layout(codegenSchema: CodegenSchema): SchemaAndOperationsLayout? {
fun ApolloGenerateSourcesBaseTask.layout(): ((CodegenSchema) -> SchemaAndOperationsLayout)? {
return if (packageNameGenerator != null) {
val options = codegenOptionsFile.get().asFile.toCodegenOptions()
Layout(codegenSchema, packageNameGenerator!!, options.useSemanticNaming ?: defaultUseSemanticNaming, options.decapitalizeFields ?: defaultDecapitalizeFields)
{
val options = codegenOptionsFile.get().asFile.toCodegenOptions()
Layout(it, packageNameGenerator!!, options.useSemanticNaming ?: defaultUseSemanticNaming, options.decapitalizeFields ?: defaultDecapitalizeFields)
}
} else {
null
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class ApolloGenerateSourcesFromIrTask : ApolloGenerateSourcesBaseTask()
downstreamUsedCoordinates = downstreamUsedCoordinates.get(),
upstreamCodegenMetadata = upstreamMetadata.files.map { it.toCodegenMetadata() },
codegenOptions = codegenOptionsFile.get().asFile.toCodegenOptions(),
layout = layout(codegenSchemaFile.toCodegenSchema()),
layout = layout()?.invoke(codegenSchemaFile.toCodegenSchema()),
compilerKotlinHooks = compilerKotlinHooks,
compilerJavaHooks = compilerJavaHooks,
operationManifestFile = operationManifestFile.orNull?.asFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class ApolloGenerateSourcesTask : ApolloGenerateSourcesBaseTask() {
codegenOptions = codegenOptionsFile.get().asFile.toCodegenOptions(),
irOptions = irOptionsFile.get().asFile.toIrOptions(),
logger = logger(),
layout = { layout(it) },
layout = layout(),
operationOutputGenerator = operationOutputGenerator,
compilerJavaHooks = compilerJavaHooks,
compilerKotlinHooks = compilerKotlinHooks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MultiModulesTests {
TestUtils.withTestProject("multi-modules-transitive") { dir ->
val result = TestUtils.executeTask(":leaf:assemble", dir)
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:assemble")!!.outcome)
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:generateServiceApolloSourcesFromIr")!!.outcome)
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:generateServiceApolloSources")!!.outcome)
}
}

Expand All @@ -34,7 +34,7 @@ class MultiModulesTests {
*/
TestUtils.withTestProject("multi-modules-diamond") { dir ->
val result = TestUtils.executeTask(":leaf:jar", dir)
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:generateServiceApolloSourcesFromIr")!!.outcome)
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:generateServiceApolloSources")!!.outcome)
}
}

Expand Down Expand Up @@ -73,17 +73,17 @@ class MultiModulesTests {
val result = TestUtils.executeTask(":node1:impl:jar", dir)

Truth.assertThat(result.task(":node1:impl:generateServiceApolloIrOperations")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
Truth.assertThat(result.task(":node1:impl:generateServiceApolloSourcesFromIr")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
Truth.assertThat(result.task(":node1:impl:generateServiceApolloSources")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
Truth.assertThat(result.task(":node1:impl:compileKotlin")?.outcome).isEqualTo(TaskOutcome.SUCCESS)

// This is recompiled because root:generateServiceApolloSourcesFromIr needs it
Truth.assertThat(result.task(":node2:impl:generateServiceApolloIrOperations")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
// But the codegen and compile kotlin are not executed
Truth.assertThat(result.task(":node2:impl:generateServiceApolloSourcesFromIr")?.outcome).isEqualTo(null)
Truth.assertThat(result.task(":node2:impl:generateServiceApolloSources")?.outcome).isEqualTo(null)
Truth.assertThat(result.task(":node2:impl:compileKotlin")?.outcome).isEqualTo(null)

// Because we didn't add any new type, this shouldn't change
Truth.assertThat(result.task(":root:generateServiceApolloSourcesFromIr")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
Truth.assertThat(result.task(":root:generateServiceApolloSources")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE)
}
}

Expand Down

0 comments on commit 4390d85

Please sign in to comment.