Skip to content

Clarify the rustpkg testing story #9003

Closed
@catamorphism

Description

On IRC, @bjz and @Kimundi pointed out some infelicities with how rustpkg handles the test crate.

kimundi writes: "I think there are 3 ways to have the test suite of a rustpkg package work: in-crate by compiling the crate with rustc --test, out-of-crate by having a test.rs file that 'extern mod's the crate, and hybrid where you have a test.rs file that contains all modules of your crate with 'mod ...;' statements, effectively providing an alternate test crate-root."

Currently, rustpkg is designed to give preference to the last option: having a test.rs file that is an alternative crate root for building a test executable.

So one question is whether to support all 3 ways with equally good ergonomics in rustpkg. The other question is whether to choose one way that we prefer, and document that that is the preferred method.

kimundi pointing out that the pros and cons of each approach are:

"in-crate: pro: quick and easy, can test private things. cons: clutters the code, change to tests mean recompile the library itself

out-of-crate: pro: can test the public api extensivly, no cluttering the crate code itself, changes to testsuite do not cause the crate to need recompiling. cons: can't test private items, need to do more work to test the public api

hybrid: pro: can test private api, separate test crate from regular crate, can test public api separately without needing to recompile crate. cons: needs to compile the same amount of code as the crate, needs to duplicate crate root."

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