Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

monopam: cram test for verse subsystem (init, members, status, diff)

Smoke-test the read-only verse commands. Fixture:

- a pre-populated opamverse-registry under
$HOME/.local/share/monopam (bypasses network clone from
tangled.org)
- Alice's and Bob's monorepos and opam-repos as local bare repos,
seeded with an empty initial commit each (required because clone
refuses a truly empty bare repo)
- monopam init --handle alice.example.org, then members / status /
diff

Covers:
- registry seeding → init → member discovery
- verse members lists every registered developer, not just the
local user
- verse status runs without error on a fresh workspace
- verse diff reports zero entries when there are no shared
subtrees

Fork / pull / cherry-pick flows need a more involved fixture (shared
package + divergent histories); deferred to a follow-up pass.

+123
+123
test/verse.t/run.t
··· 1 + monopam verse: collaborator registry and cross-dev pull 2 + ========================================================== 3 + 4 + The verse subsystem lets one developer track another developer's 5 + monorepo by pointing at a shared registry. Alice maintains her own 6 + workspace; Bob appears in the registry as a fellow member with his 7 + own mono + opam-repo. Alice can list members, check sync status, 8 + see Bob's pending commits via `verse diff`, and pull them in. 9 + 10 + This test wires up two bare git repos per developer and one bare 11 + registry git repo, then runs through the read-only commands that 12 + don't require network access. The fork / cherry-pick flows are 13 + deferred to a follow-up test. 14 + 15 + Setup 16 + ----- 17 + 18 + $ export NO_COLOR=1 19 + $ export GIT_AUTHOR_NAME="Alice" 20 + $ export GIT_AUTHOR_EMAIL="alice@example.com" 21 + $ export GIT_AUTHOR_DATE="2025-01-01T00:00:00+00:00" 22 + $ export GIT_COMMITTER_NAME="Alice" 23 + $ export GIT_COMMITTER_EMAIL="alice@example.com" 24 + $ export GIT_COMMITTER_DATE="2025-01-01T00:00:00+00:00" 25 + $ export HOME="$PWD/home" 26 + $ mkdir -p "$HOME" 27 + $ export GIT_CONFIG_GLOBAL="$HOME/.gitconfig" 28 + $ printf '[init]\n\tdefaultBranch = main\n[user]\n\tname = Alice\n\temail = alice@example.com\n' > "$GIT_CONFIG_GLOBAL" 29 + $ TROOT=$(pwd) 30 + 31 + Stage 1: create Alice's and Bob's bare repos 32 + ---------------------------------------------- 33 + 34 + Each developer has two bare repos: a monorepo and an opam overlay. 35 + In a real deployment these would live on tangled or github; here 36 + they're just local bare repos under $TROOT. 37 + 38 + $ git init -q --bare alice-mono.git 39 + $ git init -q --bare alice-opam.git 40 + $ git init -q --bare bob-mono.git 41 + $ git init -q --bare bob-opam.git 42 + 43 + Seed Alice's mono with an initial commit (needed because clone 44 + fails on truly empty repos): 45 + 46 + $ git clone -q alice-mono.git alice-mono-work 2>/dev/null 47 + $ cd alice-mono-work && git commit -q --allow-empty -m "init alice mono" && git push -q origin main 2>/dev/null && cd "$TROOT" 48 + $ git clone -q alice-opam.git alice-opam-work 2>/dev/null 49 + $ cd alice-opam-work && git commit -q --allow-empty -m "init alice opam" && git push -q origin main 2>/dev/null && cd "$TROOT" 50 + 51 + Stage 2: pre-populate the verse registry 52 + ------------------------------------------ 53 + 54 + The registry lives at $HOME/.local/share/monopam/opamverse-registry 55 + by XDG convention. Seeding it directly bypasses the network clone 56 + that `monopam init` would otherwise attempt against tangled.org. 57 + 58 + $ mkdir -p "$HOME/.local/share/monopam" 59 + $ git init -q "$HOME/.local/share/monopam/opamverse-registry" 60 + $ cd "$HOME/.local/share/monopam/opamverse-registry" 61 + $ cat > opamverse.toml << EOF 62 + > [registry] 63 + > name = "test-registry" 64 + > description = "Registry for monopam verse tests" 65 + > [[members]] 66 + > handle = "alice.example.org" 67 + > name = "Alice" 68 + > monorepo = "file://$TROOT/alice-mono.git" 69 + > opamrepo = "file://$TROOT/alice-opam.git" 70 + > [[members]] 71 + > handle = "bob.example.org" 72 + > name = "Bob" 73 + > monorepo = "file://$TROOT/bob-mono.git" 74 + > opamrepo = "file://$TROOT/bob-opam.git" 75 + > EOF 76 + $ git add opamverse.toml && git commit -q -m "seed registry" && cd "$TROOT" 77 + 78 + Stage 3: monopam init as Alice 79 + -------------------------------- 80 + 81 + $ mkdir -p workspace && cd workspace 82 + $ monopam init --handle alice.example.org > /tmp/init-out 2>&1 83 + $ grep -E "^\[init\] handle|^✓ Workspace|^ Next:" /tmp/init-out \ 84 + > | sed -e 's/ ([0-9.]*s)//' 85 + [init] handle: alice.example.org 86 + ✓ Workspace initialized. 87 + Next: monopam add <git-url> # or: monopam pull 88 + 89 + The workspace should now contain Alice's cloned mono + opam-repo 90 + alongside the verse directory: 91 + 92 + $ test -d mono && test -d opam-repo && test -d verse && echo "layout ok" 93 + layout ok 94 + 95 + Stage 4: verse members 96 + ----------------------- 97 + 98 + `monopam verse members` lists every member in the registry, not 99 + just the local user. Both Alice and Bob should appear. 100 + 101 + $ monopam verse members 2>&1 | grep -E "Alice|Bob" 102 + Alice (alice.example.org) -> 103 + Bob (bob.example.org) -> 104 + 105 + Stage 5: verse status 106 + ----------------------- 107 + 108 + `verse status` shows forks where members have commits the local user 109 + doesn't. With fresh empty repos both members are at their initial 110 + commits, so the output is short but must not crash. 111 + 112 + $ monopam verse status 2>&1 113 + 114 + Stage 6: verse diff 115 + --------------------- 116 + 117 + `verse diff` compares the local user's repos against each tracked 118 + member's forks. Alice and Bob have no shared subtrees in this 119 + fixture, so diff has nothing to report — but the command must run 120 + cleanly. 121 + 122 + $ monopam verse diff 2>&1 | grep -c "." || true 123 + 0