Skip to content

Commit 16f1680

Browse files
authored
Add Scala2 library TASTy testing instructions (#19218)
[skip ci]
2 parents ee2b74d + 096433f commit 16f1680

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/_docs/contributing/testing.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,34 @@ To run `testCompilation` on a bootstrapped Dotty compiler, use
155155
Some tests can only be run in bootstrapped compilers; that includes all tests
156156
with `with-compiler` in their name.
157157

158+
### Scala 2 library TASTy tests
159+
160+
Usually we use the Scala 2 library JAR (with classfiles) generated by Scala 2. We can
161+
also use a special version of the library that we generate with only TASTy files. This
162+
JAR is added to the classpath before the Scala 2 library JAR. This allows the compiler
163+
to load the TASTy and the runtime to load the original classfiles.
164+
165+
The library is compiled in `scala2-library-bootstrapped` with TASTy and classfiles.
166+
These classfiles should not be used. The `scala2-library-tasty` project repackages the
167+
JAR `scala2-library-bootstrapped` to only keep TASTy files. The `scala2-library-tasty-tests` provides some basic tests using the library TASTy JAR.
168+
169+
```
170+
$ sbt
171+
> scala2-library-tasty/compile
172+
> scala2-library-tasty-tests/run
173+
> scala2-library-tasty-tests/test
174+
```
175+
176+
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`).
177+
178+
```
179+
$ sbt
180+
> set ThisBuild/Build.useScala2LibraryTasty := true
181+
> scala3-compiler-bootstrapped/scalac MyFile.scala
182+
> scala3-compiler-bootstrapped/test
183+
> scala3-compiler-bootstrapped/testCompilation
184+
```
185+
158186
### From TASTy tests
159187

160188
`testCompilation` has an additional mode to run tests that compile code from a `.tasty` file.

0 commit comments

Comments
 (0)