Skip to content

Commit

Permalink
refactor: unity-test, add checks, pkg-config
Browse files Browse the repository at this point in the history
This now uses Meson, which causes it to output a pkg-config
file, which is beter supported than cmake files.

This also add the checkPhase.
  • Loading branch information
RossSmyth committed Mar 10, 2025
1 parent c5562d2 commit e0041ef
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
12 changes: 12 additions & 0 deletions pkgs/by-name/un/unity-test/meson.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/meson.build b/meson.build
index 6585129..d68f20d 100644
--- a/meson.build
+++ b/meson.build
@@ -67,6 +67,7 @@ if not meson.is_subproject()
name: meson.project_name(),
version: meson.project_version(),
libraries: [ unity_lib ],
+ subdirs: 'unity',
description: 'C Unit testing framework.'
)
endif
62 changes: 59 additions & 3 deletions pkgs/by-name/un/unity-test/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@
lib,
stdenv,
fetchFromGitHub,
cmake,
meson,
ninja,
python3,
nix-update-script,
ruby,
rubyPackages,
# Adds test groups and extra CLI flags.
buildFixture ? false,
# Adds the ablilty to track malloc and free calls.
# Note that if fixtures are enabled, this option is ignored
# and will always be enabled.
buildMemory ? buildFixture,
# Adds double precision floating point assertions
supportDouble ? false,
}:

stdenv.mkDerivation (finalAttrs: {
Expand All @@ -16,13 +29,56 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-g0ubq7RxGQmL1R6vz9RIGJpVWYsgrZhsTWSrL1ySEug=";
};

nativeBuildInputs = [ cmake ];
nativeBuildInputs = [
meson
ninja
python3
];

mesonFlags = [
(lib.mesonBool "extension_memory" buildMemory)
(lib.mesonBool "extension_fixture" buildFixture)
(lib.mesonBool "support_double" supportDouble)
];

# The meson file does not have the subdir set correctly
patches = [ ./meson.patch ];

postPatch = ''
patchShebangs --build auto
'';

# https://github.com/ThrowTheSwitch/Unity/blob/v2.6.1/.github/workflows/main.yml#L20-L35
doCheck = true;
nativeCheckInputs = [
ruby
rubyPackages.rake
rubyPackages.rubocop
rubyPackages.rspec
];

checkPhase = ''
runHook preCheck
cd ../test
rake ci
# Must do so the meson install hook works
cd ../build
runHook postCheck
'';

passthru.updateScript = nix-update-script { };

meta = {
description = "Unity Unit Testing Framework";
homepage = "https://www.throwtheswitch.org/unity";
license = lib.licenses.mit;
maintainers = [ lib.maintainers.i01011001 ];
platforms = lib.platforms.all;
maintainers = [
lib.maintainers.i01011001
lib.maintainers.RossSmyth
];
};
})

0 comments on commit e0041ef

Please sign in to comment.