1
0
Fork 0
mirror of https://github.com/imjasonh/testscript-rs synced 2026-07-08 17:16:38 +00:00
testscript-rs/examples/test_workdir_root.rs
copilot-swe-agent[bot] 6fd802beb2 Implement WorkdirRoot configuration feature
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
2025-09-30 06:20:27 +00:00

37 lines
No EOL
1.1 KiB
Rust

use testscript_rs::testscript;
use std::fs;
use tempfile::TempDir;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Testing workdir_root functionality...");
// Create a custom root directory
let custom_root = "/tmp/test_workdir_root";
fs::create_dir_all(custom_root)?;
// Create test data
let testdata = TempDir::new()?;
let testdata_path = testdata.path().join("testdata");
fs::create_dir(&testdata_path)?;
let test_content = r#"exec echo "Testing workdir_root feature"
stdout "Testing workdir_root feature"
"#;
fs::write(testdata_path.join("test.txt"), test_content)?;
// Test with custom workdir root
println!("Running test with custom workdir root: {}", custom_root);
match testscript::run(testdata_path.to_string_lossy())
.workdir_root(custom_root)
.execute() {
Ok(()) => println!("✓ Test passed with custom workdir root!"),
Err(e) => {
eprintln!("✗ Test failed: {:?}", e);
return Err(e.into());
}
}
println!("All tests passed! The workdir_root feature is working correctly.");
Ok(())
}