Skip to content

Commit

Permalink
Add Scala2 library TASTy testing instructions (#19218)
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
bishabosha authored Dec 7, 2023
2 parents ee2b74d + 096433f commit 16f1680
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/_docs/contributing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 16f1680

Please sign in to comment.