Skip to content

[test] by target: a package's test programs selected by cfg, as sources are #942

Closed

Description

@Sunrisepeak

What

A package's test programs cannot be selected by target. [target.'cfg(...)'.build] sources gates library sources per target, but every file under tests/ is built and run on every target the package builds for.

Why it matters

A package that runs on the Web (platforms lists emscripten) cannot hold a test that needs a native-only dev-dependency (an SDL window host, a GPU backend on SDL_GPU, a native muxer). The only way today is a second package beside it, native only, holding those tests and programs. In one workspace (177 packages) this accounts for a good share of the packages that exist only for that reason, for example:

  • a game whose rules and headless runtime run on the Web, and whose window test needs the native headless host: two packages;
  • a simulation kernel, its suite and presenter (Web), and the same suite run on SDL_GPU (native): a 29-line package of its own;
  • a library on the Web whose native tool is a separate package.

Asked

Test programs selectable by target, the way sources are, for example:

[target.'cfg(not(os = "emscripten"))'.test]
programs = ["tests/native/*.cpp"]

[target.'cfg(not(os = "emscripten"))'.dev-dependencies]
omui.host.headless = { path = "../host/headless" }

(target-specific dev-dependencies may already work; the missing half is the test files). Together with #941 ([test] features), this lets a package hold its own tests for each target and feature set instead of one package per combination.

Activity

  1. speak-agent commented on Nov 16, 2026

    @speak-agent
    Member

    Implemented in mcpp 2026.11.16.1 (#940): [target.'<cfg>'.test] discover adds test programs per target, with the same ! semantics as [test] discover. 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