Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[internal] tailor doesn't add go_package for testdata folder #13783

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/python/pants/backend/go/goals/tailor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import re
from dataclasses import dataclass
from pathlib import PurePath

from pants.backend.go.target_types import (
GoBinaryMainPackage,
Expand Down Expand Up @@ -69,11 +70,14 @@ async def find_putative_go_targets(
# Add `go_package` targets.
unowned_go_files = set(all_go_files.files) - set(all_owned_sources)
for dirname, filenames in group_by_dir(unowned_go_files).items():
dir_path = PurePath(dirname)
if "testdata" in dir_path.parts:
continue
putative_targets.append(
PutativeTarget.for_target_type(
GoPackageTarget,
path=dirname,
name=os.path.basename(dirname),
name=dir_path.name,
triggering_sources=sorted(filenames),
)
)
Expand Down
3 changes: 3 additions & 0 deletions src/python/pants/backend/go/goals/tailor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def test_find_go_package_targets(rule_runner: RuleRunner) -> None:
"unowned/f1.go": "",
"owned/f.go": "",
"owned/BUILD": "go_package()",
# Any `.go` files under a `testdata` folder should be ignored.
"unowned/testdata/f.go": "",
"unowned/testdata/subdir/f.go": "",
}
)
putative_targets = rule_runner.request(
Expand Down