diff options
| author | bors <bors@rust-lang.org> | 2024-02-16 21:00:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-16 21:00:48 +0000 |
| commit | bccb9bbb418a30aeb332052e721beb6ebc6b1ce7 (patch) | |
| tree | 1babe5fef21a13be5c23970c68b656cee552b1f1 /tests/ui/pattern/move-ref-patterns | |
| parent | 93a65c69ce60cb7b619eb1853866dff62f446e2b (diff) | |
| parent | ec2cc761bc7067712ecc7734502f703fe3b024c8 (diff) | |
| download | rust-bccb9bbb418a30aeb332052e721beb6ebc6b1ce7.tar.gz rust-bccb9bbb418a30aeb332052e721beb6ebc6b1ce7.zip | |
Auto merge of #120881 - jieyouxu:migrate-ui-test-directives, r=oli-obk
Migrate ui tests from legacy compiletest-style directives `//` to `ui_test`-style directives `//@`
## Preface
There's an on-going effort to rewrite parts of or the entirety of compiletest
(<https://github.com/rust-lang/compiler-team/issues/536>). A step towards this involve migrating
ui tests to use the [`ui_test`](https://github.com/oli-obk/ui_test) framework, which involves
changing compiletest directives in `// <directive-name>` style to `ui_test` `//@ <directive-name>`
style (https://github.com/rust-lang/compiler-team/issues/512).
This PR aims to implement the directive-style change from `//` to `//`@`` for ui tests only and
make compiletest only accept `//`@`` directives in the "ui" test suite (only).
## Key Changes
1. All ui test `//` directives are replaced by `//`@`` directives.
2. Only accept `//`@`` directives for "ui" test suite.
3. Errors if a comment could be interpreted as a legacy-style `//` directive.
## Diff Generation
The diff is generated by:
- Collecting directives from ui tests via hacking on compiletest.
- Using a migration tool to replace `//` directives in ui tests with `//`@`.`
### Reproduction Steps
0. Delete the temporary directory `$RUSTC_REPO_PATH/build/x86_64-apple-darwin/test/ui/__directive_lines` and the temporary file `$RUSTC_REPO_PATH/build/x86_64-apple-darwin/test/ui/__directive_lines.txt` (if you ran the collection script before).
1. Use the <https://github.com/jieyouxu/rust/tree/collect-test-directives> collect-test-directives
script, which outputs temporary files recording headers occuring in each ui test.
- You need to checkout this branch: `git checkout collect-test-directives`.
- You might need to rebase on lastest master and ensure there are no conflicts.
- You likely need to run `./x test tests/ui --stage 1 --force-rerun` to generate the temporary
files consistently.
2. Checkout the `migrate-ui-test-directives` branch.
4. Run the migration tool <https://github.com/jieyouxu/compiletest-ui_test-header-migration>.
- You will need to first generate a `migration_config.toml` via `cargo run -- generate-config` under `$CWD`.
- Then, update `manual_directives = ["// should-fail"]` in `migration_config.toml`. This is required because the collection script doesn't deal with some special meta ui tests and there are no other `// should-fail` occurrences.
5. Check that the migration at least does not cause UI test failures if you change compiletest to
accept `//`@`` directives for ui tests only.
- `RUSTC_TEST_FAIL_FAST=1 ./x test tests/ui --stage 1 --bless`
6. Confirm that there is no difference after running the migration tool when you are on the
`migrate-ui-test-directives` branch.
## Next Steps
- [x] ~~Need to implement some kind of warning or tidy script to help contributors catch old-style
`// <directive-name>` directives, while only accepting `ui_test`-style `//@ <directive-name>`
directives.~~ An error is emitted if a comment that could be interpreted as legacy-style test directive is encountered.
- [ ] Need to properly document this change in e.g. rustc-dev-guide (https://github.com/rust-lang/rustc-dev-guide/pull/1885).
- [x] Add a `README.md` to `tests/ui` describing the directive style change.
Diffstat (limited to 'tests/ui/pattern/move-ref-patterns')
7 files changed, 7 insertions, 7 deletions
diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs index 204cd3e6657..72674eb40ff 100644 --- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs +++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs @@ -1,4 +1,4 @@ -// check-pass +//@ check-pass #![allow(dropping_references)] diff --git a/tests/ui/pattern/move-ref-patterns/by-move-sub-pat-unreachable.rs b/tests/ui/pattern/move-ref-patterns/by-move-sub-pat-unreachable.rs index ff7b625a68e..b229480971d 100644 --- a/tests/ui/pattern/move-ref-patterns/by-move-sub-pat-unreachable.rs +++ b/tests/ui/pattern/move-ref-patterns/by-move-sub-pat-unreachable.rs @@ -2,7 +2,7 @@ // happen and that code is unreachable according to borrowck, we accept this code. // In particular, we want to ensure here that an ICE does not happen, which it did originally. -// check-pass +//@ check-pass fn main() { return; diff --git a/tests/ui/pattern/move-ref-patterns/issue-53840.rs b/tests/ui/pattern/move-ref-patterns/issue-53840.rs index 80effc497ed..64b6e8f2dca 100644 --- a/tests/ui/pattern/move-ref-patterns/issue-53840.rs +++ b/tests/ui/pattern/move-ref-patterns/issue-53840.rs @@ -1,4 +1,4 @@ -// check-pass +//@ check-pass enum E { Foo(String, String, String), diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs index 4de1f653db0..875fe9dba89 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs @@ -1,4 +1,4 @@ -// check-pass +//@ check-pass #![allow(dropping_references)] diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed index 5f04fc83d37..2a0649ba478 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@ run-rustfix #![allow(unused_variables)] fn main() { struct U; diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs index 5dc1ae2feb5..1bb6d8e15e1 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-default-binding-modes-fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@ run-rustfix #![allow(unused_variables)] fn main() { struct U; diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs index 1d6d9acead1..62d31f54f84 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-dynamic-semantics.rs @@ -1,4 +1,4 @@ -// run-pass +//@ run-pass // This test checks the dynamic semantics and drop order of pattern matching // where a product pattern has both a by-move and by-ref binding. |
