|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: Running the Test Suite |
| 4 | +--- |
| 5 | + |
| 6 | +Partest is a custom parallel testing tool that we use to run the test suite for the Scala compiler and library. Go the scala project folder from your local checkout and run it via `ant` or standalone as follows. |
| 7 | + |
| 8 | +## Using ant |
| 9 | + |
| 10 | +The test suite can be run by using ant from the command line: |
| 11 | + |
| 12 | + $ ant test.suite |
| 13 | + |
| 14 | +## Standalone |
| 15 | + |
| 16 | +There are launch scripts `partest` and `partest.bat` in the `test` folder of the scala project. To have partest run failing tests only and print details about test failures to the console, you can use |
| 17 | + |
| 18 | + ./test/partest --show-diff --show-log --failed |
| 19 | + |
| 20 | +You can get a summary of the usage by running partest without arguments. |
| 21 | + |
| 22 | +* Most commonly you want to invoke partest with an option that tells it which part of the tests to run. For example `--all`, `--pos`, `--neg` or `--run`. |
| 23 | +* You can test individual files by specifying individual test files (`.scala` files) as options. Several files can be tested if they are from the same category, e.g., `pos`. |
| 24 | +* You can enable output of log and diff using the `-show-log` and `-show-diff` options. |
| 25 | +* If you get into real trouble, and want to find out what partest does, you can run it with option `--verbose`. This info is useful as part of bug reports. |
| 26 | +* Set custom path from where to load classes: `-classpath <path>` and `-buildpath <path>`. |
| 27 | +* You can use the `SCALAC_OPTS` environment variable to pass command line options to the compiler. |
| 28 | +* You can use the `JAVA_OPTS` environment variable to pass command line options to the runner (e.g., for `run/jvm` tests). |
| 29 | +* The launch scripts run partest as follows: |
| 30 | + |
| 31 | + scala -cp <path to partest classes> scala.tools.partest.nest.NestRunner <options> |
| 32 | + |
| 33 | + Partest classes from a `quick` build, e.g., can be found in `./build/quick/classes/partest/`. |
| 34 | + |
| 35 | + Partest will tell you where it loads compiler/library classes from by adding the `partest.debug` property: |
| 36 | + |
| 37 | + scala -Dpartest.debug=true -cp <path to partest classes> scala.tools.partest.nest.NestRunner <options> |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +## ScalaCheck tests |
| 42 | + |
| 43 | +Tests that depend on [ScalaCheck](https://github.com/rickynils/scalacheck) can be added under folder `./test/files/scalacheck`. A sample test: |
| 44 | + |
| 45 | + import org.scalacheck._ |
| 46 | + import Prop._ |
| 47 | + |
| 48 | + object Test { |
| 49 | + val prop_ConcatLists = property{ (l1: ListInt, l2: ListInt) => |
| 50 | + l1.size + l2.size == (l1 ::: l2).size |
| 51 | + } |
| 52 | + |
| 53 | + val tests = List(("prop_ConcatLists", prop_ConcatLists)) |
| 54 | + } |
| 55 | + |
| 56 | +## Troubleshooting |
| 57 | + |
| 58 | +### Windows |
| 59 | + |
| 60 | +Some tests might fail because line endings in the `.check` files and the produced results do not match. In that case, set either |
| 61 | + |
| 62 | + git config core.autocrlf false |
| 63 | + |
| 64 | +or |
| 65 | + |
| 66 | + git config core.autocrlf input |
0 commit comments