Skip to content

Commit dd70d31

Browse files
celinvaloli-obk
authored andcommitted
Add a developer documentation to our book
1 parent bad1ac2 commit dd70d31

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
/book
2+
**/target
3+
4+
.idea
5+
*.swp
6+
*.swo
7+
.vscode

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- [Charter](./CHARTER.md)
55
- [Meetings](./meetings/README.md)
66
- [Draft RFCs](./draft-rfcs/README.md)
7+
- [Developer Documentation](./dev/README.md)

dev/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Development documentation
2+
3+
This folder contains some documentation useful for the development of Stable MIR
4+
5+
## Toolchain versions
6+
7+
Our CI currently run a nightly job that build and run our test suites against the latest nightly toolchain.
8+
This repository also contains a .toolchain file that specifies to use `nightly` channel.
9+
10+
However, if you already have the nightly toolchain installed, this will not update the toolchain to
11+
the latest nightly.
12+
You need to explicitly do that.
13+
14+
If you see some errors while compiling our tools, please ensure you have the latest nightly.
15+
You might also want to check [our nightly runs](https://github.com/rust-lang/project-stable-mir/actions/workflows/nightly.yml?query=branch%3Amain) to ensure they are not currently broken.
16+
If so, you can check what was the last successful nightly run, and use its nightly version.
17+
18+
## Tools
19+
20+
We currently have two different tools that is used to help with testing StableMIR
21+
22+
### TestDrive
23+
24+
This is a small driver that we build on the top of the rust compiler.
25+
By default, this driver behaves exactly like `rustc`, and it can be used to build a crate
26+
or multiple packages using cargo.
27+
28+
This driver also contains multiple checks that will inspect the stable MIR of the crate that was compiled.
29+
In order to run those tests, you need to pass an extra argument `--smir-check`.
30+
31+
Let's say we have a crate `input.rs`, in order to run all checks, one should invoke:
32+
33+
```shell
34+
cargo run -p test-drive -- --smir-check test.rs
35+
# or run the test-drive directly where ${BIN_PATH} is the binary location
36+
${BIN_PATH}/test-drive --smir-check test.rs
37+
```
38+
39+
In order to run this as part of a cargo build, you can run from a workspace:
40+
41+
```shell
42+
# Only check SMIR for the target crate
43+
RUSTC=${BIN_PATH} cargo rustc -p ${TARGET_PACKAGE} -- --smir-check
44+
45+
# Check SMIR for all crates being compiled, including dependencies
46+
RUSTC=${BIN_PATH} RUSTFLAGS=--smir-check cargo build
47+
```
48+
49+
This driver accepts a few other options that are all preceded with `--smir` prefix[^outdated]. For example
50+
- `--smir-fixme`: Will run checks that currently trigger a known bug in StableMIR.
51+
- `--smir-verbose`: Print status and failure messages.
52+
53+
[^outdated]: Since these are test tools, this documentation may be outdated.
54+
55+
### Compiletest
56+
57+
This is a little utility built on the top of `ui_test` crate.
58+
It scans our test folders and run tests according to the selected mode.
59+
For more details on how to run this utility, check its help option:
60+
```shell
61+
cargo run -p compiletest -- --help
62+
```
63+
64+
## Test Suites
65+
66+
We have a few different test suites for Stable MIR:
67+
- **Rust compiler [`ui-fulldeps/stable-mir`](https://github. com/rust-lang/rust/tree/master/tests/ui-fulldeps/stable-mir):**
68+
These are very simple sanity checks that live inside the main rust repository.
69+
These tests should cover very basic functionality related to the translation of internal structures to stable ones.
70+
- **Rust compiler suites:** We are enabling the execution of rust compiler test suites.
71+
These suites are run with the rust respository compiletest.
72+
To run them, I recommend using our script `scripts/run_rustc_tests.sh` since there are a lot of arguments.
73+
- **Local suites:** These are suites hosted in this repository inside `tests/`.
74+
These are run using our local `compilest` and
75+
`scripts/run_own_tests.sh` is a script to run all local suites
76+
- `fixme`: Single file crates that are currently failing.
77+
These tests are run using `--smir-fixme`.
78+
- `sanity-checks`: Small examples that exercise some specific construct.
79+
These tests succeed if compilation and all smir checks succeed.

0 commit comments

Comments
 (0)