Skip to content

Commit fe49d8d

Browse files
chore(dev): let the test tasks take paths and record two harness landmines
`server:test:unit` and `e2e:test:e2e` hardcoded `./...` while AGENTS.md documented a `paths` var they never read, and the e2e task documented `focusFilter`/`labelFilter` it never passed to ginkgo either. A scoped server run now takes 4s instead of 1m50s, so the documented way to target a package finally exists; `server:test:ai` takes the same var. The two landmines cost a wasted step and a failed test in this session: namespaced task targets exist only in the root Taskfile, and `logboek.Context()` special-cases exactly `context.Background()` while any derived context without a bound logger panics. `test-the-tests` gains the mutation hazard an independent review hit here: a test whose only barrier before a real daemon is a validation error inside the code being mutated provisions real infrastructure the moment that validation is inverted, and hangs instead of failing when nothing drains its output. Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
1 parent e2136e6 commit fe49d8d

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

.agents/skills/test-the-tests/SKILL.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ seen fail.
3838

3939
## Common ways a test looks strong but isn't
4040

41+
- **A real daemon, cluster or network is one mutation away.** A test that reaches the code
42+
under test through a validation error — "the driver is rejected, so `docker buildx create`
43+
is never called" — has its only barrier inside the thing being mutated. Invert that
44+
validation and the test provisions real infrastructure, leaves it behind, and hangs instead
45+
of failing when nothing drains what the code writes. Neutralize the escape before relying
46+
on it (an empty `PATH`, an unroutable address) and drain every pipe the code writes to, so
47+
the fault fails the test rather than the machine running it.
4148
- **The assertion holds under the bug too.** A chain assertion like
4249
`index(a) < index(b) < index(c)` can pass under both the fix and the regression it's
4350
meant to catch if the scenario doesn't force them to disagree. Reshape the scenario (add

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Follow [Effective Go](https://go.dev/doc/effective_go) and [Go Code Review Comme
6969

7070
## Commands (MANDATORY)
7171

72-
ALWAYS use these `task` commands. NEVER use raw `go build`, `go test`, `go fmt`, `go vet`, or `golangci-lint` directly. trdl is a multi-module project — most commands are namespaced by module.
72+
ALWAYS use these `task` commands. NEVER use raw `go build`, `go test`, `go fmt`, `go vet`, or `golangci-lint` directly. trdl is a multi-module project — most commands are namespaced by module, and those namespaces exist only in the root Taskfile: ALWAYS run `task` from the repository root, never from inside `server/`, `client/`, `e2e/` or `release/`.
7373

7474
### Building
7575
- NEVER `go build` → ALWAYS use the appropriate build task:
@@ -96,6 +96,7 @@ ALWAYS use these `task` commands. NEVER use raw `go build`, `go test`, `go fmt`,
9696

9797
## Testing (MANDATORY)
9898

99+
- `logboek.Context(ctx)` returns the default logger ONLY for exactly `context.Background()`; any derived context without a bound logger panics with `context is not bound with logboek logger`. In a test that reaches code logging through logboek, pass `context.Background()` unchanged or wrap it: `logboek.NewContext(ctx, logboek.DefaultLogger())`.
99100
- Server tests use Ginkgo/Gomega. `testify` (`assert`, `require`) is also available in the `server/` module.
100101
- E2E tests use Ginkgo/Gomega exclusively.
101102
- When writing tests as an AI agent → ALWAYS name the file `*_ai_test.go`, add `//go:build ai_tests` build tag, prefix test functions with `TestAI_`.

e2e/Taskfile.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ tasks:
3737
CGO_ENABLED: "0"
3838

3939
test:e2e:
40-
desc: "Run client e2e test."
40+
desc: 'Run client e2e test. Important vars: "paths", "focusFilter", "labelFilter".'
4141
# On linux/amd64 the elf_signing suite links the delivery-kit-sdk CGO ELF
4242
# signer via the server import, so it needs the C libs from
4343
# server:deps:install:c. On other platforms that suite is skipped.
44-
cmd: ginkgo --vv --keep-going --cover --covermode=atomic --coverpkg=github.com/werf/trdl/client/...,github.com/werf/trdl/server/... --output-dir={{.outputDir}} ./...
44+
cmd: ginkgo --vv --keep-going --cover --covermode=atomic --coverpkg=github.com/werf/trdl/client/...,github.com/werf/trdl/server/... --output-dir={{.outputDir}} {{if .focusFilter}}--focus="{{.focusFilter}}" {{end}}{{if .labelFilter}}--label-filter="{{.labelFilter}}" {{end}}{{.paths}}
4545
vars:
4646
outputDir: '{{.outputDir | default "../tests_coverage/e2e" }}'
47+
paths: '{{.paths | default "./..."}}'
4748

4849
test:e2e:elf-signing:
4950
desc: "Run ELF signing e2e test (linux/amd64 with CGO; requires server:deps:install:c)."

server/Taskfile.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,17 @@ tasks:
323323
goTags: "test_coverage"
324324

325325
test:unit:
326-
desc: "Run server unit tests."
327-
cmd: ginkgo --vet=off --race --keep-going --cover --coverpkg=./... --output-dir={{.outputDir}} ./...
326+
desc: 'Run server unit tests. Important vars: "paths".'
327+
cmd: ginkgo --vet=off --race --keep-going --cover --coverpkg=./... --output-dir={{.outputDir}} {{.paths}}
328328
vars:
329329
outputDir: '{{.outputDir | default "../tests_coverage/unit"}}'
330+
paths: '{{.paths | default "./..."}}'
330331

331332
test:ai:
332-
desc: "Run server tests written by AI agents (ai_tests build tag). Set TRDL_SMOKE_BUILDKITD_ADDRESS to include the buildkitd smoke test."
333-
cmd: ginkgo --vet=off --race --keep-going --tags=ai_tests ./...
333+
desc: 'Run server tests written by AI agents (ai_tests build tag). Set TRDL_SMOKE_BUILDKITD_ADDRESS to include the buildkitd smoke test. Important vars: "paths".'
334+
cmd: ginkgo --vet=off --race --keep-going --tags=ai_tests {{.paths}}
335+
vars:
336+
paths: '{{.paths | default "./..."}}'
334337

335338
verify:dist:binaries:
336339
desc: "Verify that the distributable binaries are built and have correct platform/arch."

0 commit comments

Comments
 (0)