scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

smallSeqAllocation test failure in Scala 2.12.12 #12082

Closed dragos closed 4 years ago

dragos commented 4 years ago

reproduction steps

I checked out tag v2.12.12, entered Sbt and ran junit tests.

problem

[error] Test scala.collection.SeqTest.smallSeqAllocation failed: java.lang.AssertionError: allocating min = 112 allowed = 24 -- collection seq  size 1
[error]  result was List(0)
[error]  result class scala.collection.immutable.$colon$colon
[error] Start allocation detail
[error] allocation 112 (1000 times)
[error] End allocation detail, took 0.003 sec
[error]     at scala.tools.testing.AllocationTest.exactAllocates(AllocationTest.scala:100)
[error]     at scala.tools.testing.AllocationTest.exactAllocates$(AllocationTest.scala:96)
[error]     at scala.collection.SeqTest.exactAllocates(SeqTest.scala:12)
[error]     at scala.collection.SeqTest.smallSeqAllocation(SeqTest.scala:76)

I noted the same failure with Oracle Java 8, OpenJDK 11, Mac and Linux. If I increase the warmup times to 100000 I can get that allocation number to 80, but not lower.

What is the right way to run this test?

lrytz commented 4 years ago

I get the same on MacOS with AdoptOpenJDK 1.8.0_222-b10, but it works after a bootstrap. The reason is that it's a compiler change (https://github.com/scala/scala/commit/8f657162dc) that makes it work, but without a bootstrap JUnit tests are compiled using the reference compiler (STARR).

So this test should have been done as partest, at least until bumping the starr - which actually happened on 2.12.x in the meantime (https://github.com/scala/scala/commit/71114c87df7d3ea17d88b368dbcccd2a154cbec5). So it doesn't make sense to change it at this point.

Sorry for the confusion 😕