Skip to content

Support panic=abort without #[should_panic] from libtest #62318

Closed

Description

@tmandry

When a project wants to turn on panic=abort today, they are forced to choose between

  1. Re-compiling their whole project with panic=unwind for the purpose of running tests (this not only creates longer build times, but also changes the behavior of code between testing and production)
  2. Using a custom test harness (either ad-hoc which requries changes the source code for tests, or by using custom_test_harness which is unstable)

Neither of these solutions are great. One solution that might be palatable is to support compiling panic=abort from libtest, but not support #[should_panic] tests in this mode. This could be advertised with an explicit error message anytime a test with #[should_panic] is run. Later, these could be supported as "death tests" as discussed in #32512.

In Fuchsia we'd really like to switch to panic=abort, and this is the main thing preventing us from doing so.

cc @cramertj @petrhosek

Activity

  1. added
    A-libtestArea: `#[test]` / the `test` library
    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
    T-libs-api[DEPRECATED; DO NOT USE]
    on Jul 2, 2019
  2. added
    T-langRelevant to the language team
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Jul 3, 2019
  3. cramertj commented on Jul 4, 2019

    @cramertj
    Member

    @Centril IMO this is something of a libs question since it interacts with the behavior of libtest and custom test harnesses.

  4. Centril commented on Jul 5, 2019

    @Centril
    Contributor

    @cramertj libtest seems primarily under under T-dev-tools right now and #[should_panic] is an attribute known by the language (hence T-lang), and it is documented as such in the reference. Custom test frameworks are also not a libs team issue as far as I know.

  5. added
    T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
    on Jul 5, 2019
  6. gnzlbg commented on Aug 17, 2019

    @gnzlbg
    Contributor

    We already have custom test frameworks that run each test in a single process (e.g. this one but it is easy to write your own), and those solve more problems than the alternative approaches discussed here (e.g. they trivially support #![should_panic] test for panic=abort which are essentially death tests).

    The only downside I see mentioned for this approach is that custom_test_frameworks are unstable. It might be better to work towards stabilizing these instead of making libtest more complicated to partially-support panic=abort, but not quite.

    Custom test frameworks is one of those things that has been started, is almost there, but not quite yet, and finishing those things is part of this years roadmap.

  7. tmandry commented on Aug 26, 2019

    @tmandry
    MemberAuthor

    Agreed that partial support isn't really the way to go. I'm working on fully supporting panic=abort from libtest (see #32512 (comment)).

    I also think stabilizing custom test frameworks would be nice, but I think panic=abort should be fully supported without one.

  8. tmandry commented on Aug 14, 2020

    @tmandry
    MemberAuthor

    This was originally added in #64158 and Cargo support landed in rust-lang/cargo#7460.

    #67650 tracks the unstable feature.

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

    A-libtestArea: `#[test]` / the `test` libraryC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions