Skip to content

Comments

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

Open
Serhan-Asad wants to merge 2 commits intopromptdriven:mainfrom
Serhan-Asad:fix/issue-553
Open

test: add failing tests for circular include detection in non-recursive mode (#553)#554
Serhan-Asad wants to merge 2 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
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

1 participant