mirror of
https://github.com/imjasonh/testscript-rs
synced 2026-07-10 01:56:45 +00:00
Implement WorkdirRoot configuration feature
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
This commit is contained in:
parent
a74df564e0
commit
6fd802beb2
6 changed files with 309 additions and 2 deletions
37
examples/test_workdir_root.rs
Normal file
37
examples/test_workdir_root.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue