about summary refs log tree commit diff
path: root/tests/incremental/thinlto
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-22 16:39:09 +0000
committerbors <bors@rust-lang.org>2024-02-22 16:39:09 +0000
commitf62f490fd410c06031a57915b4e5580ccbd7a30f (patch)
treed070b9f4ba33bd10d028044860c87705806e6f77 /tests/incremental/thinlto
parent933a05bd0ba91caf219222e5f61d1c92d141ff61 (diff)
parentcd25009469926abec4b1104396ef99026a6b9b9c (diff)
downloadrust-f62f490fd410c06031a57915b4e5580ccbd7a30f.tar.gz
rust-f62f490fd410c06031a57915b4e5580ccbd7a30f.zip
Auto merge of #121370 - jieyouxu:migrate-compiletest-directives, r=oli-obk
Migrate compiletest to use `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
compiletest 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 the remaining
non-"ui" test suite tests.

## Key Changes

1. All `tests/` tests now use `//`@`` directives.
2. Compiletest only accepts `//`@`` and issues an error if an old-style directive is detected.
3. `// ignore-tidy` and `// ignore-tidy-*` are considered tidy directives and are ignored by
   compiletest header parsing.

## Diff Generation

The diff is generated by:

- Collecting directives from `tests/` via hijacking compiletest to emit successfully parsed
  directive lines.
