From 44895f73e73269245a3860981fc33e5e94c2e799 Mon Sep 17 00:00:00 2001 From: Murilo Date: Tue, 30 Dec 2025 13:00:55 -0300 Subject: [PATCH] gnu: Add unity-test. * gnu/packages/check.scm (unity-test): New variable. * gnu/packages/patches/unity-test-set-subdir-correctly.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. Change-Id: I2d5c88f20df3902513990a5fcf0cbe88b31e2eee Modified-by: John Kehayias Signed-off-by: John Kehayias --- gnu/local.mk | 1 + gnu/packages/check.scm | 46 +++++++++++++++++++ .../unity-test-set-subdir-correctly.patch | 30 ++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 gnu/packages/patches/unity-test-set-subdir-correctly.patch diff --git a/gnu/local.mk b/gnu/local.mk index 5d130aa7ced..eb92804975d 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2413,6 +2413,7 @@ dist_patch_DATA = \ %D%/packages/patches/ucx-tcp-iface-ioctl.patch \ %D%/packages/patches/uftrace-fix-tests.patch \ %D%/packages/patches/ultrastar-deluxe-no-freesans.patch \ + %D%/packages/patches/unity-test-set-subdir-correctly.patch \ %D%/packages/patches/ungoogled-chromium-extension-search-path.patch \ %D%/packages/patches/ungoogled-chromium-RUNPATH.patch \ %D%/packages/patches/ungoogled-chromium-system-nspr.patch \ diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm index a18102b5e81..b2cf63a4ecf 100644 --- a/gnu/packages/check.scm +++ b/gnu/packages/check.scm @@ -58,6 +58,7 @@ ;;; Copyright © 2025 Nicolas Graves ;;; Copyright © 2025 nomike Postmann ;;; Copyright © 2025 Josep Bigorra +;;; Copyright © 2025 Murilo ;;; ;;; This file is part of GNU Guix. ;;; @@ -109,6 +110,7 @@ #:use-module (gnu packages python-web) #:use-module (gnu packages python-xyz) #:use-module (gnu packages python-science) + #:use-module (gnu packages ruby) #:use-module (gnu packages sqlite) #:use-module (gnu packages texinfo) #:use-module (gnu packages time) @@ -3431,6 +3433,50 @@ of advanced library and language features, which means it should be easily portable to just about any platform.") (license license:expat))) +(define-public unity-test + (package + (name "unity-test") + (version "2.6.1") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ThrowTheSwitch/Unity") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1s0jj9f2zav49mn9ib90idcmb6hq93aczbqysn5hj6binjmrnjw3")) + (patches (search-patches "unity-test-set-subdir-correctly.patch")))) + (build-system meson-build-system) + (arguments + (list #:configure-flags + #~(list "-Dsupport_double=true") + #:phases + #~(modify-phases %standard-phases + (add-after 'patch-source-shebangs 'patch-more-shebangs + (lambda _ + (substitute* '("auto/unity_test_summary.rb") + (("/usr/bin/ruby") + (string-append #$(this-package-input "ruby") + "/bin/ruby"))) + (substitute* '("auto/stylize_as_junit.py" + "auto/unity_test_summary.py") + (("#! python3") + (string-append #$(this-package-input "python") + "/bin/python3"))))) + (add-after 'install 'install-extra + (lambda _ + (for-each (lambda (x) + (install-file x + (string-append #$output "/share/unity-test"))) + (find-files "../source/auto"))))))) + (native-inputs (list pkg-config)) + (inputs (list python ruby)) + (home-page "https://github.com/ThrowTheSwitch/Unity") + (synopsis "Simple unit testing for C") + (description "This package provides a unit testing framework built for C, +with a focus on working with embedded toolchains.") + (license license:expat))) + (define-public libfaketime (package (name "libfaketime") diff --git a/gnu/packages/patches/unity-test-set-subdir-correctly.patch b/gnu/packages/patches/unity-test-set-subdir-correctly.patch new file mode 100644 index 00000000000..689343d9630 --- /dev/null +++ b/gnu/packages/patches/unity-test-set-subdir-correctly.patch @@ -0,0 +1,30 @@ +From 4c8dab0edd16ce6a4b7b628430de1cd42d03f31a Mon Sep 17 00:00:00 2001 +From: Ross Smyth +Date: Mon, 10 Mar 2025 16:00:38 -0400 +Subject: [PATCH] Fix meson pkg-config generation + +The pkg-config file does not include the subdir +in its build flags, so files will fail to find the +Unity headers. +--- + meson.build | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index 6585129c..9489aef4 100644 +--- a/meson.build ++++ b/meson.build +@@ -64,10 +64,10 @@ unity_dep = declare_dependency( + if not meson.is_subproject() + pkg = import('pkgconfig') + pkg.generate( +- name: meson.project_name(), ++ unity_lib, + version: meson.project_version(), +- libraries: [ unity_lib ], +- description: 'C Unit testing framework.' ++ subdirs: 'unity', ++ extra_cflags: unity_args, + ) + endif +