cornichon icon indicating copy to clipboard operation
cornichon copied to clipboard

Scala 3 support

Open agourlay opened this issue 2 years ago • 2 comments

Most of the complexity comes from migrating the BodyElementCollectorMacro macro.

Might be tacked with https://github.com/agourlay/cornichon/issues/736

Acceptance criteria:

  • cross compiling 2.12, 2.13, 3.x (dropping 2.12?)
  • introduce new unit tests for validating that the DSL yields the same Feature objects across Scala versions
  • no performance regression

agourlay avatar Jan 29 '24 16:01 agourlay

It seems the dependency on PureConfig with auto derivation is also a problem to tackle during the migration.

agourlay avatar Mar 02 '24 09:03 agourlay

It might be possible to drop the macro in Scala 3 by using context functions.

Credits to @yanns for the idea :beers:

agourlay avatar Oct 21 '24 18:10 agourlay

Hi there!

I hope you’re doing well.

I’m wondering if there are any plans or progress updates regarding Scala 3 support. Has this task been scheduled or started yet?

Any information you can share would be greatly appreciated.

Thank you!

mprevel avatar Dec 19 '24 15:12 mprevel

@mprevel No concrete work on Scala 3 has been started outside of the discussion on this issue.

TBH I have no bandwidth to push this change so it would have be to be driven by external contributors.

The migration plan is more or less:

  1. Check if all dependencies are available for Scala 3
  2. Check if the BodyElementCollectorMacro can be replaced by context functions OR else rewrite the macro for Scala 3

I am happy to provide guidance with the internals if necessary :)

agourlay avatar Jan 02 '25 10:01 agourlay

Hi @agourlay,

I've tried to add support for scala 3.

What I've done:

  1. update of build.sbt
  2. migration of pureconfig conf for scala 3
  3. a few rewrites to be able to share code between versions (common syntax for function parameters, parboiled2 parser fixes, ...)
  4. moved some files to dedicated scala versions scala-2/ scala-3 so both can compile and have running tests

What is blocking now is the CoreDsl part. I don't think context functions can fit here because the DSL allows this kind of samples:

Scenario("name") {
  step1
  step2
  step3
}

If my understanding is good, these steps cannot be grouped to a List[Step] using context functions. With a mutable approach and a builder pattern we could probably achieve it but it would break the current DSL.

Scenario("name") {
  step(step1)
  step(step2)
  step(step3)
}

So, if I'm not mistaken, keeping the exact same DSL means we have to use Scala 3 macros. If we switch to context functions instead, it would require changing the DSL.

mprevel avatar Jan 09 '25 13:01 mprevel

@mprevel Thank you very much for getting the migration started :clap:

I trust your research regarding context functions, I did not look too deep into it myself.

So, if I'm not mistaken, keeping the exact same DSL means we have to use Scala 3 macros. If we switch to context functions instead, it would require changing the DSL.

You are right, we cannot break the DSL at this point. Which means using Scala 3 macros. Do you have any experience with those?

Thanks for picking this up again!

agourlay avatar Jan 13 '25 10:01 agourlay

Fixed in 0.22.0

agourlay avatar Jan 25 '25 08:01 agourlay