|
| 1 | +# minicrater |
| 2 | + |
| 3 | +minicrater is the component of Crater's test suite that tests if the runs are |
| 4 | +actually executed and produce the correct result. It's inspired by rustc's |
| 5 | +compiletest. |
| 6 | + |
| 7 | +## Executing minicrater |
| 8 | + |
| 9 | +minicrater executions can take a few minutes to run, so it's ignored by default |
| 10 | +while running `cargo test`. You can run minicrater with: |
| 11 | + |
| 12 | +``` |
| 13 | +$ cargo test minicrater -- --ignored --test-threads 1 |
| 14 | +``` |
| 15 | + |
| 16 | +The runs' output is hidden by default, but you can show it by setting the |
| 17 | +`MINICRATER_SHOW_OUTPUT` environment variable: |
| 18 | + |
| 19 | +``` |
| 20 | +$ MINICRATER_SHOW_OUTPUT=1 cargo test minicrater -- --ignored --test-threads 1 |
| 21 | +``` |
| 22 | + |
| 23 | +## Adding tests to minicrater |
| 24 | + |
| 25 | +There are two ways to add a test to minicrater: |
| 26 | + |
| 27 | +* If your test requires different experiment configuration (like different |
| 28 | + flags or `config.toml` file entries) and no other minicrater run has the |
| 29 | + configuration you want you need to create a new minicrater run |
| 30 | +* Otherwise you can create a new local crate and have it tested by an existing |
| 31 | + minicrater run (usually the full ones) |
| 32 | + |
| 33 | +minicrater runs are defined in `tests/minicrater/mod.rs`, and each run has |
| 34 | +additional configuration in the `tests/minicrater/<run>` directory: a |
| 35 | +`config.toml` with the configuration file used for the run, and |
| 36 | +`results.expected.json`, which contains the JSON output expected in the |
| 37 | +generated report. |
| 38 | + |
| 39 | +### Adding new local crates |
| 40 | + |
| 41 | +minicrater doesn't test public crates available on crates.io, but "local |
| 42 | +crates", which are dummy crates located in the `local-crates` directory at the |
| 43 | +top of the project. To add a new local crate you need to actually create the |
| 44 | +crate in that directory and then run: |
| 45 | + |
| 46 | +``` |
| 47 | +$ cargo run create-lists |
| 48 | +``` |
| 49 | + |
| 50 | +The `create-lists` command is only needed when you add or remove local crates, |
| 51 | +not when you edit one of them. |
| 52 | + |
| 53 | +### Adding new minicrater runs |
| 54 | + |
| 55 | +To add a new minicrater run, you need to add a new entry to |
| 56 | +`tests/minicrater/mod.rs` and a configuration file in |
| 57 | +`tests/minicrater/<run>/config.toml`. Then you run minicrater - expecting the |
| 58 | +experiment to be failing - and execute the command shown in the output to |
| 59 | +generate the expected JSON report. |
0 commit comments