From 181951207339508789b28ba7cb914f983319920f Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Jun 2023 11:41:39 +0200 Subject: services: 'modify-services' preserves service ordering. Fixes . The regression was introduced in dbbc7e946131ba257728f1d05b96c4339b7ee88b, which changed the order of services. As a result, someone using 'modify-services' could find themselves with incorrect ordering of expressions in the "boot" script, whereby the cleanup expressions would come after (execl ".../shepherd"). This, in turn, would lead shepherd to error out at boot with EADDRINUSE on /var/run/shepherd/socket. * gnu/services.scm (%delete-service, %apply-clauses): Remove. (clause-alist): New macro. (apply-clauses): New procedure. (modify-services): Use it. Adjust docstring. * tests/services.scm ("modify-services: do nothing"): Remove 'sort' call. ("modify-services: delete service"): Likewise, and add 't4' service. ("modify-services: change value"): Remove 'sort' call and fix expected value. --- tests/services.scm | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/services.scm b/tests/services.scm index 8cdb1b2a31..20ff4d317e 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015-2019, 2022 Ludovic Courtès +;;; Copyright © 2015-2019, 2022, 2023 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -287,7 +287,7 @@ (x x)))) (test-equal "modify-services: do nothing" - '(1 2 3) + '(1 2 3) ;note: service order must be preserved (let* ((t1 (service-type (name 't1) (extensions '()) (description ""))) @@ -298,12 +298,11 @@ (extensions '()) (description ""))) (services (list (service t1 1) (service t2 2) (service t3 3)))) - (sort (map service-value - (modify-services services)) - <))) + (map service-value + (modify-services services)))) (test-equal "modify-services: delete service" - '(1) + '(1 4) ;note: service order must be preserved (let* ((t1 (service-type (name 't1) (extensions '()) (description ""))) @@ -313,12 +312,15 @@ (t3 (service-type (name 't3) (extensions '()) (description ""))) - (services (list (service t1 1) (service t2 2) (service t3 3)))) - (sort (map service-value - (modify-services services - (delete t3) - (delete t2))) - <))) + (t4 (service-type (name 't4) + (extensions '()) + (description ""))) + (services (list (service t1 1) (service t2 2) + (service t3 3) (service t4 4)))) + (map service-value + (modify-services services + (delete t3) + (delete t2))))) (test-error "modify-services: delete non-existing service" #t @@ -336,7 +338,7 @@ (delete t3)))) (test-equal "modify-services: change value" - '(2 11 33) + '(11 2 33) ;note: service order must be preserved (let* ((t1 (service-type (name 't1) (extensions '()) (description ""))) @@ -347,11 +349,10 @@ (extensions '()) (description ""))) (services (list (service t1 1) (service t2 2) (service t3 3)))) - (sort (map service-value - (modify-services services - (t1 value => 11) - (t3 value => 33))) - <))) + (map service-value + (modify-services services + (t1 value => 11) + (t3 value => 33))))) (test-error "modify-services: change value for non-existing service" #t -- cgit 1.4.1