Skip to content

Add failing tests for #154: file overwrite silently skipped#344

Draft
jamesdlevine wants to merge 4 commits intopromptdriven:mainfrom
jamesdlevine:fix/issue-154
Draft

Add failing tests for #154: file overwrite silently skipped#344
jamesdlevine wants to merge 4 commits intopromptdriven:mainfrom
jamesdlevine:fix/issue-154

Conversation

@jamesdlevine
Copy link
Contributor

Summary

Adds failing tests that detect the bug reported in #154 where "generation overwrite a file doesn't always happen".

Test Files

  • Unit tests: tests/test_code_generator_main.py (new tests in TestIssue154OverwriteNotHappening class)
  • E2E tests: tests/test_e2e_issue_154_overwrite.py

What This PR Contains

  • 3 failing unit tests that reproduce the reported bug at the function level
  • 4 E2E tests (3 failing, 1 passing control) that verify the bug at CLI level
  • Tests are verified to fail on current code and will pass once the bug is fixed

Root Cause

There's an architectural disconnect between overwrite confirmation and file write operations. The overwrite confirmation happens in construct_paths(), but the actual write happens later with additional conditional gates. If output_path is falsy (empty string or None), the write is silently skipped at pdd/code_generator_main.py:1087.

Bug Location: pdd/code_generator_main.py:1087 - the if output_path: check silently skips the write block instead of failing early with a clear error.

Failing Tests

Unit Tests

  1. test_issue_154_empty_output_path_should_raise_error - Verifies empty output_path raises click.UsageError
  2. test_issue_154_none_output_path_should_raise_error - Verifies None output_path raises click.UsageError
  3. test_issue_154_llm_should_not_be_called_with_invalid_output_path - Verifies LLM is NOT called when output_path is invalid

E2E Tests

  1. test_generate_fails_when_output_path_is_empty - Command should fail with non-zero exit code
  2. test_generate_fails_when_output_path_is_empty_string - Command should fail for empty string output
  3. test_no_overwrite_prompt_when_output_path_invalid - No misleading overwrite confirmation when write will be skipped

Next Steps

  1. Implement the fix at pdd/code_generator_main.py:1087
  2. Verify the unit tests pass
  3. Verify the E2E tests pass
  4. Run full test suite
  5. Mark PR as ready for review

Fixes #154


Generated by PDD agentic bug workflow

jamesdlevine and others added 4 commits January 15, 2026 22:21
…the .[dev] requirements from the current worktree - Added a phony target to do the update; made the appropriate test targets depend on it.
Address Copilot review feedback: the ensure-dev-deps dependency
is redundant on all-regression since regression, sync-regression,
and cloud-regression already depend on it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… skipped

This commit adds unit tests and E2E tests that reproduce the bug where
"generation overwrite a file doesn't always happen". The tests verify
that the code should raise an error when output_path is empty or None,
rather than silently skipping the file write.

Unit tests (tests/test_code_generator_main.py):
- test_issue_154_empty_output_path_should_raise_error
- test_issue_154_none_output_path_should_raise_error
- test_issue_154_llm_should_not_be_called_with_invalid_output_path

E2E tests (tests/test_e2e_issue_154_overwrite.py):
- test_generate_fails_when_output_path_is_empty
- test_generate_fails_when_output_path_is_empty_string
- test_generate_succeeds_when_output_path_is_valid
- test_no_overwrite_prompt_when_output_path_invalid

These tests currently FAIL on the buggy code and will pass once the
fix is implemented at pdd/code_generator_main.py:1087.

Fixes promptdriven#154

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

generation overwrite a file doesn't always happen

1 participant