| 1 | //! Process-boundary acceptance for delegated coordination (#4647). |
| 2 | //! |
| 3 | //! Typed event/App/Work rendering assertions live beside their production |
| 4 | //! modules, and `qa_pty::real_coordination_details_*` drives the sealed binary. |
| 5 | //! This target retains the real-Git fan-in proof: terminal reconciliation must |
| 6 | //! keep both candidates available instead of reducing them to source strings. |
| 7 | |
| 8 | use std::path::Path; |
| 9 | use std::process::Command; |
| 10 | |
| 11 | use tempfile::tempdir; |
| 12 | |
| 13 | #[test] |
| 14 | fn terminal_retry_fixture_preserves_both_real_git_candidates() { |
| 15 | let repo = tempdir().expect("temp repo"); |
| 16 | git(repo.path(), &["init"]); |
| 17 | git(repo.path(), &["config", "core.autocrlf", "false"]); |
| 18 | git(repo.path(), &["config", "user.name", "codewhale Tests"]); |
| 19 | git(repo.path(), &["config", "user.email", "tests@example.com"]); |
| 20 | git(repo.path(), &["config", "commit.gpgsign", "false"]); |
| 21 | git(repo.path(), &["commit", "--allow-empty", "-m", "base"]); |
| 22 | let base = git_stdout(repo.path(), &["branch", "--show-current"]); |
| 23 | |
| 24 | git(repo.path(), &["switch", "-c", "candidate-a"]); |
| 25 | std::fs::create_dir_all(repo.path().join("src")).expect("src"); |
| 26 | std::fs::write(repo.path().join("src/a.rs"), "pub const A: u8 = 1;\n").expect("candidate A"); |
| 27 | git(repo.path(), &["add", "src/a.rs"]); |
| 28 | git(repo.path(), &["commit", "-m", "candidate A"]); |
| 29 | let candidate_a = git_stdout(repo.path(), &["rev-parse", "HEAD"]); |
| 30 | |
| 31 | git(repo.path(), &["switch", &base]); |
| 32 | git(repo.path(), &["switch", "-c", "candidate-b"]); |
| 33 | std::fs::create_dir_all(repo.path().join("src")).expect("src"); |
| 34 | std::fs::write(repo.path().join("src/b.rs"), "pub const B: u8 = 2;\n").expect("candidate B"); |
| 35 | git(repo.path(), &["add", "src/b.rs"]); |
| 36 | git(repo.path(), &["commit", "-m", "candidate B"]); |
| 37 | let candidate_b = git_stdout(repo.path(), &["rev-parse", "HEAD"]); |
| 38 | |
| 39 | assert_ne!(candidate_a, candidate_b); |
| 40 | assert_eq!( |
| 41 | git_stdout(repo.path(), &["show", "candidate-a:src/a.rs"]), |
| 42 | "pub const A: u8 = 1;" |
| 43 | ); |
| 44 | assert_eq!( |
| 45 | git_stdout(repo.path(), &["show", "candidate-b:src/b.rs"]), |
| 46 | "pub const B: u8 = 2;" |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | fn git(repo: &Path, args: &[&str]) { |
| 51 | let output = Command::new("git") |
| 52 | .args(args) |
| 53 | .current_dir(repo) |
| 54 | .output() |
| 55 | .expect("git command"); |
| 56 | assert!( |
| 57 | output.status.success(), |
| 58 | "git {args:?} failed: {}", |
| 59 | String::from_utf8_lossy(&output.stderr) |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | fn git_stdout(repo: &Path, args: &[&str]) -> String { |
| 64 | let output = Command::new("git") |
| 65 | .args(args) |
| 66 | .current_dir(repo) |
| 67 | .output() |
| 68 | .expect("git command"); |
| 69 | assert!( |
| 70 | output.status.success(), |
| 71 | "git {args:?} failed: {}", |
| 72 | String::from_utf8_lossy(&output.stderr) |
| 73 | ); |
| 74 | String::from_utf8_lossy(&output.stdout).trim().to_string() |
| 75 | } |
| 76 |