buck2 — Engineering Performance
102 engineers all time · Jan 2025 – Nov 2026 · built 2026-11-22 · GitHub
Performance snapshot
Today's rolling 90-day reading for buck2, compared with the start of the series. Pick a window to move that comparison point.
Avg. perf / dev / mo
+914.6%
0.42 → 4.26 ETV
Active engineers
−20.3%
64.0 → 51.0
Features
+4.3pp
30.5% → 34.8%
vs. Meta
1.2x
0.59x → 1.2x · +24% above
buck2 vs. Meta
Per-engineer ETV for buck2 against Meta as a whole. Both lines are 90-day rolling averages scaled to a 30-day month, so they share one axis and can be read against each other at any point. Pick a window to zoom the chart to it.
Performance Composition
Each month's output split by type of work: Features (new value), Maintenance (sustaining systems), Tests, Docs, and Fixes (rework). The yellow line is output per engineer, so when it rises each engineer is delivering more, whatever the team size did. Unit: Engineering Throughput Value (ETV).
Engineering capacity
Effective engineers behind buck2, against its pre-AI baseline. Each subject has its own: buck2's is 0.42 ETV / dev / mo, its first reading in Q1 2025. Per-engineer ETV divided by that gives a capacity multiple, and that multiple applied to the engineers active in the trailing 90 days turns it into engineer-equivalents. The line is the real headcount, so the gap between line and area is what the leverage is worth. Because each baseline is its own, every subject opens at 1.0x on its first day: multiples measure improvement and are not comparable between subjects.
Knowledge concentration
How dependent is this repo on a small number of engineers? Higher top-1 share = higher key-person risk.
Jakob Degen owns 20.8 % of commits.
Behind the numbers
Written summary of the work completed each month.
No monthly reports available yet.
Top engineers
Most impactful commits
Top 10 by ETV in the all-time window.
- 18.4ETVtests/core: pytest → python_unittest Summary: # Stack Context pytest is unsupported at Meta. The buck2 e2e test harness (`fbcode/buck2/tests/e2e_util`, used through `buck_e2e.bzl`) ran its ~500 test modules as `python_pytest` targets. This stack moves the harness and every module on it to `python_unittest`, then deletes the pytest support: a harness that runs tests as `unittest` methods (D124484084), the modules converted in four groups (D124484085 `tests/core`, D124484086 the rest of `buck2/tests`, D124484087 the agentcloud guards, D124484088 everything else), and the removal of the pytest path (D124487800). Test bodies are untouched; test ids change from `test_x.py::test_y[case]` to `pkg.test_x.XTest.test_y_case`. `buck2_core_tests` makes `python_unittest`s, and the 322 modules under `tests/core` are converted with `tools/pytest_to_unittest`: each module's tests move into a `<Module>Test(BuckTestCase)` class and gain `self`; `pytest.mark.parametrize`/`pytest.param` → `parametrize`/`param`; `pytest.raises` → `self.assertRaises` (`assertRaisesRegex` for `match=`, `.value` → `.exception`); `pytest.skip` → `self.skipTest`; `pytest.mark.xfail` → `unittest.expectedFailure`. Done by hand: - Modules that generated tests with `globals()[name] = ...` (`build/test_build_report*.py`, `build/test_artifact_path_sketch.py`, `build/test_build_modifiers_report.py`, `completion/*`, `errors/test_command_report.py`, `errors/test_formatting.py`, `test/test_build_report.py`, `test/test_modifiers.py`): the factory returns the decorated method and the class body assigns it, `test_x = build_report_test("test_x", [...])`. `completion_test` is one method parametrized over the shells; a scenario with a bash-specific expectation gets a `test_x_bash` attribute beside `test_x`, so the test ids stay what they were. - `build/actions/test_http_proxy_env.py`: the autouse `monkeypatch` fixture is a `setUp` that patches `os.environ`. - `build/test_artifact_path_sketch.py`, `build/test_detailed_aggregated_metrics.py`: `pytest.approx` → `helper.utils.approx`. - `build/test_modify.py`: `test_modify_genrule_notify` called `test_modify_genrule`; the shared body is a helper. - `docs/test_docs.py`: `test_docs_fail_with_invalid_patterns` was `xfail`ed in 2022 and passes today; `expectedFailure` would fail it for passing, so the mark is gone. Test ids change shape (see the stack context), so test history and by-name disablement start over. A bare `assert` loses pytest's operand introspection: a failure prints `AssertionError` alone unless the assert carries a message. Reviewed By: IanChilds Differential Revision: D124484085 fbshipit-source-id: 3110efb82913b75e1b919d54168e93dc3440c29dDavis Rollman · ff8610e8 · 2026-10-21
- 11.8ETVmaps: The mini_map crate Summary: The core map family from the retained-maps plan, complete up to (but not including) plumbing into starlark_map and buck2: the canonical hasher, the mutable insertion-ordered map, and two immutable maps, with their sets. New code, so it ships as one diff; the ported files are marked as copies from `starlark_map` so blame carries through. The crate docs carry the design; this summary is for the choices a reviewer might want argued, and the numbers. ## The hashing layer `FastHasher`/`FastHasherBuilder` is the one hasher buck2 and starlark will share: a vendored `Fx64Hasher`, bit-identical to `rustc_hash::FxHasher` on x86_64/aarch64 and the same on every other platform, guarded by a drift test (the module docs say why vendored rather than depended on). `ShortHash` (u32) and `Hashed<K>` are `StarlarkHashValue`/`Hashed` generalized. ## `MiniMutInsertionMap` and `MiniFixedInsertionMap` `SmallMap`'s shape re-implemented on one allocation behind a one-word handle (`SmallMap` is 32 bytes on the stack plus two allocations), with its own SwissTable-shaped index past the hash-scan threshold, at 7.5 bytes per entry against hashbrown's ~10 plus a second allocation. The first cut of the index was a scalar probe loop at 5.3 bytes per entry; the microbenchmark in the next diff showed it 2× behind hashbrown on hits and 3–4× on misses, which the group matching recovers. Lookup entry points are `#[inline(always)]` (rationale on `find_in`). Against the `SmallMap` this replaces, lookups are within 0.6 ns at the sizes most of buck2's maps have, about 2 ns behind on indexed hits, and at parity or better on misses and on building, for 0.4 MB on a 716 MB text segment. The project notes carry the full table. `MiniFixedInsertionMap` is the frozen form: the same layout with the spare capacity gone, so freezing a large map is a `shrink_to_fit` and a pointer handoff. Both come with the `layout_of`/`init`/view layer for building into caller-owned memory. `==` and `Hash` are order-sensitive on the mutable map too. An earlier revision of this diff had no trait impls at all, on the theory that a mutable container cannot say which equality it means; with "Insertion" in the name the ordered one contradicts nothing, it is what `Vec` does, and it is the one that makes `==` safe as a dice cutoff where indexmap's unordered `==` is not. `eq_unordered` is the explicit way to ask the other question, and the `SmallMap` facade above keeps its legacy unordered `==` for the sites that depend on it. ## `MiniFixedSortedMap`/`MiniFixedSortedSet` The frozen map for data whose arrival order nobody needs, and so the default for retained data: `MiniFixedInsertionMap` with its entries sorted by key at construction, as a newtype, so that iteration order, `==`, `Hash`, `StrongHash` and the serialized bytes are functions of the contents however the map was built. `collect` and `From<MiniMutInsertionMap>` are the constructors. An earlier revision had a third representation in this role: dense entries sorted by `(hash, key)` with interpolation lookups through i16 checkpoints, at 0.13 bytes of overhead per entry against the insertion map's 7.5. Measured end to end through the retained-site conversions above, it bought 0.2–0.4% of allocated memory and no time, because buck2's retained maps are almost all small enough to carry no index in either layout, while it cost 3,300 lines, an iteration order that was deterministic only per hasher version, and a `K: Ord` bound anyway, for its tiebreak. The sorted newtype keeps every property that argued for it under the same bound, and a paired A/B of the two reads as noise on both workloads with memory identical to 0.1%. `sort_keys`, which the sorted map and `SortedMap` both build through, sorts positions and then permutes the entry arrays once, instead of moving entries at every comparison: 45 ns per entry at 100k shuffled entries where it was 125. ## The rest pagable sits behind a `pagable_dep` feature mirroring starlark_map's, so that feature stays meaningful after the re-plumb; the pagable bytes of the insertion map are unchanged from `SmallMap`'s. The crate builds on stable Rust; SIMD and `may_dangle` on the `Drop` impls are nightly-gated the way mini_vec gates them. Dual MIT OR Apache-2.0 throughout, including the ported code: copyright there is wholly company-owned (starlark_map has no blame past the fork, CLA covers everything since). `Vec2` is deliberately not here: it is not part of the map family and nothing in this crate uses it; a diff further up the stack moves it to `buck2_util`. `starlark_map` keeps its own copies of the ported structures until it is re-plumbed onto this crate above that. Reviewed By: 8Keep Differential Revision: D115843392 fbshipit-source-id: 708aa6a7097c04de1db105098b84a9b01d5ca29fJakob Degen · e5d11fd9 · 2026-10-21
- 9.7ETVlifetimes: Brand the compiler IR and the bytecode Summary: The compiler's products - `ExprCompiled`, `StmtsCompiled`, `DefInfo`, the spans, and the `Bc` they compile to - held `FrozenValue`s, so everything the evaluator read out of bytecode was erased and re-typed at the read: `Def::at_brand`'s vtable compare per `CallFrozenDef`, the `FrozenValue::to_value` reads in the interpreter, and the erasures at the ends of `demote`. This diff puts the brand on the IR and the bytecode. The IR lives at `'fm`, the module frozen heap the `Compiler` allocates into (`ExprCompiled<'fm>`, `ResolvedIdent::Global(Value<'fm>)`, which ripples through `CstPayload<'fm>` into the scope resolver and the typechecker), and a `Bc<'v>` is at the brand of the heap it runs against. The two meet in one place: `eval_regular_top_level_stmt` rebrands the statement's `Bc<'fm>` to `Bc<'v>` through the module edge, once per top-level statement, and the module's `DefInfo` handle is rebranded once in `eval_module`. Everything downstream is plain reads. Where a compiler product has to be a heap value - `DefInfo`, `FrameSpan`, `InlinedFrame`, `FrozenFileSpan` - it is allocated as a `StarlarkAnyComplex<T<'f>>`, the `FrozenModuleData` idiom, with a hand `FreezeBranded` that is unreachable because these are only ever allocated in frozen heaps. `Def`'s fields move to its brand, `Def::at_brand` goes, and `post_freeze` gets its edge from `ModuleHeaps::seal_with`, which is the relocated mint: the closure gets the same edge `frozen_heap` hands out, for the same reason. `FrozenFileSpan` keeps its name only because `codemap::FileSpan` already has the good one. The bytecode needed one structural move. Opcodes dispatch by `TypeId`, so instruction types must stay `'static` while their operands now carry `'v`. Call instructions therefore take `'static` marker types (`FullArgs`, `PosArgs`, `AnyCallable`, `NativeCallable`) whose GAT names the branded operand; the instruction body is unchanged and dispatch does no more work than before. `BcNativeFunction<'v>` is at the bytecode's brand rather than immortal, since a native function value can live in any frozen heap the module references, not only in a static. Smaller things this forces or frees: - `LocalAsValue` placeholders were a process-wide singleton heap indexed by slot; they are now a per-`Compiler` cache in the module frozen heap, so `alloc_simple_typed_static` goes. - `BuiltinFn::frozen()` becomes `at()` over `HeapEdge::immortal()`: `Constants` is a static. - `TypecheckProfile` is keyed by `String`: the profile outlives the evaluation, and the def names it was keyed by are now at the brand. - `UnusedLoad` carries spans instead of CST nodes, since the CST is branded and the result outlives the heap scope. - `Module::get_slot_frozen`, `frozen_value`, `Arguments::frozen_to_v` (a transmute) and `FrozenAnyArray` are dead and go. `FrozenAnyValue`/`alloc_any_value` stay for buck2's `UserProviderCallable`, and `TypeCompiled::to_frozen` is branded with a `to_frozen_unbranded` next to it for the same consumers; both are 4-C's to delete. - `is_builtin`, `speculative_exec_safe` and `eq_is_ptr_eq` move from `FrozenValue` onto `Value`, where the compiler now calls them. No new `unsafe` beyond the `seal_with` mint; the tuple `ProvidesStaticType` impl is of the same kind as its neighbours. The pagable wire format is unchanged. Reviewed By: jtbraun Differential Revision: D118970674 fbshipit-source-id: 62668fb6d7cdd982e66918d4cc93fd02d2700f1cJakob Degen · 8f2b6c35 · 2026-09-08
- 9.4ETVMove starlark_fmt into buck2/tools/ Summary: Relocates the `starlark_fmt` crate (an opinionated ruff-based Starlark/BUCK formatter) from `fbcode/starlark_fmt/` to a new shared `fbcode/buck2/tools/starlark_fmt/` directory as the first step toward open-sourcing it into the public `facebook/buck2` repo, and makes the crate open-source-buildable. Sources are moved with `sl mv` to preserve internal history. Relocation: - New shared `fbcode/buck2/tools/` home for buck2-adjacent tools. - Renamed `mod.rs` files to sibling modules (`autofixes.rs`, `formatting.rs`, `subcommands.rs`) to satisfy the buck2 `rust-no-mod-rs` lint. - No local `PACKAGE`; the crate inherits `fbcode/buck2/PACKAGE`. Target-level `visibility` is kept on `starlark_fmt_lib`. - A forwarding `alias` is left at `fbcode//starlark_fmt:starlark_fmt` so the generated DotSlash manifest (`tools/lint/starlark/starlark_fmt`) keeps resolving; removing it is a follow-up gated on the MSDK schedule repoint. - Updated the sole external Buck consumer `fbcode//autodeps2/autodeps2`, the `README.md` build/test paths, and dropped the now-stale `starlark_fmt` row from `fbcode_enable_pyrefly_targets.csv`. The ~20 path-based consumers of `tools/lint/starlark/starlark_fmt` are unaffected (that path is unchanged). Open-source readiness (so the OSS `cargo`/`buck2-oss` build works). Because this diff registers the crate in the OSS cargo workspace, it must itself be OSS-buildable, so all of the following live here: - Applied the dual MIT/Apache license header to all `.rs` files. - autocargo-generated `Cargo.toml` for the crate and registered it in the OSS workspace (`fbcode/buck2/Cargo.toml` members). - Gated the internal `lint` subcommand out of the OSS build: it uses `//common/rust/lint_message` (not in OSS), so `mod lint`, the `lint_message` import, the `Command::Lint` variant/arm, and the `lint_files` use are `#[cfg(fbcode_build)]`, and the dep is `# oss-disable`. `fmt`/`diff`/`stdin` are unaffected; the internal build is unchanged. - Gated the Meta-internal `quickcheck_arbitrary_derive` (used only by the fbcode_build-gated fuzz tests) out of the OSS build: `mod fuzz_starlark` is `#[cfg(all(test, fbcode_build))]`, and an autocargo `extra_buck_dependencies` removal drops it from the generated `Cargo.toml`. - Pinned `get-size2 = "=0.10.1"` into the OSS `[workspace.dependencies]` (via an autocargo `extra_buck_dependencies` reference) so the OSS cargo build resolves `ruff_python_ast` against `compact_str 0.9.1` (0.10.2 would need compact_str ^0.10 and fail the `CompactString: GetSize` bound). - Fixed lints that `buck2-oss-lint` denies but internal lint doesn't: `clippy::str_to_string` (28x `.to_string()` -> `.to_owned()` on `&str`) and `let_underscore_drop`. Reviewed By: d16r Differential Revision: D113069398 fbshipit-source-id: d724baad1d7b60ea545a335961b6bd36ceca933cDavis Rollman · 929c43bd · 2026-07-22
- 7.6ETVSplit the attr arena module Summary: `arena.rs` had grown to 7k lines covering the byte format, the kinds table and field types, the builder, the decoded views, every kind's semantics, the arg and query sub-encodings, and a thousand lines of tests. This moves each of those into its own submodule under `attrs/arena/` with no code changes: `storage` (words, records, the sealed arena), `schema` (the kinds table and what derives from it), `fields`, `builder`, `view`, `semantics`, `arg`, `query_expr`, `owned`, and `tests`. `arena.rs` keeps the module doc and re-exports the public API, so no caller changes. Items that cross submodule boundaries are `pub(super)`; the public surface is unchanged. The next diff moves the per-kind semantics out next to their attribute types. Reviewed By: jtbraun Differential Revision: D127006773 fbshipit-source-id: e9dea9ae4bc6cf8ae947b45a075b416bfb8ad68eJakob Degen · 95b2f436 · 2026-10-24
- 6.8ETVtests: Move tests/core/executor to the Rust harness Summary: # Stack Context buck2's e2e tests are Python, on a harness (`tests/e2e_util`) that mostly reimplements in Python what Rust already has, and they don't run in the open source build. This stack adds a Rust harness next to the Python one and moves the tests over to it a directory at a time, improving the harness as the tests need. # This diff The 17 modules of `tests/core/executor`, test for test. `test_content_based_paths` builds its `tgz` archives with `tar` and `flate2` instead of the Python `http_archive` helper. `test_dep_files` splits arguments with `shlex` and, like Python's `read_text`, turns `\r\n` into `\n`. `test_re_use_case_override_with_external_config_source` overrides only `BUCK2_TEST_EXTRA_EXTERNAL_CONFIG` instead of the whole process environment, and both `test_re_use_case_override_*` tests write their config files to `tmp_path`. `test_expect_eligible_for_dedupe_ineligible_input_for_execution_platform` never awaited its build in Python, and the Rust test keeps it that way. Reviewed By: IanChilds Differential Revision: D129394976 fbshipit-source-id: c0e52a8b780144923a8f61a7d7dda64e0f5db357Davis Rollman · b2bbb020 · 2026-11-06
- 6.1ETVtests/e2e, tests/meta_only, the bxl_test and check_dependencies_test templates: pytest → python_unittest Summary: # Stack Context pytest is unsupported at Meta. The buck2 e2e test harness (`fbcode/buck2/tests/e2e_util`, used through `buck_e2e.bzl`) ran its ~500 test modules as `python_pytest` targets. This stack moves the harness and every module on it to `python_unittest`, then deletes the pytest support: a harness that runs tests as `unittest` methods (D124484084), the modules converted in four groups (D124484085 `tests/core`, D124484086 the rest of `buck2/tests`, D124484087 the agentcloud guards, D124484088 everything else), and the removal of the pytest path (D124487800). Test bodies are untouched; test ids change from `test_x.py::test_y[case]` to `pkg.test_x.XTest.test_y_case`. The rest of the modules under `buck2/tests` (115: `e2e`, `meta_only`, `select_type_params`, and the two `e2e_util` templates behind `bxl_test` and `check_dependencies_test`) are converted with `tools/pytest_to_unittest`, as `tests/core` was. The `buck2_e2e_test.use_unittest` package value in `buck2/tests/PACKAGE` switches every `buck2_e2e_test` under it to `python_unittest`. `bxl_test` and `check_dependencies_test` pass `use_unittest = True` themselves, since their template modules are the converted ones whichever package the target lives in. Users of `buck_e2e.bzl` outside `buck2/tests` stay on pytest until D124484088. Done by hand: - `e2e_util/test_bxl_check_dependencies_template.py`: the three flavors' list-argument helpers are one module-level `pass_list_arg`, so the `if FLAVOR == ...` chain in the class body holds tests only. - `e2e/test/test_testname_formatting.py`: the test was `testname_formatting` (collected on the `test` prefix); it is `test_name_formatting`, and its dead `pytest.xfail` branch is a `skipTest`. - `meta_only/e2e/rules/cxx/test_cxx.py`: `cxx_link_test` wrote a test per target into `globals()` from a loop; it is one method parametrized over the targets. - `meta_only/e2e/rules/link_groups/test_link_groups.py`: `pytest.param` in module-level lists. `meta_only/e2e/rules/nodejs/test_nodejs.py`: `pytest.fail` in a helper. Reviewed By: IanChilds Differential Revision: D124484086 fbshipit-source-id: 21c9bcc0ced3ab8a69bbb09a59d9a05bf070c6a1Davis Rollman · 1ea7bf67 · 2026-10-21
- 5.5ETVhypermodern: Add dice_core Summary: The core state of `docs/incrementality.md` as its own crate: keys, revisions and untracked-input revisions as opaque identities, branches and versions, one claim per key and branch pinning its witnessing certificate, assertion histories for injected keys, exact per-branch rdep maps, and the four operations `commit`, `fork`, `lookup` and `write`, plus `take` for today's `unstable_take`. Nothing in dice uses it yet; the next diff replaces `core/graph` with it. It is a separate crate because we will want the algorithm usable outside dice eventually, and drawing the line now is what keeps it pure: everything environment-specific comes in through one `Env` trait with three associated types, the dependency payload of a certificate (dice's series-parallel deps), data per claim (dice's invalidation paths) and data per assertion (dice's invalidation priority). The core stores these and hands them back. The one thing it does with them itself is compare payloads, since whether two certificates are the same one is a question about their traces, not about which allocation holds them; environments hand back the allocation they were given, so the comparison is by address almost always. A key that is both asserted and certified is a hard panic on both paths, in release too; dice's public API only allows that through test mocks. The one-word `triomphe` `Arc` dice uses moves in here, because certificates are shared between the core's claims and the environment's candidates; dice re-exports it and so depends on the crate already. Lookups that cannot answer offer a candidate for the environment to re-establish only if it was stamped with the version's untracked-input revision; one that was not can never cover the version. `nearest_certificate` is there for environments that want that certificate's value regardless, as dice does for its equality cutoff. ## Where the code departs from the doc - Seqs are 1-based (`NonZeroU32`), so that `Option<Version>` is free and the root's first commit is seq 2, matching the version numbers dice's tests already use. - Fork builds the child's rdep map from the certificates of the attached set instead of copying the parent's and supplementing it. With exact maps that is the same set of edges, and it lets the checker assert Invariant 3 as an equality rather than a superset. - The install policy for a branch that already has a claim is "replace iff the new window reaches further" (§5.2 leaves it as a policy). One visible consequence, pinned by a test: a branch's own attach replaces a closed copy it inherited for earlier seqs, so those seqs fall back from `Valid` to `Unknown` with a candidate. - §5.2 step 2.4, the same certificate still covering the child's fork seq, turns out to be unreachable through `write` under one-window-per-slot semantics (a re-issue after a close always restarts the window at or after the close). The arm is kept; the test that expected it documents what happens instead, a re-home. ## Testing Three layers, all in the crate. Unit tests, one module per part of the doc: resolution rules 1 to 3, commit and its BFS, write and coverage including non-contiguous covers of returning injected premises, each cascade rule of §5.2 step 2, fork including the round-6 counterexample and the support worklist, the untracked-input semantics ported from `check_that_force_dirty_*`, retention, and the constructions that shaped the design (the certificate island and cyclic writes of Appendix C, the fork worklist's revision check, a grandchild below a shadow, dirties on both sides of a fork, a re-homed claim's ε history, the G4 chain, fill-in from a closed parent window, the displaced-claim precision loss, certificates written after `take`). Every mutating call in a test re-checks the invariants. `check_invariants` is a full scan of everything the state promises about itself: the branch tree, history ordering, Invariants 1 to 3, `closed_index` exactness, and no key both asserted and certified. The master invariant is not a property of the state alone, so it is left to the oracle. The fuzzer runs random operation sequences against an oracle that computes §3.2's judgment by brute force over the recorded history. Two generators: arbitrary certificates, random keys, revisions, premises and ε, for which soundness must still hold because the theorem is unconditional; and an honest environment with fixed dep graphs and a deterministic value function, driven the way dice's worker drives the core, which additionally checks from-scratch consistency, that a write at a head attaches, and that a commit closes nothing outside the changed keys' support. Failing cases shrink by deleting operations and print with their seed. To check the harness has teeth I planted bugs one at a time. A first round of five (BFS skipping inherited claims, no cascade, closed covers installed open, stale edges kept, no support filter at fork) was caught within 200 cases, every time by the invariant checker. A second round of five aimed past the checker (off-by-ones in `History::at` and `Window::covers`, a child resolving at its parent's head instead of the fork point, inherited injected cover denied, no-op asserts decided against the parent's view) was caught by the unit tests and both fuzz modes; the last one only by the oracle, so it is a unit test now too. Reviewed By: christolliday Differential Revision: D118978185 fbshipit-source-id: f81aef9a831e5cd6edbb0e4dd9afbb4f625334deJakob Degen · 28d4420f · 2026-09-10
- 5.2ETVtests: Move tests/core/daemon to the Rust harness Summary: # Stack Context buck2's e2e tests are Python, on a harness (`tests/e2e_util`) that mostly reimplements in Python what Rust already has, and they don't run in the open source build. This stack adds a Rust harness next to the Python one and moves the tests over to it a directory at a time, improving the harness as the tests need. # This diff The 14 modules of `tests/core/daemon`, test for test. The two `test_daemon` tests that hold a command open use the harness's `subscribe` client. The harness gets `Buck::set_cwd` (for `test_checkouts_share_daemon`), `buck2_e2e::utils::file_id` (the file index, which the standard library doesn't expose on Windows), and `buck2_e2e::process` (`daemon_is_alive`, `wait_for_exit`, `wait_for_daemon_pid`, and signals on Unix), which replaces `tests/core/lsp`'s own `daemon_is_alive`. A Python `finally` becomes cleanup after the test body. It runs when the body returns an error, but not after a failed assertion; there the harness still stops the test's daemon. Reviewed By: IanChilds Differential Revision: D129394975 fbshipit-source-id: cc1a375cf7e4e484a7990d1af7914ccaf4ed1da4Davis Rollman · aed1e271 · 2026-11-06
- 5.1ETVtests: Add a Rust harness for e2e tests Summary: # Stack Context buck2's e2e tests are Python, on a harness (`tests/e2e_util`) that mostly reimplements in Python what Rust already has, and they don't run in the open source build. This stack adds a Rust harness next to the Python one and moves the tests over to it a directory at a time, improving the harness as the tests need. # This diff `tests/e2e_util/rust` is the harness. A test module is `test_foo.rs` next to its `test_foo_data`, as with Python, and each test is an `async fn` marked `#[buck_test(...)]`: ``` #[buck_test(data_dir = "sub")] async fn test_bad_target(buck: &Buck) -> anyhow::Result<()> { buck.build(&["//:good"]).await?; buck.build(&["//:bad"]) .await .expect_failure() .assert_stderr_matches("Error running analysis"); Ok(()) } ``` - The options of `#[buck_test]` are those of `buck_test()`, and a test gets the same project, environment and buckconfig as a Python test would. - A failed command is an `Err` carrying the command line, stdout and stderr, so `?` reports it in full, and `expect_failure()` turns the expectation around. A command can also be started and waited for later. - When a test fails, by an error or a panic, the harness stops its daemon and deletes its project, as Python's `finally` did. Rust tests here abort on a panic, so a panic hook does that part. - After a passed test, the harness fails an isolated test whose daemon panicked at any point unless it sets `allow_daemon_panics = true`, as Python does since D129123674. - `buck2_e2e::json::Json` is JSON as Python's `json` reads and writes it, keys in their order and `dumps` taking `json.dumps`'s `indent` and `sort_keys`, for the golden files Python tests wrote: the harness's `serde_json` sorts keys. - Golden files and their sanitizers, the event log and streaming build report helpers, and the HTTP server for download tests are ported as they are. Where Python and Rust differ (`re` vs `regex`, `splitlines`, exit codes of signals), the harness keeps Python's meaning. `buck_e2e_test` makes a `rust_unittest` when its `srcs` are Rust, and `buck2_core_tests` picks up `test_*.rs` as it does `test_*.py`. A Rust test starts in the project root with paths relative to it, so the macro tells the harness which of its variables are paths to make absolute. Like the tests, the harness builds with buck only: no Cargo manifests. Most tests outside `tests/core` run inplace: in the repository itself, with an isolation dir of their own per test case, rather than in a copy of their test data. The harness runs them as the Python one does, from the root of the test target's cell. A Rust test starts in the project root rather than in that cell, so `buck_e2e_test` names the cell and the harness finds its path in the repository's `.buckconfig`. The isolation dir is named after the test target and case, as with Python, so that what the test builds has the same action cache keys on every machine, and inplace tests keep soft errors soft (`BUCK2_HARD_ERROR=false`): they build the repository's own targets. A test that copies its test data can also have a copy of the prelude (`PRELUDE`) and of the toolchain platform cells (`OVR_CONFIG`) put in its project. ___ landed-with-radar-review Differential Revision: D129372986 fbshipit-source-id: 84510ef5a47fb96b1b22553ea8825c2b3c872af1Davis Rollman · 6e3b2e3c · 2026-11-05