Skip to content

Add Scala2 library TASTy testing instructions #19218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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