Skip to content

packaging/nix-make: Build and run the unit tests - #673

Merged
edolstra merged 5 commits into
mainfrom
nix-make-tests
Oct 7, 2026
Merged

edolstra merged 5 commits into
mainfrom
nix-make-tests

Conversation

@edolstra

@edolstra edolstra commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Build and run the unit tests with nix-make (Nix as the C++ build system), so that nix flake check ./packaging/nix-make covers them along with the functional tests.

Context

One commit per test suite (util, store, fetchers, expr, flake), each adding make.nix files 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 with gtest, gmock and rapidcheck entries in deps.nix, that is all mkComponent needed.

A runTest helper produces a derivation that runs a test program. Every variant of the flake now has nix-<lib>-tests-run per suite and nix-all-tests, an aggregate of all unit and functional test runs; checks points at the release nix-all-tests. AGENTS.md documents the new targets.

All suites pass in the release and debug-fast variants; the release nix itself is unchanged.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Build & Testing
    • The Nix build now supports building and running unit tests alongside functional tests, either together or independently.
    • The combined test check covers additional core components and their C APIs, making broader test coverage available through the standard flake check.
    • Updated testing guidance reflects the expanded test build options.

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>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: fe547de6-389d-4a15-bea5-c0bb2c18b3b8
📥 Commits

Reviewing files that changed from the base of the PR and between 1ef9034 and 18be442.

📒 Files selected for processing (18)
  • AGENTS.md
  • packaging/nix-make/deps.nix
  • packaging/nix-make/flake.nix
  • packaging/nix-make/lib.nix
  • packaging/nix-make/run-test.py
  • src/libexpr-c/make.nix
  • src/libexpr-test-support/make.nix
  • src/libexpr-tests/make.nix
  • src/libfetchers-c/make.nix
  • src/libfetchers-tests/make.nix
  • src/libflake-c/make.nix
  • src/libflake-tests/make.nix
  • src/libstore-c/make.nix
  • src/libstore-test-support/make.nix
  • src/libstore-tests/make.nix
  • src/libutil-c/make.nix
  • src/libutil-test-support/make.nix
  • src/libutil-tests/make.nix

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.


📝 Walkthrough

Walkthrough

The 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 nix flake check.

Changes

Nix test build and execution

Layer / File(s) Summary
Test dependency and runner support
packaging/nix-make/deps.nix, packaging/nix-make/lib.nix, packaging/nix-make/run-test.py
The dependency mappings add Google Test, Google Mock, RapidCheck, and a broader libgit2 header prefix. The library exports runTest; its Python runner loads the configured command and environment, runs the command, and creates the output directory after success.
C API and test-support components
src/lib*-c/make.nix, src/lib*-test-support/make.nix
Nix component definitions add C API libraries and test-support components for the utility, store, expression, fetcher, and flake libraries.
Component unit-test executables
src/libutil-tests/make.nix, src/libstore-tests/make.nix, src/libfetchers-tests/make.nix, src/libexpr-tests/make.nix, src/libflake-tests/make.nix
Nix expressions define unit-test executables and their test runs, including configured dependencies, test data, and environment values. The utility tests also define a run that disables openat2 and fchmodat2 through enosys.
Aggregate test check and guidance
packaging/nix-make/flake.nix, AGENTS.md
The flake adds unit-test runners to nix-all-tests alongside functional tests, exposes the aggregate through checks, and re-exports the built-in checks schema. The testing guidance documents the all-tests build command and independent suite builds.

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
Loading

Merge Risk: ⚪ Minimal · up to 18be4

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding build and run support for unit tests in packaging/nix-make.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request October 7, 2026 15:30 Inactive
@edolstra
edolstra added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit 7aedbf0 Oct 7, 2026
36 checks passed
@edolstra
edolstra deleted the nix-make-tests branch October 7, 2026 17:45

This branch was previously deployed

1 inactive deployment
pull request — 18be442f Deployed Oct 7, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants