Scala Aspect tests find the wrong filename for source jars.
In com.google.idea.blaze.aspect.scala.scalalibrary.ScalaLibraryTest.testScalaLibrary(), there is a test that loads a test fixture based on the code in the aspect.scala.scalalibrary aspect test.
Right now, the code looks like this:
assertThat(target.getJavaIdeInfo().getJarsList().get(0).getJar().getRelativePath())
.isEqualTo(testRelative("simple.jar"));
// Also contains ijars for scala-library.
// Also contains jars + srcjars for liblibrary.
If we change the code to match the Java implementation (and actually match the ijar and -src.jar, it will fail:
assertThat(
target.getJavaIdeInfo().getJarsList().stream()
.map(IntellijAspectTest::libraryArtifactToString)
.collect(toList()))
.containsExactly(
jarString(
testRelative("simple.jar"),
testRelative("simple-ijar.jar"),
testRelative("simple-src.jar")));
difflib/DiffUtils
java.lang.NoClassDefFoundError:
at com.google.common.truth.Platform.makeDiff(Platform.java:82)
at com.google.common.truth.ComparisonFailureWithFacts.formatExpectedAndActual(ComparisonFailureWithFacts.java:102)
at com.google.common.truth.ComparisonFailureWithFacts.makeFacts(ComparisonFailureWithFacts.java:81)
at com.google.common.truth.ComparisonFailureWithFacts.create(ComparisonFailureWithFacts.java:49)
at com.google.common.truth.FailureMetadata.failEqualityCheck(FailureMetadata.java:179)
at com.google.common.truth.Subject.failEqualityCheck(Subject.java:913)
at com.google.common.truth.Subject.failEqualityCheckForEqualsWithoutDescription(Subject.java:867)
at com.google.common.truth.IterableSubject.containsExactlyElementsIn(IterableSubject.java:437)
at com.google.common.truth.IterableSubject.containsExactly(IterableSubject.java:360)
at com.google.idea.blaze.aspect.scala.scalalibrary.ScalaLibraryTest.testScalaLibrary(ScalaLibraryTest.java:52)
...
Debugging reveals that the actual name it finds for a source jar is "simple.-src.jar", with an extra period in the wrong place. And, indeed, if I change the last line to this, it passes:
testRelative("simple.-src.jar")));
This makes me think that there's a deeper bug in the way that the aspect is looking for scala source files.
Hello @BillyAutrey, Can you provide the example used in testing the above issue.
Yeah, I described exactly what I did above.
Here's the line as it exists today: https://github.com/bazelbuild/intellij/blob/68bc3a7e12181ecc36d557db9379111841aa5192/aspect/testing/tests/src/com/google/idea/blaze/aspect/scala/scalalibrary/ScalaLibraryTest.java#L43
And here's the Java version of the same assertion: https://github.com/bazelbuild/intellij/blob/68bc3a7e12181ecc36d557db9379111841aa5192/aspect/testing/tests/src/com/google/idea/blaze/aspect/java/javalibrary/JavaLibraryTest.java#L91
If you change the Scala code (in the first link) to match, like so:
assertThat(
target.getJavaIdeInfo().getJarsList().stream()
.map(IntellijAspectTest::libraryArtifactToString)
.collect(toList()))
.containsExactly(
jarString(
testRelative("simple.jar"),
testRelative("simple-ijar.jar"),
testRelative("simple-src.jar")));
This will fail, as described in my initial comment.
@BillyAutrey how did you get to this issue? Are you looking for source attachment to external jars? If yes, there are number of fixes that need to be made to get it working. I have a fork with a working implementation, but it will take some time to turn those changes into contributions to official plugin codebase. https://github.com/wix-playground/intellij/tree/scala-attach-sources
@liucijus yeah that's where we were headed. We actually got Scala sources to attach with some very minor changes, I couldn't get your changes to work in the default bazel code base.
@liucijus yeah that's where we were headed. We actually got Scala sources to attach with some very minor changes, I couldn't get your changes to work in the default bazel code base.
@BillyAutrey I have opened #4108 as an overview of all issues. If there are more case you're aware I would love to hear about them (repro would be more than appreciated).