summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-06-06 11:41:39 +0200
committerLudovic Courtès <ludo@gnu.org>2023-06-06 11:54:39 +0200
commit181951207339508789b28ba7cb914f983319920f (patch)
treea9747a37eb4fa7cf7dadb481df64b7856644ca0e /tests
parentdc0c5d56ee04d8a2b57f316be7f95b9aca244ab5 (diff)
services: 'modify-services' preserves service ordering.
Fixes <https://issues.guix.gnu.org/63921>. 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.
Diffstat (limited to 'tests')
-rw-r--r--tests/services.scm37
1 files changed, 19 insertions, 18 deletions
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 <ludo@gnu.org>
+;;; Copyright © 2015-2019, 2022, 2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; 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