Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctestCheckHook: init, {pdal,gifticlib,zynaddsubfx}: migrate to ctestCheckHook #379426

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

xokdvium
Copy link
Contributor

@xokdvium xokdvium commented Feb 4, 2025

Motivation for this hook is simple: there's no single documented
way to do trivial things with ctest:

  1. Pass additional flags to ctest invocation.
  2. Selectively disable tests in a mechanism similar to python's
    disabledTests or rust's composable skips in checkFlags.
  3. Disable parallel checking.

Current state of things has lead to several different solutions:

  1. Completely overriding checkPhase [1] and invoking ctest manually
    with the necessary flags. This is most often coupled with -E for
    disabling test or setting parallel level.
  2. Wrangling with weird double string/regex escaping and trying to stuff
    additional parameters and/or exclusion regex via CMAKE_CTEST_ARGUMENTS.
    This approach is especially painful when test names have spaces. This is
    the reason I originally decided to implement this hook after wrangling with
    failing darwin tests here [2].
  3. Stuffing additional arguments into checkFlagsArray with the
    ARGS makefile parameter [3].

I don't see any reason to keep the status-quo. Doing something along these
lines has been suggested [4] for both ctest and meson. Meson setup-hook
has switched from ninja to meson in [5] with little friction. Doing
the same for cmake in a single sweep would prove problematic due to the
aforementioned zoo of workarounds and hacks for ctest. Doing it via
a separate hook would allow us to refactor things piecemeal and without
going through staging. The benefit of the hook is immediately clear and it
would allow to drive the refactor tractor at a comfortable pace.

[1]: pd/pdal/package.nix:117, cc/ccache/package.nix:108, gl/glog/package.nix:79
[2]: #375955
[3]: op/open62541/package.nix:114
[4]: #113829
[5]: #213845

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@xokdvium xokdvium force-pushed the feat/ctest-check-hook branch 2 times, most recently from cc8da0e to a2a5406 Compare February 6, 2025 08:29
@xokdvium xokdvium force-pushed the feat/ctest-check-hook branch from a2a5406 to 12bcae0 Compare February 14, 2025 18:54
@xokdvium
Copy link
Contributor Author

Rebased. Hopefully rerunning the nixpkgs manual build job will fix the intermittent cachix 501 error.

Pinging CMake maintainers here for visibility and their reviews, since ctest is part of cmake package and I want some more people to take a look at this. Hope I'm not overstepping here - nix-owners already pinged quite a few maintainers of the migrated packages. cc @ttuegel @LnL7.

Also @wolfgangwalther, since they recently worked on __structuredAttrs support in setup-hooks, including cmake ones. I tested this hook manually for __structuredAttrs, but I'm quite new to setup-hooks and there might be some footguns I'm not aware of.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only looked at the hook. structuredAttrs-wise I don't see any problems. 👍

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/5224

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Feb 21, 2025
@xokdvium xokdvium requested a review from jtojnar February 22, 2025 18:27
@xokdvium xokdvium force-pushed the feat/ctest-check-hook branch from 12bcae0 to a1358e7 Compare March 3, 2025 19:47
Motivation for this hook is simple: there's no single documented
way to do trivial things with ctest:

1. Pass additional flags to ctest invocation.
2. Selectively disable tests in a mechanism similar to python's
   `disabledTests` or rust's composable skips in `checkFlags`.
3. Disable parallel checking.

Current state of things has lead to several different solutions:

1. Completely overriding `checkPhase` [1] and invoking ctest manually
   with the necessary flags. This is most often coupled with `-E` for
   disabling test or setting parallel level.
2. Wrangling with weird double string/regex escaping and trying to stuff
   additional parameters and/or exclusion regex via `CMAKE_CTEST_ARGUMENTS`.
   This approach is especially painful when test names have spaces. This is
   the reason I originally decided to implement this hook after wrangling with
   failing darwin tests here [2].
3. Stuffing additional arguments into `checkFlagsArray` with the
   `ARGS` makefile parameter [3].

I don't see any reason to keep the status-quo. Doing something along these
lines has been suggested [4] for both `ctest` and `meson`. Meson setup-hook
has switched from `ninja` to `meson` in [5] with little friction. Doing
the same for cmake in a single sweep would prove problematic due to the
aforementioned zoo of workarounds and hacks for `ctest`. Doing it via
a separate hook would allow us to refactor things piecemeal and without
going through staging. The benefit of the hook is immediately clear and it
would allow to drive the refactor tractor at a comfortable pace.

[1]: pd/pdal/package.nix:117, cc/ccache/package.nix:108, gl/glog/package.nix:79
[2]: https://www.github.com/NixOS/nixpkgs/pull/375955
[3]: op/open62541/package.nix:114
[4]: https://www.github.com/NixOS/nixpkgs/issues/113829
[5]: https://www.github.com/NixOS/nixpkgs/pull/213845
@xokdvium xokdvium force-pushed the feat/ctest-check-hook branch from a1358e7 to 494f737 Compare March 3, 2025 19:56
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants