Commit e70c5f4
authored
Add support for multi-file tests (#76)
This PR adds support for writing multi translation-unit tests in the
below format. All multi translation-unit tests go into
`tests/multi-file`, one test per directory. `test.expectations` is an
optional file that contains one of the following test expectations:
no-compile, translation-fail, panic, nondet-result; or it can be empty
if the test is successful:
```
tests/multi-file/
└── extern_functions
├── a.c
├── b.c
├── CMakeLists.txt
├── out
│ ├── refcount
│ │ └── extern_functions.rs
│ └── unsafe
│ └── extern_functions.rs
└── test.expectations
```
I took this opportunity to refactor the logic inside `Cpp2RustTest.py`
because the `multi-file` addition did not fit well into the current
model. Now `Cpp2RustTest.py` is composed of:
* `TestExpectations`: dataclass describing the expected output of the
test: `should_panic, should_not_compile, should_not_translate,
is_nondet_result, xfail`. For classic tests (ub, benchmarks,
unit-tests), TestExpectations is populated from the comment line inside
the source file, for multi-file tests, TestExpectations is populated
from `test.expectatoins`
* `TestContext`: dataclass that defines all test steps (`setup,
translate, check_expected, build_cpp, build_rust, run_cpp, run_rust,
compare`) and keeps test specific data as member variables, including
`TestExpectations`
* `Cpp2RustTest`: entry point of lit, contains `execute` (which calls
directly into `TestContext`) `getTestsForPath` and `getTestsInDirectory`
* free helper functions1 parent 3d497fc commit e70c5f4
8 files changed
Lines changed: 442 additions & 182 deletions
File tree
- tests
- lit/lit/formats
- multi-file/extern_functions
- out
- refcount
- unsafe
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
0 commit comments