1
0
Fork 0
mirror of https://github.com/imjasonh/testscript-rs synced 2026-07-09 09:36:48 +00:00

Implement TestWork functionality for preserving working directories on failure

Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-09-27 17:27:10 +00:00
parent 6cb1109c05
commit fe5da3cebe
7 changed files with 282 additions and 5 deletions

View file

@ -8,8 +8,22 @@ fn main() {
std::env::set_current_dir(manifest_dir).expect("Failed to change directory");
}
// Run all tests in testdata directory
match testscript::run("testdata").execute() {
// Check for test directory from environment for test purposes
let test_dir = std::env::var("TESTSCRIPT_TEST_DIR").unwrap_or_else(|_| "testdata".to_string());
// Check if preserve work should be enabled
let preserve_work = std::env::var("TESTSCRIPT_PRESERVE_WORK")
.map(|v| v == "true" || v == "1")
.unwrap_or(false);
// Run all tests in the specified directory
let mut builder = testscript::run(test_dir);
if preserve_work {
builder = builder.preserve_work_on_failure(true);
}
match builder.execute() {
Ok(()) => println!("All tests passed!"),
Err(e) => {
eprintln!("Test failed: {}", e);