- Using a migration tool
  (<https://github.com/jieyouxu/compiletest-ui_test-header-migration/tree/master>) to replace
  `//` directives in compiletest tests with `//`@`.`

### Reproduction Steps

0. Delete the temporary file `$RUSTC_REPO_PATH/build/<target_triple>/test/__directive_lines.txt`,
   if the collection script was previously ran.
1. Use the <https://github.com/jieyouxu/rust/tree/collect-test-directives> collect-test-directives
   script, which outputs a temporary file recording headers occuring in each compiletest test.
   - You need to checkout this branch: `git checkout collect-test-directives`.
   - This needs to be rebased on latest master to ensure up-to-date test directives can be collected.
   - You need to run `./x test` on each of the `test/*` subfolders once:

        ```bash
        ./x test tests/assembly/ --stage 1 --force-rerun
        ./x test tests/codegen/ --stage 1 --force-rerun
        ./x test tests/codegen-units/ --stage 1 --force-rerun
        ./x test tests/coverage/ --stage 1 --force-rerun
        ./x test tests/coverage-run-rustdoc/ --stage 1 --force-rerun
        ./x test tests/debuginfo/ --stage 1 --force-rerun
        ./x test tests/incremental/ --stage 1 --force-rerun
        ./x test tests/mir-opt/ --stage 1 --force-rerun
        ./x test tests/pretty/ --stage 1 --force-rerun
        ./x test tests/run-make/ --stage 1 --force-rerun
        ./x test tests/run-make-fulldeps/ --stage 1 --force-rerun
        ./x test tests/run-pass-valgrind/ --stage 1 --force-rerun
        ./x test tests/rustdoc/ --stage 1 --force-rerun
        TARGET=<target-triple> ./x test tests/rustdoc-gui/ --stage 1 --force-rerun
        ./x test tests/rustdoc-js/ --stage 1 --force-rerun
        ./x test tests/rustdoc-js-std/ --stage 1 --force-rerun
        ./x test tests/rustdoc-json/ --stage 1 --force-rerun
        ./x test tests/rustdoc-ui/ --stage 1 --force-rerun
        ./x test tests/ui/ --stage 1 --force-rerun
        ./x test tests/ui-fulldeps/ --stage 1 --force-rerun
        ```

2. Checkout the `migrate-compiletest-directives` branch.
3. Run the migration tool <https://github.com/jieyouxu/compiletest-ui_test-header-migration>.
4. Check that the migration at least does not cause test failures if you change compiletest to
   accept `//`@`` directives only. This is also required if the test outputs somehow need to be
   blessed.
   - `RUSTC_TEST_FAIL_FAST=1 ./x test tests/<secondary-directory>  --stage 1 --bless`
5. Confirm that there is no difference after running the migration tool when you are on the
   `migrate-compiletest-directives` branch.

## Follow Up Work

- [ ] Adjust rustc-dev-guide docs for compiletest directives (this time for all the other suites and modes). <https://github.com/rust-lang/rustc-dev-guide/pull/1895>.
Diffstat (limited to 'tests/incremental/thinlto')
-rw-r--r--tests/incremental/thinlto/cgu_invalidated_via_import.rs6
-rw-r--r--tests/incremental/thinlto/cgu_invalidated_when_export_added.rs4
-rw-r--r--tests/incremental/thinlto/cgu_invalidated_when_export_removed.rs4
-rw-r--r--tests/incremental/thinlto/cgu_invalidated_when_import_added.rs6
-rw-r--r--tests/incremental/thinlto/cgu_invalidated_when_import_removed.rs6
-rw-r--r--tests/incremental/thinlto/cgu_keeps_identical_fn.rs6
-rw-r--r--tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs6
7 files changed, 19 insertions, 19 deletions
diff --git a/tests/incremental/thinlto/cgu_invalidated_via_import.rs b/tests/incremental/thinlto/cgu_invalidated_via_import.rs
index a81b4f7e9d0..04a5a06384a 100644
--- a/tests/incremental/thinlto/cgu_invalidated_via_import.rs
+++ b/tests/incremental/thinlto/cgu_invalidated_via_import.rs
@@ -2,9 +2,9 @@
 // via ThinLTO and that imported thing changes while the definition of the CGU
 // stays untouched.
 
-// revisions: cfail1 cfail2 cfail3
-// compile-flags: -Z query-dep-graph -O
-// build-pass
+//@ revisions: cfail1 cfail2 cfail3
+//@ compile-flags: -Z query-dep-graph -O
+//@ build-pass
 
 #![feature(rustc_attrs)]
 #![crate_type="rlib"]
diff --git a/tests/incremental/thinlto/cgu_invalidated_when_export_added.rs b/tests/incremental/thinlto/cgu_invalidated_when_export_added.rs
index 95f3b8ae4d9..a9b05467bf6 100644
--- a/tests/incremental/thinlto/cgu_invalidated_when_export_added.rs
+++ b/tests/incremental/thinlto/cgu_invalidated_when_export_added.rs
@@ -1,5 +1,5 @@
-// revisions: cfail1 cfail2
-// build-pass
+//@ revisions: cfail1 cfail2
+//@ build-pass
 
 // rust-lang/rust#69798:
 //
diff --git a/tests/incremental/thinlto/cgu_invalidated_when_export_removed.rs b/tests/incremental/thinlto/cgu_invalidated_when_export_removed.rs
index e86ebd354b1..3a78a290c7b 100644
--- a/tests/incremental/thinlto/cgu_invalidated_when_export_removed.rs
+++ b/tests/incremental/thinlto/cgu_invalidated_when_export_removed.rs
@@ -1,5 +1,5 @@
-// revisions: cfail1 cfail2
-// build-pass
+//@ revisions: cfail1 cfail2
+//@ build-pass
 
 // rust-lang/rust#69798:
 //
diff --git a/tests/incremental/thinlto/cgu_invalidated_when_import_added.rs b/tests/incremental/thinlto/cgu_invalidated_when_import_added.rs
index 9c17c8745f8..4198c6c273b 100644
--- a/tests/incremental/thinlto/cgu_invalidated_when_import_added.rs
+++ b/tests/incremental/thinlto/cgu_invalidated_when_import_added.rs
@@ -1,6 +1,6 @@
-// revisions: cfail1 cfail2
-// compile-flags: -O -Zhuman-readable-cgu-names -Cllvm-args=-import-instr-limit=10
-// build-pass
+//@ revisions: cfail1 cfail2
+//@ compile-flags: -O -Zhuman-readable-cgu-names -Cllvm-args=-import-instr-limit=10
+//@ build-pass
 
 // rust-lang/rust#59535:
 //
diff --git a/tests/incremental/thinlto/cgu_invalidated_when_import_removed.rs b/tests/incremental/thinlto/cgu_invalidated_when_import_removed.rs
index fc53acf75cb..4880d376fcc 100644
--- a/tests/incremental/thinlto/cgu_invalidated_when_import_removed.rs
+++ b/tests/incremental/thinlto/cgu_invalidated_when_import_removed.rs
@@ -1,6 +1,6 @@
-// revisions: cfail1 cfail2
-// compile-flags: -O -Zhuman-readable-cgu-names -Cllvm-args=-import-instr-limit=10
-// build-pass
+//@ revisions: cfail1 cfail2
+//@ compile-flags: -O -Zhuman-readable-cgu-names -Cllvm-args=-import-instr-limit=10
+//@ build-pass
 
 // rust-lang/rust#59535:
 //
diff --git a/tests/incremental/thinlto/cgu_keeps_identical_fn.rs b/tests/incremental/thinlto/cgu_keeps_identical_fn.rs
index 9e840f67ab2..5751759223b 100644
--- a/tests/incremental/thinlto/cgu_keeps_identical_fn.rs
+++ b/tests/incremental/thinlto/cgu_keeps_identical_fn.rs
@@ -3,9 +3,9 @@
 // ends up with any spans in its LLVM bitecode, so LLVM is able to skip
 // re-building any modules which import 'inlined_fn'
 
-// revisions: cfail1 cfail2 cfail3
-// compile-flags: -Z query-dep-graph -O
-// build-pass
+//@ revisions: cfail1 cfail2 cfail3
+//@ compile-flags: -Z query-dep-graph -O
+//@ build-pass
 
 #![feature(rustc_attrs)]
 #![crate_type = "rlib"]
diff --git a/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs b/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
index 45eb1382874..e05508fa8e3 100644
--- a/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
+++ b/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
@@ -1,9 +1,9 @@
 // This test checks that a change in a CGU does not invalidate an unrelated CGU
 // during incremental ThinLTO.
 
-// revisions: cfail1 cfail2 cfail3
-// compile-flags: -Z query-dep-graph -O
-// build-pass
+//@ revisions: cfail1 cfail2 cfail3
+//@ compile-flags: -Z query-dep-graph -O
+//@ build-pass
 
 #![feature(rustc_attrs)]
 #![crate_type="rlib"]