Skip to content

Some tweaks to graph rendering, remove smir_pretty instances #43

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
merged 8 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
toolchain: nightly-2024-11-29 # Hardcoded version, same as is in the build.rs

- name: 'Build smir_pretty' # rustfmt documentation claims it is unstable on code that doesn't build
- name: 'Build stable-mir-json' # rustfmt documentation claims it is unstable on code that doesn't build
run: |
cargo build -vv

Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
with:
toolchain: nightly-2024-11-29 # Hardcoded version, same as is in the build.rs

- name: 'Build smir_pretty'
- name: 'Build stable-mir-json'
run: | # Warning check should be redundant since code-quality runs first
RUSTFLAGS='--deny warnings' cargo build -vv

Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "smir_pretty"
name = "stable_mir_pretty"
version = "0.1.0"
edition = "2021"

Expand Down
43 changes: 15 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,25 @@ To ensure code quality, all code is required to pass `cargo clippy` and `cargo f

## Tests

### Running the Tests

To run the tests, do the following:

```shell
make generate_ui_tests
```
Integration tests for `stable-mir-pretty` consist of compiling a number of (small)
programs with the wrapper compiler, and checking the output against expected JSON
data ("golden" tests).

This will generate four outputs:
The tests are stored [in `src/tests/integration/programs`](./src/tests/integration/programs).

| Path | Comment |
| --- | --- |
| `deps/rust/tests/ui/upstream` | Upstream `rustc` test outputs |
| `deps/rust/tests_ui_upstream.log` | Upstream test log |
| `deps/rust/tests/ui/smir` | `smir_pretty` test outputs (including `.smir.json` files) |
| `deps/rust/tests_ui_smir.log` | `smir_pretty` test log |
To compensate for any non-determinism in the output, the JSON file is first processed
to sort the array contents and remove data which changes with dependencies (such as
the crate hash suffix in the symbol names).

### Test Rationale
The JSON post-processing is performed [with `jq` using the script in `src/tests/integration/normalise-filter.jq`](./src/tests/integration/normalise-filter.jq).

Since this crate is a Stable MIR serialization tool, there are two main features we are interested in:
Some tests have non-deterministic output and are therefore expected to fail.
These tests are stored [in `src/tests/integration/failing`](./src/tests/integration/failing).

1. the serialization facilities should be stable (i.e. not crash)
2. the serialized output should be correct

Since this tool is currently in its early stages, it is hard to test (2).
However, to test (1) and to make progress towards (2), we currently do the following:

1. in the rustc test suite, we gather all of the run-pass tests, i.e., tests where the compiler is able to generate a binary _and_ subsequently execute the binary such that it exits successfully
2. we extract the test runner invocation from the `x.py test` command
3. we execute the test runner with upstream `rustc` against the test inputs from (1) --- this gives us a baseline on which tests should pass/fail
4. we re-execute the test runner but use our wrapper binary against the test inputs from (1) --- this generates the corresponding `.smir.json` files and shows us where any regressions occur
### Running the Tests

To run the tests, do the following:

**NOTE:** In order to speed up test time, we setup the test runner, by default, such that it skips codegen and compiler-generated binary execution.
**NOTE:** Points (1,4) also means that our test _outputs_ from this phase can become test _inputs_ for KMIR.
```shell
make integration-test
```
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod driver;
pub mod printer;
use driver::stable_mir_driver;
use printer::emit_smir;
use smir_pretty::mk_graph::emit_dotfile;
use stable_mir_pretty::mk_graph::emit_dotfile;

fn main() {
let mut args: Vec<String> = env::args().collect();
Expand Down
Loading