From 5f690393fdc6883c3a756fbceeeeb00e1dd2c0a1 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 31 Jan 2026 13:57:44 +0100 Subject: [PATCH] feat: add system tests support --- etc/manifests/system-tests.scm | 61 ++++++++++++++++++++++++++++++++++ modules/ruther.scm | 3 ++ modules/ruther/tests.scm | 27 +++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 etc/manifests/system-tests.scm create mode 100644 modules/ruther.scm create mode 100644 modules/ruther/tests.scm diff --git a/etc/manifests/system-tests.scm b/etc/manifests/system-tests.scm new file mode 100644 index 0000000000000000000000000000000000000000..5be3a50f555804de473457612c1b857348f38f0a --- /dev/null +++ b/etc/manifests/system-tests.scm @@ -0,0 +1,61 @@ +;;; This file has been taken from GNU Guix. +;;; The original copyright header follows. + +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016, 2018-2020, 2022 Ludovic Courtès +;;; +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(use-modules (ruther tests) + (gnu tests) + (gnu packages package-management) + (guix monads) + (guix store) + ((guix git-download) #:select (git-predicate)) + ((guix utils) #:select (current-source-directory)) + (git) + (srfi srfi-1) + (ice-9 match)) + +(define (system-test->manifest-entry test) + "Return a manifest entry for TEST, a system test." + (manifest-entry + (name (string-append "test." (system-test-name test))) + (version "0") + (item test))) + +(define* (filter-tests + #:key + (tests (ruther-system-tests)) + (filter-tests (getenv "TESTS"))) + (match filter-tests + (#f + tests) + ((= string-tokenize (filter-tests ...)) + (filter (lambda (test) + (member (system-test-name test) filter-tests)) + tests)))) + +(define (system-test-manifest) + "Return a manifest containing all the system tests, or all those selected by +the 'TESTS' environment variable." + (let* ((tests (filter-tests))) + (format (current-error-port) "Selected ~a system tests...~%" + (length tests)) + + (manifest (map system-test->manifest-entry tests)))) + +;; Return the manifest. +(system-test-manifest) diff --git a/modules/ruther.scm b/modules/ruther.scm new file mode 100644 index 0000000000000000000000000000000000000000..bc3138fff1d01153a48be11fec2556ba63c1b213 --- /dev/null +++ b/modules/ruther.scm @@ -0,0 +1,3 @@ +(define-module (ruther)) + +;; Dummy for now. diff --git a/modules/ruther/tests.scm b/modules/ruther/tests.scm new file mode 100644 index 0000000000000000000000000000000000000000..d50ec06391b3f2656f959970df4896da2cc7e700 --- /dev/null +++ b/modules/ruther/tests.scm @@ -0,0 +1,27 @@ +(define-module (ruther tests) + #:use-module (gnu tests) + #:use-module (guix discovery) + #:use-module (guix ui) + #:export (ruther-test-modules + fold-ruther-system-tests + ruther-system-tests)) + +(define (ruther-test-modules) + "Return the list of modules that define system tests." + (scheme-modules (dirname (search-path %load-path "ruther.scm")) + "ruther/tests" + #:warn warn-about-load-error)) + +(define (fold-ruther-system-tests proc seed) + "Invoke PROC on each system test, passing it the test and the previous +result." + (fold-module-public-variables (lambda (obj result) + (if (system-test? obj) + (cons obj result) + result)) + '() + (ruther-test-modules))) + +(define (ruther-system-tests) + "Return the list of system tests." + (reverse (fold-ruther-system-tests cons '())))