Skip to content

test: add failing tests for circular include detection in non-recursive mode (#553)#554

Merged
gltanaka merged 3 commits intopromptdriven:mainfrom
Serhan-Asad:fix/issue-553
Feb 24, 2026
Merged

test: add failing tests for circular include detection in non-recursive mode (#553)#554
gltanaka merged 3 commits intopromptdriven:mainfrom
Serhan-Asad:fix/issue-553

Conversation

@Serhan-Asad
Copy link
Collaborator

Summary

Adds failing tests that detect the bug reported in #553 — circular <include> tags cause an infinite loop in the default (non-recursive) preprocess path.

Test Files

  • Unit tests: tests/test_circular_includes.py (6 new tests in TestCircularIncludesNonRecursive class)
  • E2E tests: tests/test_e2e_issue_553_circular_includes_non_recursive.py (6 subprocess-based CLI tests)

What This PR Contains

  • 4 failing unit tests that reproduce the infinite loop bug (timeout after 10s)
  • 4 failing E2E tests that verify the bug at CLI integration level (subprocess + timeout)
  • 4 regression guards (2 unit + 2 E2E) that confirm non-circular includes and recursive mode still work correctly
  • Tests are verified to fail on current code and will pass once the bug is fixed

Root Cause

_seen set for cycle detection is only populated inside if recursive: blocks at preprocess.py:272-274 and preprocess.py:179-181. In the default non-recursive path, _seen stays empty, so the cycle check at line 226 is dead code. The convergence loop (while prev_text != current_text) oscillates forever with circular includes.

Next Steps

  1. Implement the fix — extend _seen tracking into the non-recursive convergence loop
  2. Verify all 8 circular include tests pass (4 unit + 4 E2E)
  3. Verify all 4 regression guards still pass
  4. Run full test suite to check for regressions
  5. Mark PR as ready for review

Fixes #553


Generated by PDD agentic bug workflow

…ve mode (promptdriven#553)

Add 6 unit tests and 6 E2E tests that detect the bug where circular
<include> tags cause an infinite loop in the default (non-recursive)
preprocess path. The _seen set is only populated inside `if recursive:`
blocks, making cycle detection dead code in non-recursive mode.

Unit tests (test_circular_includes.py):
- 4 circular tests that fail with timeout (infinite loop)
- 2 regression guards that pass (non-circular includes still work)

E2E tests (test_e2e_issue_553_circular_includes_non_recursive.py):
- 4 subprocess-based CLI tests that fail with timeout
- 2 regression guards that pass

All circular tests are verified to fail on current code and will pass
once the fix is implemented.

Refs promptdriven#553
… path (promptdriven#553)

Populate _seen tracking in the non-recursive convergence loops of
process_include_tags and process_backtick_includes. Previously _seen was
only updated inside `if recursive:` blocks, making the cycle check dead
code in non-recursive (default) mode and causing infinite loops.

Also clean up unused _timeout/signal/contextlib imports in tests and
make E2E output file assertion unconditional.

Fixes promptdriven#553

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Serhan-Asad Serhan-Asad marked this pull request as ready for review February 23, 2026 18:40
@gltanaka gltanaka requested a review from Copilot February 24, 2026 01:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds regression tests for Issue #553 (circular <include> tags causing an infinite loop in the default non-recursive preprocess path) and updates the preprocessor to attempt cycle detection in the non-recursive convergence loops.

Changes:

  • Add new unit test coverage for circular includes in non-recursive mode.
  • Add new subprocess-based CLI E2E coverage for Issue #553 scenarios (mutual/self/3-file cycles; XML and backtick includes).
  • Modify pdd/preprocess.py to detect circular includes during non-recursive convergence.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
pdd/preprocess.py Adds tracking-based cycle detection in the non-recursive convergence loops for XML and backtick includes.
tests/test_circular_includes.py Adds a new TestCircularIncludesNonRecursive test class for Issue #553 coverage.
tests/test_e2e_issue_553_circular_includes_non_recursive.py Adds subprocess-based CLI tests that assert non-recursive circular includes fail fast instead of hanging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…eplace pytest-timeout markers with signal-based timeouts

- E2E tests now set PYTHONPATH to project root, matching other E2E tests in the repo (prevents ModuleNotFoundError in CI)
- Replace @pytest.mark.timeout(10) with @_with_timeout(10) using SIGALRM since pytest-timeout is not a declared dependency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gltanaka gltanaka merged commit 1b9f59a into promptdriven:main Feb 24, 2026
1 check passed
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.

Circular include cycle detection missing in non-recursive preprocess path

3 participants