I'm having a problem with compiler testing. For so...
# ksp
g
I'm having a problem with compiler testing. For some reason, it does not detect KSP generated files. They have been successfully generated and it's possible to browse to them throught the file system, but they're not reported on the compilation result. It looks like it's looking for kapt generated stuff instead. Here's how I'm running it: <inside thread>
The processors are provided through a provider parameter in the paremeterized test. It never simultaneously contains kapt and ksp processors.
Code:
Copy code
compile(folder: File, vararg sourceFiles: SourceFile): KotlinCompilation.Result {
  val processors = provider.provide()
  val kspProcessors = processors.filterIsInstance<SymbolProcessor>()
  val kaptProcessors = processors.filterIsInstance<BasicAnnotationProcessor>()
  return KotlinCompilation()
    .apply {
      workingDir = folder
      inheritClassPath = true
      if (kspProcessors.isNotEmpty()) {
        symbolProcessors = kspProcessors
      } else if (kaptProcessors.isNotEmpty()) {
        annotationProcessors = kaptProcessors.asProcessorList
      }
      sources = sourceFiles.asList()
      verbose = false
      kspIncremental = true
    }.compile()
}

// ... during test
compile(temporaryFolder.root, SourceFile.kotlin(/* ... */))
y
hmm, is this with room compile testing? we do have tests for this, and in fact didn't you add similar ones for kotlin generated sources?
t
That’s a bug in the actual test compile library
Will search for the ticket and link it here in a few minutes
I guess this is probably what you are searching for: https://github.com/tschuchortdev/kotlin-compile-testing/issues/70
g
@yigit Not for room processor. Yes I did and they passed in room compile testing, but not in my personal project. I believe I was validating different things for room.
@Timo Gruen it’s very likely related indeed. It’s for generated stubs and sources as well in my scenario. I opened a ticket there.
y
there was some other issues w/ java class package names so the KspTestRunner in room does some additional setup.
maybe thats why it works there
though it was for java inputs, not outputs
g
I've created a workaround, mentioned it here: https://github.com/tschuchortdev/kotlin-compile-testing/issues/129#issuecomment-804390310 Basically used references in the result itself to navigate to where the sources would be generated. It's basically what it currently does for Kapt.