mirror of
https://github.com/imjasonh/krust
synced 2026-07-08 06:45:32 +00:00
migrate integration tests to testscript
Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
parent
cd1d52840c
commit
24685b4331
16 changed files with 299 additions and 345 deletions
37
tests/testscript_test.rs
Normal file
37
tests/testscript_test.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
use std::path::PathBuf;
|
||||
use testscript_rs::testscript;
|
||||
|
||||
#[test]
|
||||
fn testscripts() {
|
||||
// Get the path to the target/debug directory
|
||||
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let target_dir = manifest_dir.join("target").join("debug");
|
||||
|
||||
testscript::run("tests/testdata")
|
||||
.setup(move |env| {
|
||||
// Build krust binary
|
||||
std::process::Command::new("cargo")
|
||||
.args(["build", "--bin", "krust"])
|
||||
.status()
|
||||
.expect("Failed to build krust");
|
||||
|
||||
// Copy binary to test work directory so it's available in PATH
|
||||
let krust_src = target_dir.join("krust");
|
||||
let krust_dst = env.work_dir.join("krust");
|
||||
|
||||
std::fs::copy(&krust_src, &krust_dst)?;
|
||||
|
||||
// Make it executable
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let mut perms = std::fs::metadata(&krust_dst)?.permissions();
|
||||
perms.set_mode(0o755);
|
||||
std::fs::set_permissions(&krust_dst, perms)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.execute()
|
||||
.unwrap();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue