MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / build_template

Function build_template

tests/mcp_suite/fixture.rs:270–307  ·  view source on GitHub ↗
(dest: &Path)

Source from the content-addressed store, hash-verified

268}
269
270async fn build_template(dest: &Path) -> io::Result<()> {
271 // Build in a system temp dir, not under the repository's target/, so
272 // branch detection walking up from the fixture project cannot find this
273 // repo's .git and bootstrap branch metadata that a TempDir-based test
274 // project would never have.
275 let scratch = tempfile::TempDir::new()?;
276 let scratch_root = scratch.path().canonicalize()?;
277
278 for (flavor, indexed) in [(EMPTY_FLAVOR, false), (INDEXED_FLAVOR, true)] {
279 let root = scratch_root.join(flavor);
280 let project = root.join("project");
281 fs::create_dir_all(&project)?;
282 if indexed {
283 write_indexed_fixture_sources(&project);
284 }
285
286 let profile_root = root.join("home/.tracedecay");
287 let global_db_path = profile_root.join("global.db");
288 let options = TraceDecayOpenOptions {
289 profile_root: Some(profile_root.clone()),
290 global_db_path: Some(global_db_path.clone()),
291 };
292 let cg = TraceDecay::init_with_options(&project, options)
293 .await
294 .map_err(io_other)?;
295 if indexed {
296 cg.index_all().await.map_err(io_other)?;
297 }
298 cg.checkpoint().await.map_err(io_other)?;
299 cg.close();
300
301 purge_global_registry(&global_db_path).await?;
302 copy_tree(&root, &dest.join(flavor))?;
303 }
304
305 fs::write(dest.join("READY"), b"ok")?;
306 Ok(())
307}
308
309/// Removes the template project's own registration from the template global
310/// DB so seeded copies start with a schema-complete but empty registry;

Callers 1

ensure_templateFunction · 0.85

Calls 7

purge_global_registryFunction · 0.85
copy_treeFunction · 0.85
writeFunction · 0.85
index_allMethod · 0.80
checkpointMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected