Skip to content

A test-directory program named as the package's own bin target is written over that program ([test] programs = "directory") #1028

Backlog

Description

@speak-agent

mcpp 2026.11.26.1, Linux x64 (GCC 16.1).

A package whose bin target and whose test directory have the same name gets one output path for two different programs. Whichever of mcpp build and mcpp test ran last decides what the file is; nothing is diagnosed.

Reproduce

# mcpp.toml
[package]
name    = "collide"
version = "0.1.0"

[targets.collide]
kind = "bin"
main = "src/main.cpp"

[dev-dependencies]
mcpplibs.mtest = "*"

[test]
programs = "directory"

src/main.cpp prints the program; tests/collide/one_test.cpp holds one mtest case.

$ mcpp build && target/x86_64-linux-gnu/<hash>/bin/collide
the program
$ mcpp test            # 1 passed
$ target/x86_64-linux-gnu/<hash>/bin/collide
  ok   collide.one/one # the file is now the test program
$ mcpp build           # relinks (0.67 s) — the program again

Why it matters

  • Anything that finds a built program by its path (a build rule's tool, a benchmark harness, a packaging step, CI's "build, test, then run the binary") runs the test program after mcpp test, with no error — here a timing harness measured the mtest runner printing no such case in 0 ms instead of the tool.
  • mcpp build after mcpp test (and the reverse) relinks every time, so the two commands never both find their output current.

The natural layout produces it: a tool package x with the program x and tests/x/ (two packages of one workspace here had it).

Expected

Either the two outputs do not share a path (test programs under their own directory or with a suffix, as file-per-program tests have _test), or planning refuses the manifest and names both targets.

Activity

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