Skip to content
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

Unit test failures on 2.13.12 #3580

Closed
som-snytt opened this issue Jul 7, 2023 · 0 comments · Fixed by #3581
Closed

Unit test failures on 2.13.12 #3580

som-snytt opened this issue Jul 7, 2023 · 0 comments · Fixed by #3581

Comments

@som-snytt
Copy link

som-snytt commented Jul 7, 2023

Unit tests fail on the Scala 2 community build.

Configuration (required)

HEAD

Problem

[scalafmt] [error] Failed tests:
[scalafmt] [error] 	org.scalafmt.FidelityTest
[scalafmt] [error] 	org.scalafmt.FormatTests

Notes

It looks like Tokens#last doesn't throw on empty Tokens. Scalafmt should handle empty tokens:

defnBeforeTemplate(leftOwner).filter(_.tokens.nonEmpty).map { x =>
  val policyEnd = Policy.End.On(x.tokens.last)
  delayedBreakPolicy(policyEnd)(forceNewlineBeforeExtends)
}

(I didn't pursue a fix.)

Noticed at scala/community-build#1680 (comment)

==> X org.scalafmt.FormatTests.unit/Annotations.stat:59: #1640                                       |  0.001s org.scalafmt.util.FormatException: java.util.NoSuchElementException: last of empty IndexedSeq
    at org.scalafmt.FormatTests.run(FormatTests.scala:56)
    at org.scalafmt.FormatTests.$anonfun$new$3(FormatTests.scala:33)
    at org.scalafmt.FormatTests.$anonfun$new$3$adapted(FormatTests.scala:33)
    at org.scalafmt.util.CanRunTests.$anonfun$runTest$2(CanRunTests.scala:19)
Caused by: java.util.NoSuchElementException: last of empty IndexedSeq
    at scala.collection.IndexedSeqOps.last(IndexedSeq.scala:110)
    at scala.collection.IndexedSeqOps.last$(IndexedSeq.scala:105)
    at scala.meta.tokens.Tokens.last(Tokens.scala:29)
    at org.scalafmt.internal.Router.$anonfun$getSplitsImpl$118(Router.scala:838)
    at scala.Option.map(Option.scala:242)
    at org.scalafmt.internal.Router.getSplitsImpl(Router.scala:837)
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.

1 participant