Skip to content

Conversation

Zalathar
Copy link
Contributor

One of the very silly things about directive processing in compiletest is that for each directive in the test file, we proceed to check it against dozens of different directive names in linear sequence, without any kind of indexed lookup, and without any early-exit after a known directive name is found (unless a panic occurs).

This PR is a big step away from that, by taking the iter_directives loop in TestProps::load_from and making all of its directive processing dispatch to a hashtable of individual name-specific handlers instead.


The handler system is set up in a way that should allow us to add capabilities or change the implementation as needed, without having to mass-modify the existing handlers (e.g. this is why the handler and multi_handler functions are used).


This PR is focused on mass-migrating all of the TestProps directive processing into handlers. Most of the resulting handlers could obviously be simplified further (e.g. by avoiding the redundant name checks that were needed in the pre-migration code), but I've avoided doing any such simplifications in this PR to keep its scope limited and make reviewing easier.

The patches in this PR have been arranged so that the main migration can be inspected with git diff --color-moved --color-moved-ws=ignore-all-space to verify that it moves all of the relevant lines intact, without modifying or discarding any of them.

r? jieyouxu

This step consists of two changes:

- Renaming `self` to `props`
- Inserting temporary comments to preserve line breaks

This will make it easier to verify that the main migration commit preserves all
of the lines being migrated.
Use `git diff --color-moved --color-moved-ws=ignore-all-space` (or similar) to
verify that the directive-processing lines have been moved without changes.
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

Some changes occurred in src/tools/compiletest

cc @jieyouxu

compiletest directives have been modified. Please add or update docs for the
new or modified directive in src/doc/rustc-dev-guide/.

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc labels Oct 22, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 22, 2025
@Zalathar
Copy link
Contributor Author

Running a bunch of try jobs to check for unforeseen problems:

@bors try jobs=x86_64-msvc-1,i686-msvc-1,x86_64-mingw-1,test-various,armhf-gnu,aarch64-apple,dist-i586-gnu-i586-i686-musl

rust-bors bot added a commit that referenced this pull request Oct 22, 2025
compiletest: Migrate `TestProps` directive handling to a system of named handlers

try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
try-job: test-various
try-job: armhf-gnu
try-job: aarch64-apple
try-job: dist-i586-gnu-i586-i686-musl
@rust-bors

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Oct 22, 2025

☀️ Try build successful (CI)
Build commit: dd79bb4 (dd79bb4ea51e0e37cea8fc6fdaef3a0586643b34, parent: 37ec98f5d33c0876a9ffa5ee17dc0895659efe37)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants