test(grasp06): run staging maintenance in streaming cleanup fixture

The standalone receive-pack streaming test expected synchronous directory
removal and omitted the server's maintenance worker. Deferred staging cleanup
therefore left the fixture waiting forever even though the production server
starts that worker.

Start the real worker with the handler's lock map and wait with a bounded
deadline for empty-view removal. Also assert that the staging registry is
empty. The fake Git writes no objects, so let its repack and prune commands
complete as no-ops. Preserve the assertion that receive-pack streams progress
while the repository remains available and the subprocess is still running.
This changes test infrastructure only, not production cleanup or timeouts.

Validation: all four streaming tests and the full ngit-grasp suite pass
(3621 tests); formatting and diff checks pass. CI on the production parent
identified the original immediate-removal assertion as its failing test.

Assisted-by: GPT-6
This commit is contained in:
DanConwayDev
2026-09-30 15:54:25 +00:00
parent 1b7d59d23c
commit 834569b4dd
+24 -3
View File
@@ -318,6 +318,10 @@ async fn prs_receive_pack_streams_stdout_before_cleanup_removes_empty_repo() {
subpath: "git-receive-pack".to_string(),
};
let repo_path = prs_repo_path(git_data.path(), &prs.submitter.to_hex(), &prs.identifier);
let maintenance = tokio::spawn(ngit_grasp::git::staging::run_worker(
ngit_grasp::git::storage::LocalGitStorage::new(git_data.path()),
repo_init_locks.clone(),
));
let response = handle_prs_receive_pack(
&prs,
@@ -352,10 +356,22 @@ async fn prs_receive_pack_streams_stdout_before_cleanup_removes_empty_repo() {
finish_body(&mut body, &mut streamed).await;
assert_eq!(streamed, expected_git_output());
assert!(
!repo_path.exists(),
"/prs/ cleanup should remove zero-ref repo after receive-pack exits"
timeout(Duration::from_secs(5), async {
while repo_path.exists() {
tokio::task::yield_now().await;
}
})
.await
.expect("/prs/ maintenance should remove zero-ref repo after receive-pack exits");
assert_eq!(
std::fs::read_dir(git_data.path().join(".grasp/staging"))
.expect("staging registry")
.count(),
0,
"cleanup must also remove the staging record"
);
maintenance.abort();
let _ = maintenance.await;
}
// Keep the listener bound until Git has observed the parent's release.
@@ -553,6 +569,11 @@ if [ "$1" = "for-each-ref" ]; then
exit 0
fi
# This streaming fixture never writes Git objects, so maintenance is a no-op.
if [ "$1" = "repack" ] || [ "$1" = "prune" ]; then
exit 0
fi
echo "unsupported fake git invocation: $*" >&2
exit 1
"#