| 1 |
<!-- Copyright 2025 The Fuchsia Authors |
| 2 |
|
| 3 |
Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| 4 |
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT |
| 5 |
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. |
| 6 |
This file may not be copied, modified, or distributed except according to |
| 7 |
those terms. --> |
| 8 |
|
| 9 |
# UI & Output Tests |
| 10 |
|
| 11 |
When updating UI test files (`tests/ui-*` or `zerocopy-derive/tests/ui-*`) or |
| 12 |
functionality which could affect compiler error output or derive output, run: |
| 13 |
`../tools/update-expected-test-output.sh`. |
| 14 |
|
| 15 |
**Note:** We maintain separate UI tests for different toolchains (`ui-msrv`, |
| 16 |
`ui-stable`, `ui-nightly`) because compiler output varies. The script handles |
| 17 |
this automatically. |
| 18 |
|
| 19 |
### Symlink Pattern |
| 20 |
|
| 21 |
To share test code across toolchains while allowing for different error output, |
| 22 |
we use a symlink pattern: |
| 23 |
|
| 24 |
1. **Canonical Source:** The `ui-nightly` directory holds the actual source |
| 25 |
files (`.rs`). |
| 26 |
2. **Symlinks:** The `ui-stable` and `ui-msrv` directories contain *symlinks* |
| 27 |
to the `.rs` files in `ui-nightly`. |
| 28 |
- **Example:** `tests/ui-stable/foo.rs` -> `../ui-nightly/foo.rs` |
| 29 |
3. **Unique Output:** Each directory contains its own `.stderr` files. |
| 30 |
|
| 31 |
### Workflow Rules |
| 32 |
|
| 33 |
- **Adding a Test:** |
| 34 |
1. Create the `.rs` file in `ui-nightly`. |
| 35 |
2. Create relative symlinks in `ui-stable` and `ui-msrv` pointing to the |
| 36 |
new file in `ui-nightly`. |
| 37 |
3. Run `../tools/update-expected-test-output.sh` to generate the `.stderr` files. |
| 38 |
- **Modifying a Test:** |
| 39 |
1. Edit the `.rs` file in `ui-nightly`. |
| 40 |
2. Run `../tools/update-expected-test-output.sh` to update the `.stderr` files. |
| 41 |
- **Removing a Test:** |
| 42 |
1. Delete the `.rs` file from `ui-nightly`. |
| 43 |
2. Delete the symlinks from `ui-stable` and `ui-msrv`. |
| 44 |
3. Delete the corresponding `.stderr` files from all three directories. |
| 45 |
|
| 46 |
**NEVER** edit `.stderr` files directly. Only update them via the script or the |
| 47 |
commands it runs. If a `.stderr` file is causing a test failure and updating it |
| 48 |
via tooling does not fix the failure, that indicates a bug. |