Skip to content

binaries built by cargo test can be different from those built with cargo build #11954

Open
@silence-coding

Description

@silence-coding

Problem

When the cargo test is executed, the binary built by the cargo build is overwritten as the result of the cargo test build.

test-build.zip

├── Cargo.lock
├── Cargo.toml
└── test-bin
    ├── Cargo.toml
    ├── src
    │   ├── lib.rs
    │   └── main.rs
    └── tests
        └── xxx_test.rs

image

Steps

  1. cargo test
  2. cargo uild
  3. cargo test

Binaries will be overwritten constantly.

Possible Solution(s)

The cargo test should not modify the bin, but only the compiled test bin.

Notes

No response

Version

cargo 1.68.0 (115f34552 2023-02-26)
release: 1.68.0
commit-hash: 115f34552518a2f9b96d740192addbac1271e7e6
commit-date: 2023-02-26
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Linux [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-featuresArea: features — conditional compilationA-workspacesArea: workspacesC-bugCategory: bugS-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions