(
parent: &Path,
config: &Config,
)
| 257 | /// same synthetic content. Returns the atomic golden and the bare path. |
| 258 | #[cfg(unix)] |
| 259 | fn prepare_fixtures( |
| 260 | parent: &Path, |
| 261 | config: &Config, |
| 262 | ) -> Result<(tempfile::TempDir, Vec<Golden>, PathBuf)> { |
| 263 | let directory = tempfile::Builder::new().prefix("agb").tempdir_in(parent)?; |
| 264 | let root = directory.path(); |
| 265 | let golden = build_golden(config); |
| 266 | |
| 267 | // Atomic host repository. Writes happen through the ordinary record path |
| 268 | // so the served graph is a real repository, not a canned fixture. |
| 269 | let repo = atomic_repository::Repository::init(root.join("host"))?; |
| 270 | if config.span { |
| 271 | use atomic_core::pristine::{CapabilityMutTxnT, MutTxnT, SPAN_RANGE_CAPABILITY}; |
| 272 | let mut txn = repo.pristine().write_txn()?; |
| 273 | txn.put_required_capability(SPAN_RANGE_CAPABILITY)?; |
| 274 | txn.commit()?; |
| 275 | } |
| 276 | fs::create_dir_all(root.join("host/files/east"))?; |
| 277 | fs::create_dir_all(root.join("host/files/west"))?; |
| 278 | for file in &golden { |
| 279 | fs::write(root.join("host").join(&file.path), &file.content)?; |
| 280 | } |
| 281 | let wc = repo.require_working_copy_id()?; |
| 282 | repo.add(wc, "files", Default::default())?; |
| 283 | repo.add(wc, "empty.txt", Default::default())?; |
| 284 | record(&repo, "synthetic baseline", 0)?; |
| 285 | // Hot-file edits: every edit rewrites the east hot file and records it, |
| 286 | // exactly one commit per edit to match the Git history's shape. |
| 287 | let hot_path = root.join("host/files/east/file_0000.txt"); |
| 288 | let mut hot: Vec<String> = (0..config.lines) |
| 289 | .map(|l| generated_line("east", 0, l)) |
| 290 | .collect(); |
| 291 | for edit in 0..config.edits { |
| 292 | let line = (edit * 17) % config.lines; |
| 293 | hot[line] = edited_line(line, edit + 1); |
| 294 | let content = hot.concat(); |
| 295 | fs::write(&hot_path, &content)?; |
| 296 | record(&repo, "synthetic hot-file edit", edit + 1)?; |
| 297 | } |
| 298 | let hot = hot.concat(); |
| 299 | // The golden east hot file must reflect the final edit, not the baseline. |
| 300 | let mut golden = golden; |
| 301 | let golden_east_hot = golden |
| 302 | .iter_mut() |
| 303 | .find(|f| f.path == "files/east/file_0000.txt") |
| 304 | .context("missing east hot file in golden")?; |
| 305 | golden_east_hot.content = hot.into_bytes(); |
| 306 | drop(repo); |
| 307 | |
| 308 | // Git bare repository with the same shape: one baseline commit, one |
| 309 | // commit per hot-file edit. The seed must start from the baseline |
| 310 | // content — the golden's hot file already reflects the edits. |
| 311 | let seed = root.join("git-seed"); |
| 312 | fs::create_dir_all(seed.join("files/east"))?; |
| 313 | fs::create_dir_all(seed.join("files/west"))?; |
| 314 | let baseline_hot: Vec<Golden> = golden |
| 315 | .iter() |
| 316 | .map(|file| { |
no test coverage detected