Skip to content

Add support for generating layout tests in a different file - #3493

Open
DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:separate-layout-tests
Open

DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:separate-layout-tests

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Contributor

Add a new command line flag, --separate-layout-tests-path, and a new builder method, separate_layout_tests_path(), to set the path for layout tests. Unlike when wrapping static functions, an explicit path is required for the layout tests to be put in a different file, with no fallback to a temporary file. Separate layout tests are expected to be useful in projects where the bindings are included in version control, in which case the include! of the generated file would break if that file wasn't also present.

Fixes #1655

Add a new command line flag, `--separate-layout-tests-path`, and a new builder
method, `separate_layout_tests_path()`, to set the path for layout tests.
Unlike when wrapping static functions, an explicit path is required for the
layout tests to be put in a different file, with no fallback to a temporary
file. Separate layout tests are expected to be useful in projects where the
bindings are included in version control, in which case the `include!` of the
generated file would break if that file wasn't also present.

Fixes rust-lang#1655

@emilio emilio left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused about the goal here. If you want to check in the bindings into source control, you do need to avoid layout tests anyway because those are fundamentally target specific, right?

To be honest, the bindings are likely target specific in practice too (due to padding etc that it might add, but...).

Is the idea that you'd run bindgen once with the layout tests somewhere else then don't check-in the layout tests? Or... something else?

View changes since this review

@DanielEScherzer

Copy link
Copy Markdown
Contributor Author

I'm a bit confused about the goal here. If you want to check in the bindings into source control, you do need to avoid layout tests anyway because those are fundamentally target specific, right?

To be honest, the bindings are likely target specific in practice too (due to padding etc that it might add, but...).

Is the idea that you'd run bindgen once with the layout tests somewhere else then don't check-in the layout tests? Or... something else?

My goal was to make changes to the bindings in the source control easier to read by not filling the diff with changes to the layout tests, they can still be checked in

@rustbot

rustbot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #3519) made this pull request unmergeable. Please resolve the merge conflicts.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to generate layout tests in a different file.

3 participants