Skip to content

Improve instructions on how to run tests for AI agents#5592

Open
y9v wants to merge 2 commits intomasterfrom
improve-agentic-docs-for-running-tests
Open

Improve instructions on how to run tests for AI agents#5592
y9v wants to merge 2 commits intomasterfrom
improve-agentic-docs-for-running-tests

Conversation

@y9v
Copy link
Copy Markdown
Member

@y9v y9v commented Apr 14, 2026

What does this PR do?
This PR aims to improve the identification of a correct test task for AI agents.

Motivation:
AI agents (Claude Code, Cursor, etc.) currently try running isolated spec files with bundle exec rspec ..., which fails for contrib/integration tests that require specific appraisal Gemfiles. This change teaches the agents the lib/spec/rake test:TASK_KEY mapping, including the product-level pattern (namespaced tasks for appsec/profiling/di/ai_guard, flat tasks for tracing contribs), and how to self-serve edge cases by checking the Rakefile and Matrixfile.

Change log entry
None.

Additional Notes:
I used AI to write these changes, used AI to test if these instructions actually improve anything.

How to test the change?
Try to do some simple change using your favorite coding agent, see if it can correctly identify the test tasks it needs to run.

@y9v y9v self-assigned this Apr 14, 2026
@y9v y9v requested a review from a team as a code owner April 14, 2026 12:46
@datadog-prod-us1-5
Copy link
Copy Markdown

datadog-prod-us1-5 bot commented Apr 14, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 97.26% (+1.89%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: fb870dc | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

Copy link
Copy Markdown
Contributor

@vpellan vpellan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I had a similar PR in #5588 but I think yours is better, so I'll close mine

Comment thread .cursor/rules/testing.mdc
Comment on lines +61 to +62
- Contrib/integration tests need Docker: `docker compose run --rm tracer-3.4 /bin/bash`, then run the rake task inside
- `test:main` can run locally on any Ruby for quick feedback
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #5588, I added instructions to tell agents to run the tests twice: once with the earliest version we support (2.5) and once with the latest version (4.0) because it often happens that we miss regressions in older rubies.

Also, it often happens after a dependency update that cursor fails to run bundler. I think we can also add an instruction like If Bundler fails in the container, run bundle install and retry once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants