()
| 17 | |
| 18 | impl Fixture { |
| 19 | fn new() -> Self { |
| 20 | let home = tempfile::tempdir().unwrap(); |
| 21 | let work = tempfile::tempdir_in(home.path()).unwrap(); |
| 22 | // Cargo can release its target lock while tests run, allowing another |
| 23 | // worktree to replace the shared binary between fixtures or commands. |
| 24 | static BINARY: OnceLock<(Vec<u8>, std::fs::Permissions)> = OnceLock::new(); |
| 25 | let (bytes, permissions) = BINARY.get_or_init(|| { |
| 26 | let path = Path::new(env!("CARGO_BIN_EXE_atomic")); |
| 27 | ( |
| 28 | std::fs::read(path).expect("read test binary"), |
| 29 | std::fs::metadata(path) |
| 30 | .expect("stat test binary") |
| 31 | .permissions(), |
| 32 | ) |
| 33 | }); |
| 34 | let binary = home.path().join("atomic-under-test"); |
| 35 | std::fs::write(&binary, bytes).expect("pin test binary"); |
| 36 | std::fs::set_permissions(&binary, permissions.clone()) |
| 37 | .expect("make test binary executable"); |
| 38 | Self { work, home, binary } |
| 39 | } |
| 40 | |
| 41 | fn run(&self, args: &[&str]) -> Output { |
| 42 | self.run_at(self.work.path(), args) |
nothing calls this directly
no test coverage detected