scalac-options icon indicating copy to clipboard operation
scalac-options copied to clipboard

Add integration tests to check each supported scalac option against each supported scalac version

Open satorg opened this issue 3 years ago • 4 comments

This is a call-out to trigger a discussion rather than an issue itself.

We could create an IntegrationTest configuration and add tests that would verify whether a certain scalac option is really supported for a specific scalac version.

Checking it by hand is quite boring and unreliable and it would be nice to automate it somehow. A straightforward solution that comes to mind is using scala-cli for each option and every scala version the project supposed to support:

$ scala-cli compile -S 2.12.12 -O -Xlint:deprecation -- empty.scala
Compiling project (Scala 2.12.12, JVM)
Error: 'deprecation' is not a valid choice for '-Xlint'
Compiled project (Scala 2.12.12, JVM)

whereas

$ scala-cli compile -S 2.12.13 -O -Xlint:deprecation -- empty.scala

compiles without errors.

So would it be possible to employ scala-cli for integration tests in the project and does it look reasonable overall?

See also #5 for a related discussion.

satorg avatar Sep 14 '22 18:09 satorg

👍 to the idea. But I propose we just do it with scalac; scala-cli is an extra dependency to juggle with its own complications (like that it requires JDK 17 ....)

armanbilge avatar Sep 14 '22 18:09 armanbilge

👍 to the idea. But I propose we just do it with scalac; scala-cli is an extra dependency to juggle with its own complications (like that it requires JDK 17 ....)

Random thoughts: with coursier you can install a specific scalac version with cs install scalafmt:2.4.2. I bet itr can be used as a dependency very much we do in the tests of the typelevel toolkit, and with that we could theoretically download and install specific scalac version to use, with the proper flags, against a specific scala file.

Another chance would be leveraging sbt scripted tests maybe?

TonioGela avatar Mar 20 '24 18:03 TonioGela

scalac itself is a very ordinary dependency :) No need to fuss with coursier. We can just add every version of scalac to the build and then invoke them in isolated classloaders or something.

armanbilge avatar Mar 20 '24 19:03 armanbilge

scalac itself is a very ordinary dependency :) No need to fuss with coursier. We can just add every version of scalac to the build and then invoke them in isolated classloaders or something.

Okay, I'll sort out something then :)

TonioGela avatar Mar 20 '24 22:03 TonioGela