fix: render command now respects --working-dir global argument#366
Merged
josecelano merged 12 commits intomainfrom Feb 18, 2026
Merged
fix: render command now respects --working-dir global argument#366josecelano merged 12 commits intomainfrom
josecelano merged 12 commits intomainfrom
Conversation
- Add working_dir() accessor method to ExecutionContext - Update router to pass working_dir from context to render controller - Update render controller to accept working_dir parameter instead of using std::env::current_dir() - Update application handler to use Environment::create() with working_dir - Update render command test to pass temp workspace as working_dir This fixes the bug where the render command ignored the --working-dir global argument and always used the current directory, causing tests to pollute the project's data/ folder. Resolves #365
ddab8eb to
a434dda
Compare
Adds automated check to ensure unit tests don't pollute the production data/ folder. This verification: - Runs after unit tests in the testing workflow - Checks if data/ folder contains any files or subdirectories - Fails the workflow with clear error message if pollution detected - Only runs in CI (isolated environment) to avoid interference with legitimate local data folder usage E2E test workflows are intentionally excluded as they test real functionality that requires using the data folder. Related to #365
21a2beb to
e3edd01
Compare
Member
Author
|
ACK e3edd01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the bug where the
rendercommand ignores the--working-dirglobal argument and always usesstd::env::current_dir()instead. During investigation and testing, discovered and fixed a broader test isolation issue where E2E tests were polluting the productiondata/folder with logs.Problem Overview
Initial Issue (Issue #365)
The
rendercommand wasn't respecting the--working-dirglobal argument, causing tests to create environment data in the project root instead of isolated temporary directories.Discovered Issue
After fixing the
--working-dirbug, tests still polluteddata/logs/because--log-dirand--working-dirare independent by design. Investigation revealed 44 E2E test ProcessRunner calls across 6 test files that needed explicit--log-dirconfiguration for complete isolation.Changes
Part 1: Render Command --working-dir Fix
Presentation Layer
ExecutionContext (context.rs):
working_dir()accessor method to retrieve the working directory from global CLI argumentsoutput_format()methodRouter (router.rs):
context.working_dir()to the controller--working-dirargument is properly forwardedRender Controller (render/handler.rs):
execute()method signature to acceptworking_dir: &Pathparameterstd::env::current_dir()callworking_dirparameter insteadApplication Layer
Environment::new()toEnvironment::create()to respect the working directoryworking_dirparameter to environment creationPart 2: Complete E2E Test Isolation (6-Phase Refactor)
ProcessRunner Enhancement
log_dirfield to ProcessRunner.log_dir()builder methodrun_create_command,run_destroy_command, etc.) to pass--log-dirwhen configured--working-dir) and log location (via--log-dir)Test Files Updated (44 ProcessRunner Calls Fixed)
Phase 0 - validate_command.rs (Commit 1d576a5a):
Phase 1 - create_command.rs (Commit e452efe6):
Phase 2 - list_command.rs (Commit 53b87a8d):
Phase 3 - show_command.rs (Commit 5682ae05):
Phase 4 - destroy_command.rs (Commit 82946459):
Phase 5 - purge_command.rs (Commit 1c437d80):
Documentation
Impact
Immediate Benefits
data/folder--working-dirlike other commandsArchitectural Improvements
--working-dirand--log-dirare properly independentTesting
Comprehensive Verification
data/folder: Completely empty (0 files, 0 directories) after running entire test suiteTest Isolation Pattern
Related Issues
Closes #365
Statistics
Checklist
365-fix-render-working-dir)Additional Notes
Architecture Alignment
This fix aligns the render command with the project's architecture where all commands should respect global CLI arguments. The
--working-dirargument is now properly threaded through the entire command execution pipeline: CLI → Router → Controller → Application Handler → Domain.Test Isolation Philosophy
The comprehensive test isolation work follows the project's principle that tests should never pollute production directories. By ensuring both
--working-dirand--log-dirare properly controlled, we achieve complete test isolation where temporary directories are created, used, and automatically cleaned up without leaving any artifacts in the project workspace.Systematic Approach
The refactor followed a systematic phase-by-phase approach (documented in e2e-test-isolation-log-dir.md):
This approach ensured the pattern was solid before applying it to more complex test files, and made the review process more manageable with clear, focused commits.