Skip to content

fix: ignore commented inline-test markers#1432

Closed
statxc wants to merge 1 commit into
entrius:testfrom
statxc:fix/inline-test-ast-detection
Closed

fix: ignore commented inline-test markers#1432
statxc wants to merge 1 commit into
entrius:testfrom
statxc:fix/inline-test-ast-detection

Conversation

@statxc

@statxc statxc commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

close #1431

Fix has_inline_tests() so Rust/Zig/D inline-test detection no longer treats markers inside comments or string literals as real tests.

The existing regex remains as a fast prefilter, but matches are now verified against tree-sitter AST nodes:

  • Rust: attribute_item / inner_attribute_item
  • Zig: TestDecl
  • D: unittest_declaration

This preserves the current file-level inline-test demotion behavior while avoiding false positives from docs, examples, comments, and raw strings.

Problem

has_inline_tests() regex-scanned raw source text. A production Rust file containing #[test] only inside a block comment or raw multiline string was classified as an inline-test file.

That caused calculate_token_score_from_file_changes() to demote the whole file to ScoringCategory.TEST and apply TEST_FILE_CONTRIBUTION_WEIGHT = 0.05.

Validation

  • uv run pytest -q tests/validator/test_inline_test_detection.py
  • uv run pytest -q tests/validator/test_token_scoring_integration.py tests/validator/test_inline_test_detection.py
  • uv run pytest tests/ -v
  • uv run pre-commit run --all-files --show-diff-on-failure
  • SKIP=pytest uv run pre-commit run --all-files --hook-stage pre-push

Result: full test suite passed, 914 tests.

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jun 2, 2026
@anderdc anderdc closed this Jun 4, 2026
@statxc

statxc commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

@anderdc I hope you are doing well.
Could you explain about why this was closed.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Inline-test detection treats block comments and multiline strings as real tests

2 participants