Skip to content

Improve detection of executable and test targets #544

@Silic0nS0ldier

Description

@Silic0nS0ldier

The extension currently has it's own logic to determine if tests are executable and/or testable;

  • Targets defined with a rule named test_suite are considered testable (can technically be incorrect if a rule with the same name is used, but very unlikely).
  • Targets with a _test suffix are considered testable (this matches Bazel's documented behaviour, although in practise names like test and ActionTest are also allowed).
  • All targets are considered executable, which is incorrect most of the time.

This results in invalid actions being advertised in codelens, etc.

An improvement can be made today using the query filter functions tests(...) (long available) and executables(...) (9.0.0 and 8.5.0) allow us to use Bazel's own definition of what is testable and executable.

However it is not currently possible to output multiple result sets from queries, so multiple queries would be required (3, up from 1). This has a non-negliable performance impact, especially in big workspaces.

To address the performance needs, I'm adding test and executable to the proto output in bazelbuild/bazel#27955. This approach should also simplify backward compatibility (no query change necessary, just falling back to inference when Bazel version is too low).

Metadata

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