Skip to content

cargo test without cargo build won't create target/debug/libfoo.rlib while cargo build does #6131

Closed as not planned
@LukasKalbertodt

Description

@LukasKalbertodt

I always expect that cargo test basically runs a cargo build before doing anything test specific. But that's apparently not the case.


Minimal example:

Cargo.toml

[package]
name = "foo"
version = "0.1.0"
authors = ["me"]
edition = "2018"

src/lib.rs

pub fn foo() {}

tests/main.rs

use foo::foo;

#[test]
fn main() {
    foo();
}

Executing cargo test will compile the foo crate and execute tests. Fine. BUT: cargo clean && cargo test won't create the file target/debug/libfoo.rlib while cargo clean && cargo build does create that file. This is very unexpected.

Tests on rustc 1.31.0-nightly (5597ee8a6 2018-10-03)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: target output directory layout, naming, and organizationCommand-testS-propose-closeStatus: A team member has nominated this for closing, pending further input from the team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions