From ce3b1bb3efbd78c59d97c8ddff4e61e6b8be3371 Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Sun, 29 Nov 2026 11:15:58 -0500 Subject: [PATCH] Release v0.3.3 Upgrading - Re-seed your goldens with seed --force to pick up the PackageCache fix below. Goldens and worktrees made with v0.3.2 keep working, but worktrees hydrated from an old golden still reinstall their packages on Unity 6000.7 and 7000.0. Added - doctor, hydrate and list warn when a Library/ holds player-build state made in another checkout. uwt never clones Bee or BurstCache, but a Library/ copied in by hand brings them, and so does moving a project after it has built a player. Unity does not notice, and a player built on a copied BurstCache can run the other checkout's version of a changed Burst job. hydrate --json reports it as foreign_build_state (a list of entry and from), and list shows a foreign-build-state tag and a list --json field of the same name. Fix it with hydrate --force, or delete Library/Bee, BurstCache, BuildCache and ScriptAssemblies with the editor closed. It is a warning, never a refusal, and it only sees a Library/ in which a player has been built. Changed - The README and SKILL.md say up front which Unity versions are tested: 6.0 LTS, 6.3 LTS, 6.6, 6.7 (beta) and 7.0 (alpha). SKILL.md gives the import count and disk per version, and what differs between them. 2022.3 and earlier probably work, since the mechanism is the same and the script does not check the version, but they have not been tested. - The README charts disk and time per extra worktree against project size. - The docs no longer say a first open always re-creates 0.8-1.0 GiB of package binaries. With Library/PackageManager cloned, 6000.7.0b10 re-creates none, and Bee and BurstCache are the main first-open cost. Fixes - Library/PackageManager is now cloned instead of denied. From Unity 6000.7.0b10 and 7000.0 (UPM 9.36) the package manager keeps an install record there, and without it the first open of a worktree reinstalls every non-module package, so PackageCache stops being shared. On the URP sample a worktree's private PackageCache after the first open went from 968 to 111 MiB. The editor ignores the golden's cached paths and re-resolves the worktree in about a second. No change on 6000.3, which has no install record. - hydrate --force checks for a running editor again after the clone, before the swap. On macOS and Linux an editor that opened the project during the clone was left on a Library that was then deleted. It now exits 3 (editor_busy) and leaves the old Library in place. - macOS and Linux: a dangling symlink at the top level of a cloned directory was dropped instead of cloned. --- .gitattributes | 1 + .github/workflows/tests.yml | 4 +- README.md | 105 +++++++++++------- docs/worktree-cost-dark.svg | 61 ++++++++++ docs/worktree-cost-light.svg | 61 ++++++++++ skills/unity-worktree-cow/SKILL.md | 97 ++++++++++++---- .../scripts/unity-worktree-cow.sh | 81 +++++++++++++- tests/README.md | 5 +- tests/run-tests.sh | 72 +++++++++++- 9 files changed, 415 insertions(+), 72 deletions(-) create mode 100644 docs/worktree-cost-dark.svg create mode 100644 docs/worktree-cost-light.svg diff --git a/.gitattributes b/.gitattributes index 48956e0..ee19d20 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,4 +4,5 @@ *.sh text eol=lf *.json text eol=lf *.md text eol=lf +*.svg text eol=lf *.yml text eol=lf diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b7abe09..69cbaa0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Show environment shell: bash run: | @@ -44,7 +44,7 @@ jobs: matrix: fs: [btrfs, xfs, zfs] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Make a loopback ${{ matrix.fs }} volume shell: bash run: | diff --git a/README.md b/README.md index c28d443..514b282 100644 --- a/README.md +++ b/README.md @@ -12,36 +12,59 @@ private `Library/`; only the disk blocks are shared, and they diverge on write. Unity Version Control (Plastic) workspaces work the same way, with `cm` doing the reconciling; see `SKILL.md`. -Measured per worktree on Windows 11, ReFS: - -| project | plain checkout + its own Library | `uwt new` | after first open + work | -|---|---|---|---| -| asset-heavy, 41k files | 33.7 GiB · 94 s + 573 s import | 344 MiB · 29 s | 1.98 GiB · **17×** | -| monorepo subdir, 39k files | 16.3 GiB · 46 s + 370 s | 318 MiB · 28 s | 1.31 GiB · **12×** | -| URP sample, 3k files | 3.4 GiB · 4 s + 121 s | 124 MiB · 11 s | 462 MiB · **7.6×** | -| DOTS, code only | 1.1 GiB · 0.2 s + 61 s | 100 MiB · 9 s | 583 MiB · **2.0×** | -| production, 41.5k files, 25 GiB Library | ~31 GiB (estimated) | 405 MiB · 34–40 s | 2.50–2.64 GiB · **~12×** | - -The first four are Unity 6000.7 after a first open and 100 scripted edits; the -fifth is Unity 6000.6 after four agent-driven editors compiled and ran tests in -parallel. All are measured by physical-cluster overlap (`uwt measure`). +Tested with Unity 6.0 LTS, 6.3 LTS, 6.6, 6.7 (beta) and 7.0 (alpha), on +Windows, macOS and Linux. On every one a hydrated worktree opened without a +reimport (0–6 assets imported, against thousands cold); `SKILL.md` has the +figures per version. Earlier versions probably work but are untested (see +Requirements). The measurements below are 6.7 and 6.6, where most of the work +was done. + + + + Disk and time for one more worktree, against project size. A plain worktree costs the whole project: 1.1 to 33.7 GiB and 61 to 668 s. A uwt worktree costs 0.45 to 1.98 GiB and 45 to 132 s. + + +Four projects on Windows 11 (ReFS) with Unity 6.7: a code-only DOTS project +(1.1 GiB), the URP sample (3.4 GiB), a project in a monorepo subdirectory +(16 GiB) and an asset-heavy one (34 GiB, 41k tracked files). Project size is a +plain checkout plus its own imported `Library/`. The uwt line is `uwt new`, a +first open, then 50 scripted code edits and up to 50 material edits, measured +by physical-cluster overlap (`uwt measure`). `SKILL.md` has the table. + +The cost follows the project's file count and code, not its size: + +- A fresh worktree is about one 4 KiB cluster per file: 100–344 MiB here, in + 9–29 s. +- The first open adds what Unity regenerates per checkout (`Bee`, + `BurstCache`, and in these runs some `PackageCache` binaries): 0.3–1.6 GiB. + Now that uwt clones `Library/PackageManager`, `PackageCache` stays shared on + 6000.7.0b10 and 7.0, so the first open costs less than charted. +- Assets and their import results stay shared, so the saving grows with the + project: 2.0×, 7.6×, 12× and 17× here. + +Elsewhere: a production project (41.5k files, 25 GiB `Library/`, Unity 6.6) +with four agent-driven editors compiling and running tests in parallel came to +2.50–2.64 GiB per worktree, against an estimated 31 GiB. On macOS +(APFS) the 34 GiB project is 0 MiB +fresh and 1.45 GiB after a first open and 100 edits (23×); `new` takes about +80 s there, because git re-hashes LFS content once per clone. A hydrated worktree opens without a reimport (0–6 assets imported, against 4,035–23,451 cold) but not without a compile: the first open rebuilds every -script assembly and resolves packages, about 400 s on the production project -with four editors opening at once, most of it contention between them, and -about a minute for one editor alone on the test projects. Seed from a clean -checkout: uncommitted edits in the donor reimport in every worktree. -Its cost is about one 4 KiB cluster per file, so it is close -to fixed per project and the saving grows with project size. After the first -open it grows slowly, except that on Unity 6.6+ a texture or model reimport -can turn a whole `DataStore` segment private (0.1–0.5 GiB); see `SKILL.md`. +script assembly and resolves packages. That took 36–104 s for one editor alone +on the four projects above, and about 400 s on the production project with +four editors opening at once, most of it contention between them. Seed from a +clean checkout: uncommitted edits in the donor reimport in every worktree. +After the first open a worktree grows slowly, except that on Unity 6.6+ a +texture or model reimport can turn a whole `DataStore` segment private +(0.1–0.5 GiB); see `SKILL.md`. Before 6.6 the per-file `Library/Artifacts/` +keeps superseded artifacts shared. ## Install -Copy `skills/unity-worktree-cow/` into the Unity project's repo, in the folder -your agent reads skills from, and commit it: `uwt new` resets every worktree to -its branch, so an uncommitted skill does not reach the worktrees it creates. +`npx skills add Unity-Technologies/unity-worktree-cow` (the `skills` CLI) +installs it for most agents. By hand, copy `skills/unity-worktree-cow/` into +the Unity project's repo, in the folder your agent reads skills from: | agent | folder in the repo | |---|---| @@ -49,14 +72,15 @@ its branch, so an uncommitted skill does not reach the worktrees it creates. | Claude Code | `.claude/skills/` | | Copilot in VS Code | `.github/skills/` | +Commit it either way: `uwt new` resets every worktree to its branch, so an +uncommitted skill does not reach the worktrees it creates. + Cursor and the Copilot coding agent also read `.claude/skills/`, so a repo used only with those and Claude Code needs just that one. A repo shared with Codex or Gemini as well needs both folders; keep the full skill in one and, in the other, a `SKILL.md` that repeats the frontmatter and points at the first, so there is only one script to update. -`npx skills add Unity-Technologies/unity-worktree-cow` (the `skills` CLI) does the copy for most agents. - An agent without skill support can be pointed at it from `AGENTS.md`: ```markdown @@ -81,7 +105,7 @@ $uwt remove path/to/wt # git worktree remove, refused while an editor has $uwt measure # private disk of every worktree and the golden ``` -`list`, `new`, `remove` and `measure` take `--json` for agents: one record on stdout, +`list`, `new`, `hydrate`, `remove` and `measure` take `--json` for agents: one record on stdout, human output on stderr. `new` is safe to run concurrently. `SKILL.md` has a recipe for one editor per worktree. @@ -94,22 +118,25 @@ an editor is using the project. A filesystem that block-clones, with the repo and the worktrees on the same volume: -- **Windows** — ReFS (Dev Drive) on Windows 11 24H2 or later. NTFS cannot. -- **macOS** — APFS. Suite green; measured end to end on the 41k-file project: a fresh worktree is 0 MiB private, 1.45 GiB after a first open - and 100 edits, against 33.8 GiB for a plain checkout plus cold import - (23×). `new` takes 80 s there, 69 s of it the verify `git status` - re-hashing 23.5 GB of LFS content once, because every clone has a new - inode. Windows skips that; see `SKILL.md` Troubleshooting. -- **Linux** — btrfs, XFS with `reflink=1`, or ZFS ≥ 2.2 (where `measure` - refuses: ZFS does not report physical extents). ext4 cannot. +- **Windows**: ReFS (Dev Drive) on Windows 11 24H2 or later. NTFS cannot. +- **macOS**: APFS. +- **Linux**: btrfs, XFS with `reflink=1`, or ZFS ≥ 2.2. ext4 cannot. On anything else `doctor` says so and the tool refuses. There is no copy fallback: a byte copy of the project is the problem this exists to avoid. -Dependencies are bash, git and coreutils. Windows adds robocopy and fsutil, -both in-box. Plastic workspaces need `cm` on `PATH`. `measure` alone also needs PowerShell on Windows (in-box) or -`python3` elsewhere, because reading physical extents needs ioctls. The editor interlock needs nothing extra: a rename probe on -Windows, a `/proc` scan on Linux, `lsof` on macOS. +Tested with Unity 6.0 LTS, 6.3 LTS, 6.6, 6.7 (beta) and 7.0 (alpha), on +Windows 11 (ReFS), macOS (APFS) and Linux (btrfs, XFS). 2022.3 and earlier +probably work: the mechanism is the same and the script does not check the +version, but they have not been tested. It needs an Asset Database v2 Library +(`Library/ArtifactDB`, Unity 2019.3 on); `seed` refuses one without it. + +Dependencies are bash, git and coreutils, plus: + +- Windows: robocopy and fsutil, both in-box. +- Plastic workspaces: `cm` on `PATH`. +- `measure` only: PowerShell on Windows (in-box) or `python3` elsewhere, to + read physical extents. It refuses on ZFS, which does not report them. ## Documentation diff --git a/docs/worktree-cost-dark.svg b/docs/worktree-cost-dark.svg new file mode 100644 index 0000000..3d96b2a --- /dev/null +++ b/docs/worktree-cost-dark.svg @@ -0,0 +1,61 @@ + +Cost of one more Unity worktree, plain against uwt, by project size +Two line charts against project size from 1.1 to 33.7 GiB. Disk per extra worktree: 1.1, 3.4, 16.3, 33.7 GiB plain against 0.57, 0.45, 1.31, 1.98 GiB with uwt. Time to a usable worktree: 61, 126, 415, 668 s plain against 45, 54, 81, 132 s with uwt. +Disk per extra worktree GiB + +0 + +10 + +20 + +30 +0 +10 +20 +30 +project size, GiB + + + + + + + + + + +33.7 GiB +1.98 GiB, 17× less +12× less +Time to a usable worktree seconds + +0 + +250 + +500 +0 +10 +20 +30 +project size, GiB + + + + + + + + + + +668 s +132 s, 5× faster + + +plain worktree with its own Library + + +uwt worktree + diff --git a/docs/worktree-cost-light.svg b/docs/worktree-cost-light.svg new file mode 100644 index 0000000..5efa70a --- /dev/null +++ b/docs/worktree-cost-light.svg @@ -0,0 +1,61 @@ + +Cost of one more Unity worktree, plain against uwt, by project size +Two line charts against project size from 1.1 to 33.7 GiB. Disk per extra worktree: 1.1, 3.4, 16.3, 33.7 GiB plain against 0.57, 0.45, 1.31, 1.98 GiB with uwt. Time to a usable worktree: 61, 126, 415, 668 s plain against 45, 54, 81, 132 s with uwt. +Disk per extra worktree GiB + +0 + +10 + +20 + +30 +0 +10 +20 +30 +project size, GiB + + + + + + + + + + +33.7 GiB +1.98 GiB, 17× less +12× less +Time to a usable worktree seconds + +0 + +250 + +500 +0 +10 +20 +30 +project size, GiB + + + + + + + + + + +668 s +132 s, 5× faster + + +plain worktree with its own Library + + +uwt worktree + diff --git a/skills/unity-worktree-cow/SKILL.md b/skills/unity-worktree-cow/SKILL.md index 49b433c..6a249d6 100644 --- a/skills/unity-worktree-cow/SKILL.md +++ b/skills/unity-worktree-cow/SKILL.md @@ -25,12 +25,13 @@ Measured per worktree on Windows 11, ReFS: | DOTS, code only | 1.1 GiB · 0.2 s + 61 s | 100 MiB · 9 s | 583 MiB · **2.0×** | | production, 41.5k files, 25 GiB Library | ~31 GiB (estimated) | 405 MiB · 34–40 s | 2.50–2.64 GiB · **~12×** | -The first four are Unity 6000.7, "work" being a first open plus 100 scripted -code and material edits. The fifth is Unity 6000.6 with four agent-driven +The first four are Unity 6000.7.0b3, "work" being a first open, 50 scripted code +edits and 50 material edits (3 on the DOTS project, all it has). The fifth is Unity 6000.6 with four agent-driven editors compiling and running tests in parallel. All are measured by physical-cluster overlap (`uwt measure`). Four editors compiling and running tests at once on the first four projects ended within 2% of the scripted figures or below them -(2.01–2.02 GiB on the 41k-file project). +(2.01–2.02 GiB on the 41k-file project). Other editor versions are under +"Unity versions" below. A hydrated worktree opens with 0–6 assets imported, against 4,035–23,451 cold. That is not a free open: the first one compiles every script assembly and @@ -42,8 +43,8 @@ that is the editors contending with each other, not the clone: on the 41k-file project one editor alone spends 39 s in `CompileScripts` and 7 s in `ImportOutOfDateAssets`, four at once 160–168 s and 17–41 s. Still much faster than a cold import, but budget minutes, not seconds, and stagger first opens -when disk or CPU is tight. As a range: 42–66 s for one editor alone on the -test projects, up to ~7 minutes with four at once on the production one. +when disk or CPU is tight. As a range: 36–104 s for one editor alone on the +four projects above, up to ~7 minutes with four at once on the production one. The 0–6 figure assumes a golden seeded from a clean checkout. The Library is imported from the donor's working tree, so whatever the worktree does not @@ -53,12 +54,16 @@ checkout near the branches you will work on. `Search` is denied too, so the editor rebuilds its index in the background after the refresh; that is separate from the first-open times above. -The first open is also where the private cost comes from. The largest item is -usually `PackageCache`: Unity re-creates a fixed set of large package binaries -(executables in `~` folders such as `com.unity.ai.assistant/RelayApp~/relay_win.exe`) -byte-identical but in fresh blocks, 0.8–1.0 GiB on projects that carry them -and nothing on projects that do not. Then `Bee` and `BurstCache` regenerating -(~0.3 and 0.2–0.4 GiB). After that, code, material, shader, prefab and scene +The first open is also where the private cost comes from: `Bee` and +`BurstCache` regenerating (~0.3 and 0.2–0.4 GiB). Up to 6000.7.0b3 the largest +item was usually `PackageCache`: Unity re-created a fixed set of large package +binaries (executables in `~` folders such as +`com.unity.ai.assistant/RelayApp~/relay_win.exe`) byte-identical but in fresh +blocks, 0.3–1.0 GiB on projects that carry them. On 6000.7.0b10, with +`Library/PackageManager` cloned, it re-creates none: the monorepo project's +`PackageCache` stayed at 139 MiB through the first open, which cost 416 MiB +against 729 on b3, and the worktree ended the same work at 1.02 GiB (16×). +After that, code, material, shader, prefab and scene edits grow a worktree slowly (+17 to +77 MiB over a second open and 250 edits). @@ -118,21 +123,39 @@ outcomes apart: | Outcome | Record | |---|---| | Library cloned from the golden | `ok`, `value.action` = `hydrated` | -| A Library was already there | `ok`, `value.action` = `kept`; `value.library` is `uwt` or `other` | +| A Library was already there | `ok`, `value.action` = `kept`; `value.library` is `uwt` or `other`; `value.foreign_build_state` lists build state made in another checkout (below), empty when there is none | | No snapshot yet | `error`, exit 2, `reason` = `no_golden` | | Editor has the project open | `error`, exit 3, `reason` = `editor_busy` | | Volume cannot clone | `error`, exit 2, `reason` = `unsupported_volume` | | Worktree and golden on different volumes | `error`, exit 2, `reason` = `different_volume` | +### A `Library/` copied in by hand + +uwt never clones `Bee` or `BurstCache`, but a `Library/` copied from another +checkout brings them, and so does moving a project after it has built a +player. Unity does not notice: Bee records the project path in each player +DAG's input file and Burst records it in its cache manifest, and a build at the +new path rewrites neither. `doctor`, `hydrate` and `list` read those two +records and report any that name another checkout: + +``` +! Library/BurstCache holds player-build state made in another checkout: /work/slot-1 +``` + +The fix is to delete `Library/Bee`, `BurstCache`, `BuildCache` and +`ScriptAssemblies` in that worktree with the editor closed, or to run +`hydrate --force`. It is a warning, never a refusal, and it only sees a +`Library/` in which a player has been built. + ## Commands | command | what it does | |---|---| -| `doctor [PATH]` | Proves this volume block-clones by doing one and reading the refcount back. Checks the golden and cache root are on the project's volume, which open-file check the interlock will use, whether an editor is live, and the golden's state. Warns on Windows when long paths are off. | +| `doctor [PATH]` | Proves this volume block-clones by doing one and reading the refcount back. Checks the golden and cache root are on the project's volume, which open-file check the interlock will use, whether an editor is live, and the golden's state. Warns on Windows when long paths are off, and when the `Library/` holds build state made in another checkout. | | `seed [PATH] [--force]` | Snapshots the working tree and `Library/` (minus the deny list) plus the git index. Refuses while an editor or Data Store has the project open. Cheap; re-run after editor upgrades. | | `new BRANCH [--path DIR] [--base REF] [--inherit-untracked] [--init-submodules] [--verify] [--json]` | `git worktree add --no-checkout`, clone the snapshot, hand git the snapshot's index, `reset --hard` to the branch, verify zero tracked differences, clean inherited untracked files, hydrate `Library/`. Refuses before registering anything if the volume cannot clone, or if it folds case and the branch has paths that collide by case. Rolls back on failure. | -| `hydrate [PATH] [--force] [--json]` | Gives an existing worktree a `Library/` cloned from the golden. One that already has a `Library/` is left alone (exit 0); `--force` replaces it, and keeps the old one until the new one is in place. | -| `list [PATH] [--json]` | Every worktree of the repo, including ones uwt did not create, with its branch, lock state, and whether its `Library/` came from uwt (`uwt`), from an editor (`other`), or is absent (`none`). | +| `hydrate [PATH] [--force] [--json]` | Gives an existing worktree a `Library/` cloned from the golden. One that already has a `Library/` is left alone (exit 0), with a warning if it holds build state made in another checkout; `--force` replaces it, and keeps the old one until the new one is in place. | +| `list [PATH] [--json]` | Every worktree of the repo, including ones uwt did not create, with its branch, lock state, and whether its `Library/` came from uwt (`uwt`), from an editor (`other`), or is absent (`none`), and a `foreign-build-state` tag where it applies. | | `measure [PATH...] [--by N] [--json]` | Private disk of each worktree and the golden against all the others, by physical-block overlap, with the largest private groups. Read-only. See "Measuring it yourself". | | `remove PATH [--force] [--delete-branch] [--json]` | `git worktree remove` behind the editor interlock. A dirty worktree needs `--force`; a locked one needs `git worktree unlock` first. The branch is kept, or with `--delete-branch` deleted as `git branch -d` would, only when it holds no work of its own. Refuses the main worktree. | @@ -151,8 +174,8 @@ stderr and stdout carries exactly one record, either `{"status":"error","exit":2,"reason":"no_golden","message":"..."}`. `reason` is there when the failure is one a script can act on: `no_golden`, `editor_busy`, `unsupported_volume`, `different_volume`, `other_project`. -`hydrate`'s value has `project`, `action`, `library`, `build_target` and -`seconds`. `new`'s value has `path`, +`hydrate`'s value has `project`, `action`, `library`, `build_target`, +`foreign_build_state` and `seconds`. `new`'s value has `path`, `project`, `uwt` (this script's absolute path), `branch`, `head`, `seconds`, `verified` and `submodules_uninitialized`; `remove`'s has `path`, `branch` and `branch_deleted`. @@ -180,6 +203,35 @@ do-it-yourself version of this goes wrong: robocopy on NTFS or on a pre-24H2 build, `cp` without `--reflink`, or a cross-volume target all copy 24 GiB and say nothing. +### Unity versions + +Every version below has opened a hydrated worktree without a reimport. Private disk is per worktree, after its first open. + +| Unity | build | platform | project | imports, cold → hydrated | after first open | plain checkout | +|---|---|---|---|---|---|---| +| 6.0 LTS | 6000.0.84f1 | Linux, btrfs | URP sample | 5,597 → 1 | 204 MiB | 3,537 MiB | +| 6.3 LTS | 6000.3.25f1 | Linux, btrfs | URP sample | 5,809 → 1 | 183 MiB | 3,773 MiB | +| 6.3 LTS | 6000.3.29f1 | Windows, ReFS | 3D (URP) template | 4,439 → 0 | | | +| 6.6 | 6000.6.4f1 | Windows, ReFS | production, four agents | ~5 | 2.50–2.64 GiB | ~31 GiB (estimated) | +| 6.7 (beta) | 6000.7.0a4 to b10 | Windows, macOS, Linux | the four projects above | 0–6 | see the first table | | +| 7.0 (alpha) | 7000.0.0a20 | Windows, ReFS | URP sample | 5,930 → 1 | 380 MiB | 3,476 MiB | + +What changes between versions is the Library, not the tool: + +- **Before 6.6** artifacts are per-file, in `Library/Artifacts/`, and a + reimport leaves the superseded ones shared: 50 texture reimports cost + +51 MiB on 6.0 and 6.3. From 6.6 they are packed into `DataStore`, which + compacts (see above). +- **From package manager 9.36** (6000.7.0b10, 7.0) installs are recorded in + `Library/PackageManager`. uwt clones it; without it every first open + reinstalls the packages and `PackageCache` stops being shared. + +2022.3 and earlier probably work: the mechanism is the same, and nothing in +the script checks the version. They have not been tested. uwt needs an Asset +Database v2 Library (`Library/ArtifactDB`, Unity 2019.3 on); `seed` refuses +one without it. On an untested version, run `doctor`, then `seed`, `new` and +an editor open, and check the import count and `measure` before relying on it. + ## Unity Version Control (Plastic) Plastic workspaces get the same commands. uwt picks git or Plastic by the @@ -320,14 +372,15 @@ by the first build. - **Denied**: `Bee`, `BurstCache`, `BuildCache` (build-system state keyed by absolute path), `ScriptAssemblies` (compiled output of *this* branch's - scripts), `PackageManager` (regenerated from the lock file), `Search`, - `TempArtifacts` (indexes derived from the artifact DB). + scripts), `Search`, `TempArtifacts` (indexes derived from the artifact DB). - **Never**: `EditorInstance.json`, `ProtocolInstance.json`, `Pipeline/`, `*.pid`, `*-lock`, `uds.lock`, `*.index-lock`. These identify or lock a running editor; they are stripped after every clone. -- **Everything else is cloned**: `PackageCache`, `DataStore`, `ArtifactDB`, - `SourceAssetDB`, `ShaderCache`, the `Build*` settings, `PlayerDataCache`, - per-user UI state. The `Build*` files are the best value per byte: they +- **Everything else is cloned**: `PackageCache`, `PackageManager` (its install + record is what stops the package manager reinstalling `PackageCache`), + `DataStore`, `ArtifactDB`, `SourceAssetDB`, `ShaderCache`, the `Build*` + settings, `PlayerDataCache`, per-user UI state. The `Build*` files are the + best value per byte: they carry the active build target, so the worktree opens on the same platform without a platform-switch reimport. diff --git a/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh b/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh index 81042fd..cecd899 100644 --- a/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh +++ b/skills/unity-worktree-cow/scripts/unity-worktree-cow.sh @@ -41,7 +41,10 @@ esac # output of THIS branch's scripts, and indexes derived from the artifact DB. # They are also all cheap to rebuild, so denying them costs almost nothing. # (Bee was measured directly: grafting it ships the donor's compiled output.) -LIBRARY_DENY="Bee BurstCache BuildCache ScriptAssemblies PackageManager Search TempArtifacts" +# PackageManager is not on it: without its install.db, UPM 9.36+ (6000.7, +# 7000.0) reinstalls every package and PackageCache stops being shared. The +# absolute paths it holds are checked by the editor and re-resolved on open. +LIBRARY_DENY="Bee BurstCache BuildCache ScriptAssemblies Search TempArtifacts" # Files that identify or lock a running editor. Copying them cross-wires two # editors or trips LMDB's reader table. Stripped after every Library clone. @@ -315,6 +318,57 @@ build_target() { # build_target # A path in git's form for --json: E:/x on Windows. jpath() { if [ "$OS" = windows ]; then cygpath -m "$1"; else printf '%s' "$1"; fi; } +# Where a Library's player-build state was made. Bee records the project path +# in each player DAG's input file, and Burst records its command line in its +# cache manifest; a later build at another path rewrites neither. A path that +# is not this project means Library/ was copied in from another checkout, or +# the project moved after it built: the state the deny list keeps out of every +# worktree uwt makes, arrived some other way. Measured on 6000.3 with Burst +# 1.8: a player built on such a BurstCache ran the other checkout's Burst code. +has_build_state() { # has_build_state ; exit 0 iff a player was built in its Library + local f + for f in "$1"/Library/Bee/Player*-inputdata.json "$1"/Library/BurstCache/*/BurstCacheManifest.cm; do + [ -f "$f" ] && return 0 + done + return 1 +} +foreign_build_state() { # foreign_build_state -> " " per foreign origin + local proj="$1" lib="$1/Library" entry path + has_build_state "$proj" || return 0 + { LC_ALL=C grep -ahoE '"EditorToLinkerData":"[^"]+"' "$lib"/Bee/Player*-inputdata.json 2>/dev/null + LC_ALL=C grep -ahoE -- '--temp-folder=[^[:cntrl:]]+' "$lib"/BurstCache/*/BurstCacheManifest.cm 2>/dev/null + } | LC_ALL=C awk ' + # Forward slashes, none doubled or trailing. + function clean(p) { gsub(/\\/, "/", p); gsub(/\/+/, "/", p); sub(/\/$/, "", p); return p } + /^"EditorToLinkerData":"/ { + e = "Bee"; p = $0; sub(/^"EditorToLinkerData":"/, "", p); sub(/"$/, "", p) + if (p ~ /\\u/) next # an escaped path this cannot compare: say nothing + p = clean(p); sub(/\/Library\/Bee\/.*$/, "", p) + } + /^--temp-folder=/ { e = "BurstCache"; p = clean(substr($0, 15)); sub(/\/Temp\/Burst$/, "", p) } + { if (p == "" || seen[e " " p]++) next; print e, p }' \ + | while IFS=' ' read -r entry path; do + # The same directory, however it is spelled: a symlinked /var, a Windows + # short name, another case. A path that no longer exists is not this one. + [ "$path" -ef "$proj" ] || printf '%s %s\n' "$entry" "$path" + done +} +warn_foreign_build_state() { # warn_foreign_build_state <"entry path" lines> + local line + while IFS= read -r line; do + [ -n "$line" ] && warn "Library/${line%% *} holds player-build state made in another checkout: ${line#* }" + done <<<"$1" + say " Unity does not notice. With Burst 1.8, a player built on a copied BurstCache ran the other checkout's Burst code." + say " With the editor closed, delete Library/Bee, BurstCache, BuildCache and ScriptAssemblies here; Unity rebuilds them." +} +foreign_json() { # foreign_json <"entry path" lines> -> JSON array + local line out="" + while IFS= read -r line; do + [ -n "$line" ] && out="$out${out:+,}{\"entry\":\"${line%% *}\",\"from\":$(json_str "${line#* }")}" + done <<<"$1" + printf '[%s]' "$out" +} + fs_type() { case "$OS" in windows) df -T "$1" 2>/dev/null | awk 'NR==2{print $2}' ;; # Git Bash df knows refs/ntfs; fsutil needs admin @@ -381,7 +435,9 @@ cow_tree() { # cow_tree [--globs] [exclude-name...] fi mkdir -p "$dst" || return 1 for e in "$src"/* "$src"/.[!.]*; do - [ -e "$e" ] || continue + # Skips a glob that matched nothing. -e follows links, so a dangling + # symlink needs -L to count as the entry it is. + [ -e "$e" ] || [ -L "$e" ] || continue local n; n="$(basename "$e")"; skip=0 for x in "$@"; do [ "$n" = "$x" ] && skip=1; done # shellcheck disable=SC2254 @@ -551,6 +607,12 @@ cmd_doctor() { say " unity=$(golden_field "$gd" unity_version) commit=$(golden_field "$gd" commit | cut -c1-10) created=$(golden_field "$gd" created) files=$(golden_field "$gd" files) build_target=$(build_target "$gd/Library")" [ "$(golden_field "$gd" unity_version)" = "$(unity_version "$proj")" ] || warn "golden was captured under a different editor version than this checkout declares; re-seed after upgrades" else say " none yet - run: uwt seed (with the editor closed)"; fi + say ""; head_ "build state" + local fb; fb="$(foreign_build_state "$proj")" + if [ -n "$fb" ]; then warn_foreign_build_state "$fb" + elif has_build_state "$proj"; then + good "the player-build state in Library/ was made in this checkout" + else say " no player-build state in Library/"; fi say ""; head_ "not offered, on purpose" say " a shared Library via symlink/junction - Unity 6 keeps its lock in Temp/, so two editors get no mutual exclusion" say " hardlinks for the artifact DBs - no copy-on-write; Unity mmap-writes them and would corrupt every sibling" @@ -668,12 +730,13 @@ hydrate_library() { # hydrate_library [] # The end of every hydrate that leaves a Library in place. is # "hydrated" or "kept"; library says who made what is there, as `list` does. hydrate_done() { # hydrate_done - local wt="$1" from=other bt; [ -f "$wt/Library/.uwt-hydration.txt" ] && from=uwt - bt="$(build_target "$wt/Library")" + local wt="$1" from=other bt fb; [ -f "$wt/Library/.uwt-hydration.txt" ] && from=uwt + bt="$(build_target "$wt/Library")"; fb="$(foreign_build_state "$wt")" if [ "$2" = kept ]; then good "Library/ already exists ($([ $from = uwt ] && echo "hydrated by uwt" || echo "not from uwt")); left as it is. Pass --force to replace it from the golden." + [ -z "$fb" ] || warn_foreign_build_state "$fb" fi - json_ok hydrate "{\"project\":$(json_str "$(jpath "$wt")"),\"action\":\"$2\",\"library\":\"$from\",\"build_target\":$(json_str "$bt"),\"seconds\":$(( $(now) - $3 ))}" + json_ok hydrate "{\"project\":$(json_str "$(jpath "$wt")"),\"action\":\"$2\",\"library\":\"$from\",\"build_target\":$(json_str "$bt"),\"foreign_build_state\":$(foreign_json "$fb"),\"seconds\":$(( $(now) - $3 ))}" exit $EXIT_OK } @@ -699,6 +762,10 @@ cmd_hydrate() { local why; why="$(cow_probe "$wt")" || REASON=unsupported_volume die "this volume cannot block-clone ($why)" if [ -d "$lib" ]; then hydrate_library "$gd" "$wt" "$new" || die "hydrate failed; the existing Library/ is untouched" + # The clone takes long enough for an editor to have opened the project. + # Off Windows the move below succeeds under it, and the editor is left + # running on a Library that is then deleted. + ( require_editor_closed "$wt" hydrate ) || { local rc=$?; rm -rf "$new"; exit $rc; } mv "$lib" "$old" || { rm -rf "$new"; die "could not move the existing Library/ aside; it is untouched"; } mv "$new" "$lib" || { mv "$old" "$lib"; rm -rf "$new"; die "could not put the new Library/ in place; the previous one is restored"; } rm -rf "$old" || warn "the new Library/ is in place, but $old could not be deleted; delete it by hand" @@ -1043,8 +1110,10 @@ cmd_list() { if [ -f "$lib/.uwt-hydration.txt" ]; then state=uwt; gc="$(grep -m1 '^golden_commit=' "$lib/.uwt-hydration.txt" | cut -d= -f2-)" elif [ -d "$lib" ]; then state=other; fi local main=false; [ $first = 1 ] && main=true - rows="$rows$([ $first = 1 ] || printf ,){\"path\":$(json_str "$wt"),\"head\":$(json_str "$head"),\"branch\":$([ -n "$br" ] && json_str "$br" || printf null),\"main\":$main,\"locked\":$locked,\"prunable\":$prunable,\"library\":\"$state\",\"golden_commit\":$([ -n "$gc" ] && json_str "$gc" || printf null)}" + local foreign=false; [ $state = none ] || [ -z "$(foreign_build_state "$wt${pre:+/$pre}")" ] || foreign=true + rows="$rows$([ $first = 1 ] || printf ,){\"path\":$(json_str "$wt"),\"head\":$(json_str "$head"),\"branch\":$([ -n "$br" ] && json_str "$br" || printf null),\"main\":$main,\"locked\":$locked,\"prunable\":$prunable,\"library\":\"$state\",\"foreign_build_state\":$foreign,\"golden_commit\":$([ -n "$gc" ] && json_str "$gc" || printf null)}" local tags="library=$state"; [ $main = true ] && tags="$tags main" + [ $foreign = true ] && tags="$tags foreign-build-state" [ $locked = true ] && tags="$tags locked"; [ $prunable = true ] && tags="$tags prunable" printf '%s %-28s %s\n' "$wt" "${br:-(detached ${head:0:10})}" "$tags" first=0 diff --git a/tests/README.md b/tests/README.md index 9c90eae..80b17a5 100644 --- a/tests/README.md +++ b/tests/README.md @@ -21,10 +21,11 @@ Synthetic fixtures: a fake git repo shaped like a Unity project with a fake | group | covers | |---|---| | 1 | `doctor` resolves the project from a subdirectory and reports state | -| 2 | `seed` snapshots the tracked tree and `Library`, applies the deny list and the never-list, leaves the source alone, honours `--force`, rejects an empty `ArtifactDB` | +| 2 | `seed` snapshots the tracked tree and `Library`, applies the deny list and the never-list, leaves the source alone, honours `--force`, rejects an empty `ArtifactDB`, keeps a dangling top-level symlink (Linux and macOS) | | 3 | the interlock refuses while a database is held open by another process (Linux and macOS) and while it is memory-mapped with the fd already closed, the way LMDB holds it (Linux; python3 builds the mapping); `doctor` names the open-file mechanism; a dead pid does not block. Windows needs a real editor, see below | | 4 | `new` registers, clones, reconciles to the target branch (same-commit and cross-branch), cleans inherited untracked files, honours `--path`, `--base`, `--inherit-untracked`, checks out an existing branch, gives committed content for files the source hides behind `assume-unchanged`/`skip-worktree`, and refuses before registering when it cannot proceed | -| 5 | `hydrate` fills a plain worktree, refuses to overwrite without `--force`, warns on a Unity version mismatch | +| 5 | `hydrate` fills a plain worktree, refuses to overwrite without `--force`, warns on a Unity version mismatch; `--force` refuses (exit 3) when the project is opened while the replacement is being cloned (Linux and macOS) | +| 5b | `doctor`, `hydrate` and `list` report a `Library/` whose Bee player DAG or Burst cache manifest names another checkout, and pass one that names its own under any spelling (another case, a symlink, a Windows short name) or has none | | 6 | CLI errors exit 2 | | 7 | a project in a subdirectory of its repo: `seed` records the prefix, `new` clones back to it and leaves files outside it to git, `hydrate` given the worktree root finds the project | | 8 | `list` (text and `--json`) and where each `Library` came from; `remove` refuses the main worktree, a non-root path, a dirty worktree without `--force`, and a worktree whose `ArtifactDB` is open (exit 3), and keeps the branch, or with `--delete-branch` deletes it only when it has no commits of its own; `new --json` success and error records; `new --verify` rolls back a snapshot whose content changed behind matching stat data (which plain `new` lets through on Windows), runs its fresh-index pass only on Windows, and a configured `core.checkStat=minimal` does not weaken the check | diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 35ff9c3..8c731bf 100644 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -61,7 +61,7 @@ mkdir -p "$PROJ" && cd "$PROJ" || exit 2 # The branch is named, never left to init.defaultBranch: the groups below return to it by name. git init -q -b main && git config user.email t@t && git config user.name t && git config core.autocrlf false \ || { echo "fixture: git init failed"; exit 2; } -mkdir -p ProjectSettings Assets/Scenes Packages Library/PackageCache/com.x@abc Library/DataStore/00 \ +mkdir -p ProjectSettings Assets/Scenes Packages Library/PackageCache/com.x@abc Library/PackageManager/Cache Library/DataStore/00 \ Library/Bee Library/BurstCache Library/ScriptAssemblies Library/Search Library/Pipeline Library/ShaderCache Temp obj printf 'm_EditorVersion: 6000.7.0b1\nm_EditorVersionWithRevision: 6000.7.0b1 (deadbeef)\n' > ProjectSettings/ProjectVersion.txt echo scene > Assets/Scenes/A.unity; echo '{}' > Packages/manifest.json; echo tracked > README.md @@ -71,6 +71,7 @@ head -c 200000 /dev/urandom > Library/SourceAssetDB head -c 100000 /dev/urandom > Library/DataStore/uds.db head -c 100000 /dev/urandom > Library/DataStore/UDSData_3.bin echo pkg > Library/PackageCache/com.x@abc/package.json +echo '{"packages":{"com.x":{"fingerprint":"abc"}}}' > Library/PackageManager/install.db; echo sig > Library/PackageManager/Cache/sig echo dag > Library/Bee/x.dag; echo burst > Library/BurstCache/b.dll; echo dll > Library/ScriptAssemblies/a.dll echo idx > Library/Search/i.index; echo pipe > Library/Pipeline/p; echo sc > Library/ShaderCache/s.bin # The smallest EditorUserBuildSettings.asset uwt reads the build target from: @@ -119,6 +120,8 @@ if [ $CLONES = 1 ]; then check "cloned: ArtifactDB, SourceAssetDB, DataStore, PackageCache, ShaderCache" \ nonempty "$GD/Library/ArtifactDB" "$GD/Library/SourceAssetDB" "$GD/Library/DataStore/uds.db" \ "$GD/Library/PackageCache/com.x@abc/package.json" "$GD/Library/ShaderCache/s.bin" + check "cloned: PackageManager, whose install.db keeps PackageCache shared" \ + nonempty "$GD/Library/PackageManager/install.db" "$GD/Library/PackageManager/Cache/sig" check "denied: Bee, BurstCache, ScriptAssemblies, Search" \ absent "$GD/Library/Bee" "$GD/Library/BurstCache" "$GD/Library/ScriptAssemblies" "$GD/Library/Search" check "never-files stripped: EditorInstance.json, *-lock, *.pid, Pipeline/" \ @@ -128,6 +131,15 @@ if [ $CLONES = 1 ]; then check "seed --force republishes" bash -c "touch -d '2000-01-01' '$GD.txt'; bash '$UWT' seed '$PROJ' --force >/dev/null && [ \"\$(find '$GD.txt' -newermt '2001-01-01')\" ]" check "seed refuses an empty ArtifactDB" bash -c "cp -r '$PROJ' '$ROOT/proj-empty' && : > '$ROOT/proj-empty/Library/ArtifactDB'; bash '$UWT' seed '$ROOT/proj-empty' --force; [ \$? = 2 ]" rm -rf "$ROOT/proj-empty" + if [ $WIN = 0 ]; then + # The tree clone walks top-level entries; one that is a dangling symlink + # still has to be cloned. Re-seeded without it so later groups see the + # fixture they expect. + ln -s nowhere "$PROJ/dangling" + check "a dangling top-level symlink is in the snapshot" bash -c "bash '$UWT' seed '$PROJ' --force >/dev/null 2>&1 && [ -L '$GD/dangling' ]" + rm -f "$PROJ/dangling" + uwt seed "$PROJ" --force >/dev/null 2>&1 || { echo "fixture: re-seed failed"; exit 2; } + fi else check "seed refuses on a non-cloning volume with exit 2" [ $rc = 2 ] check "seed says why" grep -qi 'cannot block-clone' <<<"$out" @@ -173,6 +185,7 @@ if [ $CLONES = 1 ]; then check "inherited untracked file was cleaned" [ ! -e "$WT/scratch.txt" ] check "Library hydrated with a stamp" nonempty "$WT/Library/ArtifactDB" "$WT/Library/.uwt-hydration.txt" check "Library has no denied or never entries" absent "$WT/Library/Bee" "$WT/Library/EditorInstance.json" + check "Library carries the package install record" nonempty "$WT/Library/PackageManager/install.db" "$WT/Library/PackageManager/Cache/sig" check "Library is writable" bash -c "echo x >> '$WT/Library/ArtifactDB'" check "new refuses an existing path" bash -c "bash '$UWT' new feature/y --path '$WT' >/dev/null 2>&1; [ \$? = 2 ]" check "existing branch is checked out, not recreated" bash -c "bash '$UWT' new keep --path '$ROOT/wt-keep' >/dev/null 2>&1 && [ \"\$(git -C '$ROOT/wt-keep' branch --show-current)\" = keep ]" @@ -268,6 +281,21 @@ if [ $CLONES = 1 ]; then check "and leaves the existing Library byte-identical" bash -c "cmp -s '$ROOT/plain/Library/ArtifactDB' '$ROOT/plain-adb' && [ -f '$ROOT/plain/Library/MINE' ]" check "and leaves no staging directory" absent "$ROOT/plain/Library.uwt-new" "$ROOT/plain/Library.uwt-old" done + # An editor that opens the project while the replacement is being cloned is + # caught before the swap. Forced the same way: the real cp, then an fd held + # open on the existing ArtifactDB. Not on Windows, for the reason group 3 gives. + if [ $WIN = 0 ]; then + mkdir -p "$SH/editor" + printf '#!/usr/bin/env bash\ncase "$*" in *.uwt-probe*) exec "%s" "$@" ;; esac\n"%s" "$@" || exit 1\n[ -e "%s" ] && exit 0\nexec 9<>"%s"\nsleep 8 >/dev/null 2>&1 & echo $! > "%s"\n' \ + "$(command -v cp)" "$(command -v cp)" "$SH/editor/pid" "$ROOT/plain/Library/ArtifactDB" "$SH/editor/pid" > "$SH/editor/cp" + chmod +x "$SH/editor/cp" + PATH="$SH/editor:$PATH" uwt hydrate "$ROOT/plain" --force >/dev/null 2>&1; rc=$? + holder="$(cat "$SH/editor/pid" 2>/dev/null)" + if [ -n "$holder" ]; then kill "$holder" 2>/dev/null; while kill -0 "$holder" 2>/dev/null; do sleep 0.1; done; fi + check "hydrate --force refuses (exit 3) when an editor opens the project during the clone" [ $rc = 3 ] + check "and leaves the existing Library byte-identical" bash -c "cmp -s '$ROOT/plain/Library/ArtifactDB' '$ROOT/plain-adb' && [ -f '$ROOT/plain/Library/MINE' ]" + check "and leaves no staging directory" absent "$ROOT/plain/Library.uwt-new" "$ROOT/plain/Library.uwt-old" + fi out="$(PATH="$SH/probe:$PATH" uwt hydrate "$ROOT/plain" --force --json 2>/dev/null)" check "a volume that cannot clone is reason unsupported_volume" json_is "d['status']=='error' and d['exit']==2 and d['reason']=='unsupported_volume'" <<<"$out" mv "$ROOT/plain/Library" "$ROOT/plain/Library.uwt-old" && mkdir "$ROOT/plain/Library.uwt-new" @@ -280,6 +308,48 @@ else check "and --json gives the reason no_golden" json_is "d['status']=='error' and d['reason']=='no_golden'" <<<"$out" fi +# ------------------------------------------------------------------ 5b. build state +# Bee and Burst each record the path a player was built at, and a build at +# another path rewrites neither. A Library whose records name another checkout +# was copied in; doctor, hydrate and list say so. Needs no cloning. +group "5b. build state made in another checkout" +git -C "$PROJ" worktree add -q "$ROOT/wt-fbs" -b fbs +FB="$ROOT/wt-fbs"; mkdir -p "$FB/Library/Bee" "$FB/Library/BurstCache/Windows-Intel" +if [ $WIN = 1 ]; then FBM="$(cygpath -m "$FB")"; FBT="$(cygpath -w "$FB")\\Temp\\Burst"; OTHER='D:/builds/slot-1'; OTHERT='D:\builds\slot-2\Temp\Burst' +else FBM="$FB"; FBT="$FB/Temp/Burst"; OTHER='/builds/slot-1'; OTHERT='/builds/slot-2/Temp/Burst'; fi +fb_bee() { printf '{"A":1,"EditorToLinkerData":"%s/Library/Bee/artifacts/UnityLinkerInputs/EditorToUnityLinkerData.json","B":2}' "$1" > "$FB/Library/Bee/Player$2-inputdata.json"; } +fb_burst() { printf '\212bcm\r\n\006\0\001\002\n--temp-folder=%s\n--key-folder=x\n--temp-folder=%s\n' "$@" > "$FB/Library/BurstCache/Windows-Intel/BurstCacheManifest.cm"; } +fb_row() { uwt list "$PROJ" --json 2>/dev/null | json_is "[r for r in d['value'] if r['path'].endswith('wt-fbs')][0]['foreign_build_state'] == $1"; } +fb_bee "$FBM" 0000aaaa; fb_burst "$FBT" "$FBT" +check "doctor passes build state made in this checkout" bash -c "bash '$UWT' doctor '$FB' 2>&1 | grep -q 'was made in this checkout'" +out="$(uwt hydrate "$FB" --json 2>/dev/null)"; rc=$? +check "hydrate keeps the Library and reports none foreign" json_is "d['value']['action']=='kept' and d['value']['foreign_build_state']==[]" <<<"$out" +check "list does not flag it" fb_row False +if [ $WIN = 1 ]; then + fb_burst "$(tr '[:lower:]' '[:upper:]' <<<"$FBT" | sed 's/TEMP.BURST$/Temp\\Burst/')" "$FBT" + check "a path that differs only by case is the same checkout" bash -c "bash '$UWT' doctor '$FB' 2>&1 | grep -q 'was made in this checkout'" +else + # The same directory under another spelling, as macOS's /var and /private/var are. + ln -s "$FB" "$ROOT/wt-fbs-link"; fb_bee "$ROOT/wt-fbs-link" 0000aaaa; fb_burst "$ROOT/wt-fbs-link/Temp/Burst" "$FBT" + check "a path that reaches this checkout through a symlink is the same checkout" bash -c "bash '$UWT' doctor '$FB' 2>&1 | grep -q 'was made in this checkout'" + check "for list as well" fb_row False + rm "$ROOT/wt-fbs-link"; fb_bee "$FBM" 0000aaaa; fb_burst "$FBT" "$FBT" +fi +fb_bee "$OTHER" 1111bbbb # what a build after a copy leaves: the donor's DAG beside its own +out="$(uwt hydrate "$FB" --json 2>/dev/null)"; rc=$? +check "a player DAG from another checkout is reported, exit 0" bash -c "[ $rc = 0 ]" +check "with the Library entry and where it came from" json_is "[(e['entry'], e['from']) for e in d['value']['foreign_build_state']] == [('Bee', '$OTHER')]" <<<"$out" +check "doctor warns and names the directories to delete" bash -c "bash '$UWT' doctor '$FB' 2>&1 | grep -A2 'Library/Bee holds player-build state made in another checkout: $OTHER' | grep -q 'delete Library/Bee, BurstCache'" +check "doctor still exits as it did" bash -c "bash '$UWT' doctor '$FB' >/dev/null 2>&1; a=\$?; bash '$UWT' doctor '$PROJ' >/dev/null 2>&1; [ \$a = \$? ]" +check "list flags it" fb_row True +check "and tags it for a reader" bash -c "bash '$UWT' list '$PROJ' 2>/dev/null | grep 'wt-fbs' | grep -q 'foreign-build-state'" +fb_burst "$OTHERT" "$OTHERT" +check "a Burst cache from another checkout is reported too" \ + json_is "[e['entry'] for e in d['value']['foreign_build_state']] == ['Bee', 'BurstCache'] and d['value']['foreign_build_state'][1]['from'].endswith('builds/slot-2')" <<<"$(uwt hydrate "$FB" --json 2>/dev/null)" +rm -rf "$FB/Library/Bee" "$FB/Library/BurstCache" +check "a Library with no player-build state says so" bash -c "bash '$UWT' doctor '$FB' 2>&1 | grep -q 'no player-build state'" +check "and is not flagged" fb_row False + # ------------------------------------------------------------------ 6. cli group "6. cli" check "unknown command exits 2" bash -c "bash '$UWT' frob >/dev/null 2>&1; [ \$? = 2 ]"