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

Function test_file_churn

tests/graph_suite/graph_test.rs:1235–1283  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1233
1234#[tokio::test]
1235async fn test_file_churn() {
1236 let dir = TempDir::new().expect("failed to create temp dir");
1237 let project = dir.path();
1238
1239 // Init a real git repo and make two commits touching the same file
1240 std::process::Command::new("git")
1241 .args(["init"])
1242 .current_dir(project)
1243 .output()
1244 .expect("git init failed");
1245 std::process::Command::new("git")
1246 .args(["config", "user.email", "test@test.com"])
1247 .current_dir(project)
1248 .output()
1249 .expect("git config email failed");
1250 std::process::Command::new("git")
1251 .args(["config", "user.name", "Test"])
1252 .current_dir(project)
1253 .output()
1254 .expect("git config name failed");
1255
1256 fs::write(project.join("file.rs"), "fn foo() {}").expect("write failed");
1257 std::process::Command::new("git")
1258 .args(["add", "."])
1259 .current_dir(project)
1260 .output()
1261 .expect("git add failed");
1262 std::process::Command::new("git")
1263 .args(["commit", "-m", "first"])
1264 .current_dir(project)
1265 .output()
1266 .expect("git commit 1 failed");
1267
1268 fs::write(project.join("file.rs"), "fn foo() {} fn bar() {}").expect("write failed");
1269 std::process::Command::new("git")
1270 .args(["add", "."])
1271 .current_dir(project)
1272 .output()
1273 .expect("git add 2 failed");
1274 std::process::Command::new("git")
1275 .args(["commit", "-m", "second"])
1276 .current_dir(project)
1277 .output()
1278 .expect("git commit 2 failed");
1279
1280 let churn = file_churn(project, 90).await.expect("file_churn failed");
1281 let count = churn.get("file.rs").copied().unwrap_or(0);
1282 assert!(count >= 2, "file.rs should have churn >= 2, got {count}");
1283}
1284
1285#[tokio::test]
1286async fn test_file_churn_nonexistent_dir() {

Callers

nothing calls this directly

Calls 3

writeFunction · 0.85
file_churnFunction · 0.85
outputMethod · 0.80

Tested by

no test coverage detected