Skip to content

ctest: add support for modules - #5459

Draft
dybucc wants to merge 7 commits into
rust-lang:mainfrom
dybucc:feature/ctest-specific-modules
Draft

ctest: add support for modules#5459
dybucc wants to merge 7 commits into
rust-lang:mainfrom
dybucc:feature/ctest-specific-modules

Conversation

@dybucc

@dybucc dybucc commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

Add support for (currently) parsing and filtering Rust modules found in
the target crate to test. This is supposed to provide scaffolding for
multiple open feature requests that depend on ctest having support for
modules.

I decided to open this before finishing up work on generating proper
tests on both C and Rust sides, because I am not sure if I should just
let the user deal with including a cohesive set of modules that do not
cause item resolution conflicts, or if I should instead generate
separate tests for each parsed module.

Edit: the above paragraph really goes to say that I am not sure
whether I should generate multiple test templates while recursing
through the modules in TestGenerator::generate_files, or if I should
instead recurse through them in TestTemplate::new (with the passed
FfiItems) and return a collection of test templates for each parsed
module that has not been skipped.

cc @tgross35 @mbyx

Update

I have changed the way we parse item identifiers, and more specifically,
their absolute paths without crate at the start (e.g.
foo::bar::ctime() instead of crate::foo::bar::ctime().)

This should make filtering continue working as-is right now for items,
but allow filtering on items in nested submodules by using an
appropriate string matching something like the above example.

Checklist

  • Relevant tests in ctest/tests and ctest/src/tests.rs have been
    updated
  • Tested locally (LIBC_BLESS=1 cargo test -p ctest);

@rustbot label +stable-nominated

@rustbot rustbot added ctest Issues relating to the ctest crate stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Sep 3, 2026
@dybucc
dybucc force-pushed the feature/ctest-specific-modules branch 8 times, most recently from a848a8c to 1e19045 Compare September 4, 2026 13:55
Add support for parsing modules in the input Rust crate to `ctest`. This
should allow more easily implementing support for a number of recent
feature additions that have been needed in `libc`.
Add support in `TranslationHelper` to filter out modules based off of a
new type of skip accepted in `TestGenerator`'s public API. Filtering
containing items is done by filtering on stringified paths (e.g.
`foo::bar` to skip function `bar` inside top-level module `crate::foo`.)
@dybucc
dybucc force-pushed the feature/ctest-specific-modules branch from 060d0cc to 2e69844 Compare September 5, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ctest Issues relating to the ctest crate stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants