Repository navigation
packaging/nix-make: Build and run the unit tests - #673
Conversation
Add make.nix files for libutil-c, libutil-test-support and libutil-tests, transcribed from their meson.build files. The `nix-util-tests` executable gets its main() from gtest_main, which is linked explicitly since no #include refers to it. deps.nix gains entries for gtest, gmock and rapidcheck (the latter with an explicit -lrapidcheck, as rapidcheck.pc lists no libraries). A new `runTest` helper in lib.nix (with run-test.py) produces a derivation that runs a test program. libutil-tests uses it for `tests.run` and `tests.run-without-new-syscalls`, the latter under `enosys` like package.nix. Every variant of the nix-make flake now has `nix-util-tests-run`, `nix-util-tests-run-without-new-syscalls` and `nix-all-tests`, an aggregate of all test runs (unit and functional); `checks` points at the release `nix-all-tests`, so `nix flake check` runs everything. Deviations from the Meson build: no static libnixutilc (the plugin C API), no precompiled headers, and `_NIX_TEST_ACCEPT` is not supported inside the derivation (same as package.nix). Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
Add make.nix files for libstore-c, libstore-test-support and libstore-tests, transcribed from their meson.build files. The benchmark sources are excluded (Meson's `benchmarks` option is off by default). The test data is rooted at the repository together with tests/functional/derivation, as in package.nix, and the test run has `openssl` on its PATH for the HTTPS binary cache tests. The store tests keep a store under $HOME, so run-test.py now sets HOME to a writable directory and expands `$HOME` in the `env` values of `runTest`. Every variant of the nix-make flake gains `nix-store-c`, `nix-store-test-support`, `nix-store-tests` and `nix-store-tests-run`, which is included in `nix-all-tests`. Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
Add make.nix files for libfetchers-c and libfetchers-tests, transcribed from their meson.build files. The libgit2 entry in deps.nix now matches `<git2.h>` as well as `<git2/...>`, which one of the tests includes. Every variant of the nix-make flake gains `nix-fetchers-c`, `nix-fetchers-tests` and `nix-fetchers-tests-run`, which is included in `nix-all-tests`. Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
Add make.nix files for libexpr-c, libexpr-test-support and libexpr-tests, transcribed from their meson.build files. The benchmark sources are excluded (Meson's `benchmarks` option is off by default). Every variant of the nix-make flake gains `nix-expr-c`, `nix-expr-test-support`, `nix-expr-tests` and `nix-expr-tests-run`, which is included in `nix-all-tests`. Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
Add make.nix files for libflake-c and libflake-tests, transcribed from their meson.build files. Every variant of the nix-make flake gains `nix-flake-c`, `nix-flake-tests` and `nix-flake-tests-run`, which is included in `nix-all-tests`. With this, all the unit test suites that the Meson build runs by default are covered. Assisted-by: Claude Fable 5.1 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (18)
Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughThe change adds Nix build definitions for component unit tests and supporting libraries. It adds a reusable test runner and exposes an aggregate of unit-test runners and functional tests through ChangesNix test build and execution
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant NixFlakeCheck
participant nix-all-tests
participant runTest
participant run-test.py
participant nix-util-tests
NixFlakeCheck->>nix-all-tests: builds the aggregate check
nix-all-tests->>runTest: includes unit-test runner derivations
runTest->>run-test.py: starts the configured test command
run-test.py->>nix-util-tests: executes the unit-test binary
Merge Risk: ⚪ Minimal · up to This change adds unit-test builds and runs to the flake check without changing the shipped Nix binary. No concrete merge-blocking risk was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (17 skipped: 17 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Motivation
Build and run the unit tests with nix-make (Nix as the C++ build system), so that
nix flake check ./packaging/nix-makecovers them along with the functional tests.Context
One commit per test suite (util, store, fetchers, expr, flake), each adding
make.nixfiles for the test executable and the components it needs that nix-make did not build yet: the C APIs (lib*-c) and the test support libraries. Together withgtest,gmockandrapidcheckentries indeps.nix, that is allmkComponentneeded.A
runTesthelper produces a derivation that runs a test program. Every variant of the flake now hasnix-<lib>-tests-runper suite andnix-all-tests, an aggregate of all unit and functional test runs;checkspoints at the releasenix-all-tests. AGENTS.md documents the new targets.All suites pass in the
releaseanddebug-fastvariants; the releasenixitself is unchanged.🤖 Generated with Claude Code
Summary by CodeRabbit