mirror of
https://github.com/imjasonh/testscript-rs
synced 2026-07-08 17:16:38 +00:00
- [x] Analyze current codebase and understand test execution flow - [x] Add preserve_work_on_failure field to RunParams struct - [x] Add preserve_work_on_failure() method to Builder - [x] Modify TestEnvironment to support preserving work directories - [x] Update run_script_impl to handle work directory preservation on failure - [x] Add comprehensive tests to validate the new functionality - [x] Update documentation with usage examples - [x] Update README with TestWork section showing debugging capabilities - [x] Fix clippy warnings for code quality - [x] Validate functionality works correctly in both debug and release modes - [x] Fix formatting issues that caused CI failure - [x] Replace std::mem::forget() with idiomatic TempDir::keep() method ## Improved Code Quality ✅ Replaced the non-idiomatic use of `std::mem::forget()` with the proper `TempDir::keep()` method for preserving temporary directories. This approach: - Is more explicit about the intent to preserve the directory - Is the recommended way according to tempfile crate documentation - Removes the need for manual memory management workarounds - Makes the code more readable and maintainable All tests continue to pass and functionality remains unchanged. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Add TestWork functionality to preserve working directories</issue_title> > <issue_description>## Feature Request: TestWork Functionality > > Go's testscript supports a `TestWork` parameter that preserves working directories when tests fail, making debugging much easier. > > ## Proposed API > > ```rust > testscript::run("testdata") > .preserve_work_on_failure(true) > .execute() > .unwrap(); > ``` > > ## Implementation > > - When a test fails and this option is enabled, print the work directory path > - Don't clean up the temporary directory on test failure > - Could also support preserving on success for debugging > > ## Benefits > > - **Easier debugging**: Inspect files created during failed tests > - **Development workflow**: Understand what went wrong > - **Compatibility**: Matches Go testscript behavior > > ## Example Output > > ``` > Test failed. Work directory preserved at: /tmp/testscript-work-abc123 > You can inspect the test environment: > cd /tmp/testscript-work-abc123 > ls -la > ```</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> Fixes imjasonh/testscript-rs#6 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start the survey. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com> Co-authored-by: Jason Hall <jason@chainguard.dev> |
||
|---|---|---|
| .. | ||
| advanced_conditions.rs | ||
| builtin_commands.rs | ||
| edge_cases.rs | ||
| error_messages.rs | ||
| integration.rs | ||
| preserve_work.rs | ||
| setup_hook.rs | ||
| update_scripts.rs | ||