From 1385030fa493cc1bcb303b00d77d0251be999487 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 12 Sep 2026 11:41:20 -0600 Subject: [PATCH] Cover the run Git identity across sandbox providers Add a `sandbox_tests!` scenario that initializes a repository inside the sandbox from a script stage, commits, and prints the author and committer the commit object carries. It runs on the local host and, when the plugin executables are on PATH, on the host and Docker sandbox plugins, with conflicting `GIT_*` variables inherited from the launching shell. Co-Authored-By: Claude Fable 5.1 --- .../tests/it/workflow/git_identity.rs | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/apps/fabro-cli/tests/it/workflow/git_identity.rs b/lib/apps/fabro-cli/tests/it/workflow/git_identity.rs index caddfd6f8..716a13672 100644 --- a/lib/apps/fabro-cli/tests/it/workflow/git_identity.rs +++ b/lib/apps/fabro-cli/tests/it/workflow/git_identity.rs @@ -10,7 +10,10 @@ use fabro_acp::test_support::fake_acp_agent_script; use fabro_test::{TestContext, test_context}; use fabro_types::{EventBody, GitIdentitySource}; -use super::{find_run_dir, read_conclusion, run_events, run_state}; +use super::{ + dump_export, find_run_dir, read_conclusion, run_events, run_id_for, run_state, sandbox_tests, + stage_dump_dir, timeout_for, +}; fn git(dir: &Path, args: &[&str]) -> String { let output = Command::new("git") @@ -276,3 +279,46 @@ fn acp_agent_launch_env_carries_the_run_identity() { }) ); } + +// --------------------------------------------------------------------------- +// The same contract across sandbox providers: a script stage commits in a +// repository it initializes inside the sandbox and reports the identity the +// commit object carries. Runs on the local host, and on the host and Docker +// sandbox plugins when their executables are on PATH. +// --------------------------------------------------------------------------- + +sandbox_tests!(git_identity_in_sandbox); + +fn scenario_git_identity_in_sandbox(context: &TestContext, sandbox: &str) { + context.write_temp( + "sandbox_identity.fabro", + r#"digraph SandboxIdentity { + graph [goal="Commit inside the sandbox as the run identity"] + start [shape=Mdiamond] + work [shape=parallelogram, script="set -e; git init -q identity-probe && cd identity-probe && printf x > x.txt && git add x.txt && git commit -q -m probe && printf 'identity=%s|%s|%s|%s\n' \"$(git log -1 --format=%an)\" \"$(git log -1 --format=%ae)\" \"$(git log -1 --format=%cn)\" \"$(git log -1 --format=%ce)\""] + exit [shape=Msquare] + start -> work -> exit +} +"#, + ); + + context + .run_cmd() + .env("GIT_AUTHOR_NAME", "Inherited Host") + .env("GIT_COMMITTER_EMAIL", "host@example.com") + .args(["--auto-approve", "--environment", sandbox]) + .arg(context.temp_dir.join("sandbox_identity.fabro")) + .timeout(timeout_for(sandbox)) + .assert() + .success(); + + let run_dir = find_run_dir(context); + assert_eq!(read_conclusion(&run_dir)["status"], "succeeded"); + let export_dir = dump_export(context, &run_id_for(&run_dir)); + let output = std::fs::read_to_string(stage_dump_dir(&export_dir, "work@1").join("output.log")) + .expect("work output.log should exist"); + assert!( + output.contains("identity=Fabro|noreply@fabro.sh|Fabro|noreply@fabro.sh"), + "{sandbox}: the sandbox commit should carry the run identity, got: {output}" + ); +}