Skip to content

[test] features: the features a package's own tests are built with #941

Closed

Description

@Sunrisepeak

What is needed. A manifest key naming the features a package's own tests are built with, e.g.

[features]
ktx2 = { sources = ["src/ktx2/*.cppm", "src/ktx2/native/*.cpp"] }

[feature-deps.ktx2]
mcpplibs.mwrap.basis_universal = "2.50.1"

[test]
features = ["ktx2"]   # tests/ is built with these on (in addition to the defaults)

Why. mcpp test --workspace builds each member's tests with its default features, and --features applies to one invocation. So a part of a library behind a non-default feature can only be tested in one of two ways today:

  1. make the feature a default — then every consumer compiles (and depends on) it unless each writes default-features = false; or
  2. keep the part in a package of its own, whose tests are its tests.

A workspace that wants few packages (one per library or product, its optional parts as features: a decoder needing a large third-party library, a window front end of a game whose core must not link the UI) ends up with option 2 everywhere, purely so the tests run. In our workspace (179 members) this decides a good share of the package count.

Expected behaviour. [test] features adds those features to the package's own test build (its tests/ programs and the library they link), in mcpp test -p X and in mcpp test --workspace; consumers of the package are unaffected (they still get its defaults or what they ask for). A feature listed that the package does not declare is refused at load, as --features refuses it.

Related: required_features on targets (docs/04 §2.2), which already lets a program depend on a feature; this is the same for the test programs.

Activity

  1. speak-agent commented on Nov 16, 2026

    @speak-agent
    Member

    Implemented in mcpp 2026.11.16.1 (#940): [test] features names declared features that test builds activate; an undeclared name is refused. See docs/08-testing.md.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions