VirtusLab / ide-probe

Apache License 2.0
26 stars 13 forks source link

UI tests stuck at `org.virtuslab.ideprobe.dependencies.IntelliJPatternResolver.replaceGlobsWithExistingDirectories` #324

Closed PawelLipski closed 1 year ago

PawelLipski commented 1 year ago

jstack on test process:

image

Happens only in CI for some reason (e.g. this build):

image

Could not reproduce locally so far

PawelLipski commented 1 year ago

The problem is in the tail-recursive implementation of org.virtuslab.ideprobe.dependencies.IntelliJResolver#replaceGlobsWithExistingDirectories, which apparently never ends if no match is found.

For the record, the offending paths were (for revision = 223.7571.58-EAP-SNAPSHOT):

probe {
  resolvers {
    intellij.repositories = [
      # Let's first try using the IntelliJs downloaded by intellij-plugin-verifier or Gradle, if present.
      "file:///"${HOME}"/.pluginVerifier/ides/IC-[revision]/",
      "file:///"${HOME}"/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/[revision]/*/ideaIC-[revision]/",
      official
    ]
  }
}

It's likely that the infinite loop happened on ~/.pluginVerifier/ides/IC-[revision]/ (which was missing from the filesystem) rather than on ~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/[revision]/*/ideaIC-[revision]/ (which was present on filesystem). Note that in such case, replaceGlobsWithExistingDirectories will be invoked ad infinitum with originalPattern unchanged ‼️

PawelLipski commented 1 year ago

Simple repro: add the following path in org.virtuslab.ideprobe.dependencies.IntelliJResolverTest#resolvesIntelliJPatternWithGlobesUsed:

    val probeConfig = IntelliJFixture.readIdeProbeConfig(
      Config.fromString(s"""
                           |probe.resolvers.intellij.repositories = [
                           |  "file:///non/*/path",   # this one!
                           |  "$mavenRepo/com/*/intellij/*/$mavenArtifact/${mavenVersion.build}/$mavenArtifact-${mavenVersion.build}.zip"
                           |]
                           |""".stripMargin),
      "probe"
    )
PawelLipski commented 1 year ago

Out the options I've checked, https://github.com/EsotericSoftware/wildcard seems the most reasonable (other libs, including java.nio and apache-commons seem to go through every single file under the specified root folder, which is a 2/10 solution)... although it isn't even published to Maven Central (let alone maintained) 😅

So, fixing the existing logic might be a better idea indeed