Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Gazelle with python_generation_mode project can generate duplicate py_test targets #1442

Copy link
Copy link
Closed
@RJPercival

Description

@RJPercival
Issue body actions

🐞 bug report

Affected Rule

The issue is caused by the rule: py_test

Is this a regression?

Unknown

Description

When using # gazelle:python_generation_mode project, the Python Gazelle plugin still generates one py_test target per file, but puts them all in the BUILD file that has the python_generation_mode directive in it. This can result in duplicate target names if two test files have the same filename (but are in different subdirectories), as the subdirectory path is not incorporated into the target names.

When using python_generation_mode project, I would expect a single py_test target for all of the tests across all of the subdirectories, just as with py_library.

🔬 Minimal Reproduction

BUILD file:

# gazelle:python_generation_mode project

<usual gazelle targets here>
$ echo "# gazelle:python_generation_mode project" > BUILD.bazel
$ mkdir bar
$ touch bar/test_foo.py
$ mkdir baz
$ touch baz/test_foo.py
$ bazel run //:gazelle
gazelle: multiple rules found with label @test//:test_foo

🌍 Your Environment

Operating System:

  
macOS Sonoma
  

Output of bazel version:

  
bazel 6.3.2
  

Rules_python version:

  
0.25.0
  

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.