diff --git a/docs/_docs/contributing/testing.md b/docs/_docs/contributing/testing.md index 3c65c1591d40..f755bcafcd66 100644 --- a/docs/_docs/contributing/testing.md +++ b/docs/_docs/contributing/testing.md @@ -155,6 +155,34 @@ To run `testCompilation` on a bootstrapped Dotty compiler, use Some tests can only be run in bootstrapped compilers; that includes all tests with `with-compiler` in their name. +### Scala 2 library TASTy tests + +Usually we use the Scala 2 library JAR (with classfiles) generated by Scala 2. We can +also use a special version of the library that we generate with only TASTy files. This +JAR is added to the classpath before the Scala 2 library JAR. This allows the compiler +to load the TASTy and the runtime to load the original classfiles. + +The library is compiled in `scala2-library-bootstrapped` with TASTy and classfiles. +These classfiles should not be used. The `scala2-library-tasty` project repackages the +JAR `scala2-library-bootstrapped` to only keep TASTy files. The `scala2-library-tasty-tests` provides some basic tests using the library TASTy JAR. + +``` +$ sbt +> scala2-library-tasty/compile +> scala2-library-tasty-tests/run +> scala2-library-tasty-tests/test +``` + +We can enable this library in the build using the SBT setting `useScala2LibraryTasty`. This setting can only be used by bootstrapped compiler tests and is currently only supported for `test` (or `testCompilation`) and `scalac` (or `run`). + +``` +$ sbt +> set ThisBuild/Build.useScala2LibraryTasty := true +> scala3-compiler-bootstrapped/scalac MyFile.scala +> scala3-compiler-bootstrapped/test +> scala3-compiler-bootstrapped/testCompilation +``` + ### From TASTy tests `testCompilation` has an additional mode to run tests that compile code from a `.tasty` file.