Skip to content

JUnit resident compiler bug / cross-talk between tests #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lrytz opened this issue Aug 31, 2016 · 4 comments
Open

JUnit resident compiler bug / cross-talk between tests #214

lrytz opened this issue Aug 31, 2016 · 4 comments
Assignees
Milestone

Comments

@lrytz
Copy link
Member

lrytz commented Aug 31, 2016

The following two tests in scala.tools.testkit.BytecodeTesting:

  @Test
  def eins(): Unit = {
    val code =
      """class A
        |class B extends A
        |class C extends B
      """.stripMargin
    compiler.compileClasses(code)
  }

  @Test
  def zwei(): Unit = {
    val jCode = List("interface A { }" -> "A.java")
    val code1 =
      """trait B extends A
        |class C extends B
      """.stripMargin
    compiler.compileClasses(code1, jCode)
  }

Individually they both run fine. When running them together (first eins, then zwei), we get

java.lang.AssertionError: assertion failed: The compiler issued non-allowed warnings or errors:
pos: source-unitTestSource.scala,line-2,offset=34 illegal inheritance; superclass Object
 is not a subclass of the supertrait A
 of the mixin trait B ERROR

    at scala.Predef$.assert(Predef.scala:219)
    at scala.tools.testing.Compiler.checkReport(BytecodeTesting.scala:45)
    at scala.tools.testing.Compiler.compileToBytes(BytecodeTesting.scala:52)
    at scala.tools.testing.Compiler.compileClasses(BytecodeTesting.scala:57)
    at scala.lang.traits.BytecodeTest.zwei(BytecodeTest.scala:262)

Renaming B to B1 in test zwei fixes the cross-talk. Possibly related to scala/scala@59d6dbc.

@lrytz lrytz self-assigned this Aug 31, 2016
@lrytz
Copy link
Member Author

lrytz commented Sep 21, 2016

Here's another one:

  @Test
  def a(): Unit = {
    val jCode = List("interface T { }" -> "T.java")
    val code = "class C extends T"
    compiler.compileClasses(code, jCode)
  }

  @Test
  def b(): Unit = {
    val jCode = List("interface A { }" -> "A.java")
    val code =
      """trait T extends A
        |class C extends T
      """.stripMargin
    compiler.compileClasses(code, jCode)
  }

@dwijnand
Copy link
Member

Optimistically closing that this was fixed in the rework that was scala/scala-partest#75.

@lrytz
Copy link
Member Author

lrytz commented Oct 26, 2020

This ticket is not about partest, but JUnit tests that use BytecodeTesting. There we use a single Global instance and only create a new Run per test. So the test failures are symptoms of bugs in the resident compiler.

Since both still reproduce, I re-open.

@lrytz lrytz reopened this Oct 26, 2020
@dwijnand dwijnand added this to the 2.13.5 milestone Oct 26, 2020
@dwijnand dwijnand self-assigned this Oct 26, 2020
@dwijnand dwijnand removed their assignment Dec 1, 2020
@dwijnand dwijnand modified the milestones: 2.13.5, Backlog Dec 1, 2020
@dwijnand
Copy link
Member

Individually they both run fine. When running them together (first eins, then zwei), we get

java.lang.AssertionError: assertion failed: The compiler issued non-allowed warnings or errors:

Perhaps due to adaptToNewRun not reverting/resetting flags (scala/scala#9141 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants