Skip to content

Support Bazel TEST_PREMATURE_EXIT_FILE #3020

Closed

Description

@mattyclarkson

Description

When running bazel test it creates the TEST_PREMATURE_EXIT_FILE which contains an absolute path to a file in a writable directory.

If a test binary creates that file, then removes it on a successful exit it allows the test runner to understand when a test binary has been aggressively aborted.

Additional Context

In order to catch early exit, a test may create a file at the path specified by TEST_PREMATURE_EXIT_FILE upon start and remove it upon exit. If Bazel sees the file when the test finishes, it will assume that the test exited prematurely and mark it as having failed.

Bazel test encyclopedia

Activity

  1. added
    Good First Issue
    on Aug 21, 2025
  2. horenmar commented on Aug 21, 2025

    @horenmar
    Member

    The target path will be limited to target an existing directory. Creating and removing an empty file is easy-enough in C++14, but messing around with directories needs C++17's filesystem.

  3. added a commit that references this issue on Sep 22, 2025
    8ed8c43
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

    Feature RequestGood First Issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions