diff --git a/.agents/rules/testing.md b/.agents/rules/testing.md index df023fcace..8a56157230 100644 --- a/.agents/rules/testing.md +++ b/.agents/rules/testing.md @@ -48,7 +48,10 @@ description: Bazel test execution, integration test flags, and lockfiles ## Test Organization * **Domain Placement**: Place tests by the feature tested (e.g., `tests/bootstrap_impls/`), not by the fixture helper used (e.g., - `py_extension`). + `py_extension`). Keep tests and `BUILD.bazel` targets for `.agents/` scripts + co-located with the agent code (not under `tests/`), and run them via + `bazel test --config=fast-tests //.agents/...` since `//tests/...` does not + cover `.agents/`. * **Platform Constraints**: Restrict OS-specific targets with `target_compatible_with` (e.g., `["@platforms//os:windows"]`) to skip on incompatible platforms. diff --git a/.agents/skills/conversation-done/scripts/BUILD.bazel b/.agents/skills/conversation-done/scripts/BUILD.bazel index 199204599e..e06e8e66f7 100644 --- a/.agents/skills/conversation-done/scripts/BUILD.bazel +++ b/.agents/skills/conversation-done/scripts/BUILD.bazel @@ -1,6 +1,21 @@ -package(default_visibility = ["//tests:__subpackages__"]) +load("//python:py_library.bzl", "py_library") +load("//python:py_test.bzl", "py_test") +load("//tests/support:support.bzl", "NOT_WINDOWS") -exports_files( - ["cleanup.py"], - visibility = ["//tests:__subpackages__"], +package(default_visibility = ["//visibility:private"]) + +py_library( + name = "cleanup", + testonly = True, + srcs = ["cleanup.py"], + imports = ["."], + target_compatible_with = NOT_WINDOWS, +) + +py_test( + name = "cleanup_test", + size = "small", + srcs = ["cleanup_test.py"], + target_compatible_with = NOT_WINDOWS, + deps = [":cleanup"], ) diff --git a/tests/agents/cleanup_test.py b/.agents/skills/conversation-done/scripts/cleanup_test.py similarity index 100% rename from tests/agents/cleanup_test.py rename to .agents/skills/conversation-done/scripts/cleanup_test.py diff --git a/AGENTS.md b/AGENTS.md index 07768b12b4..c762122d47 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -176,7 +176,9 @@ bzl_library( ## Building and testing -Tests are under the `tests/` directory. +Tests are under the `tests/` directory, except tests for agent scripts under +`.agents/`, which stay co-located with the agent code (run with +`bazel test --config=fast-tests //.agents/...`). When testing, add `--config=fast-tests`. diff --git a/tests/agents/BUILD.bazel b/tests/agents/BUILD.bazel deleted file mode 100644 index 2b241781c4..0000000000 --- a/tests/agents/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("//python:py_library.bzl", "py_library") -load("//python:py_test.bzl", "py_test") -load("//tests/support:support.bzl", "NOT_WINDOWS") - -py_library( - name = "cleanup_lib", - testonly = True, - srcs = ["//.agents/skills/conversation-done/scripts:cleanup.py"], - imports = ["../../.agents/skills/conversation-done/scripts"], - target_compatible_with = NOT_WINDOWS, -) - -py_test( - name = "cleanup_test", - size = "small", - srcs = ["cleanup_test.py"], - target_compatible_with = NOT_WINDOWS, - deps = [":cleanup_lib"], -)