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 8cdb1b2a314..20ff4d317e8 100644
--- a/tests/services.scm
+++ b/tests/services.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015-2019, 2022 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2015-2019, 2022, 2023 Ludovic Courtès <ludo@gnu.org>
3;;; 3;;;
4;;; This file is part of GNU Guix. 4;;; This file is part of GNU Guix.
5;;; 5;;;
@@ -287,7 +287,7 @@
287 (x x)))) 287 (x x))))
288 288
289(test-equal "modify-services: do nothing" 289(test-equal "modify-services: do nothing"
290 '(1 2 3) 290 '(1 2 3) ;note: service order must be preserved
291 (let* ((t1 (service-type (name 't1) 291 (let* ((t1 (service-type (name 't1)
292 (extensions '()) 292 (extensions '())
293 (description ""))) 293 (description "")))
@@ -298,12 +298,11 @@
298 (extensions '()) 298 (extensions '())
299 (description ""))) 299 (description "")))
300 (services (list (service t1 1) (service t2 2) (service t3 3)))) 300 (services (list (service t1 1) (service t2 2) (service t3 3))))
301 (sort (map service-value 301 (map service-value
302 (modify-services services)) 302 (modify-services services))))
303 <)))
304 303
305(test-equal "modify-services: delete service" 304(test-equal "modify-services: delete service"
306 '(1) 305 '(1 4) ;note: service order must be preserved
307 (let* ((t1 (service-type (name 't1) 306 (let* ((t1 (service-type (name 't1)
308 (extensions '()) 307 (extensions '())
309 (description ""))) 308 (description "")))
@@ -313,12 +312,15 @@
313 (t3 (service-type (name 't3) 312 (t3 (service-type (name 't3)
314 (extensions '()) 313 (extensions '())
315 (description ""))) 314 (description "")))
316 (services (list (service t1 1) (service t2 2) (service t3 3)))) 315 (t4 (service-type (name 't4)
317 (sort (map service-value 316 (extensions '())
318 (modify-services services 317 (description "")))
319 (delete t3) 318 (services (list (service t1 1) (service t2 2)
320 (delete t2))) 319 (service t3 3) (service t4 4))))
321 <))) 320 (map service-value
321 (modify-services services
322 (delete t3)
323 (delete t2)))))
322 324
323(test-error "modify-services: delete non-existing service" 325(test-error "modify-services: delete non-existing service"
324 #t 326 #t
@@ -336,7 +338,7 @@
336 (delete t3)))) 338 (delete t3))))
337 339
338(test-equal "modify-services: change value" 340(test-equal "modify-services: change value"
339 '(2 11 33) 341 '(11 2 33) ;note: service order must be preserved
340 (let* ((t1 (service-type (name 't1) 342 (let* ((t1 (service-type (name 't1)
341 (extensions '()) 343 (extensions '())
342 (description ""))) 344 (description "")))
@@ -347,11 +349,10 @@
347 (extensions '()) 349 (extensions '())
348 (description ""))) 350 (description "")))
349 (services (list (service t1 1) (service t2 2) (service t3 3)))) 351 (services (list (service t1 1) (service t2 2) (service t3 3))))
350 (sort (map service-value 352 (map service-value
351 (modify-services services 353 (modify-services services
352 (t1 value => 11) 354 (t1 value => 11)
353 (t3 value => 33))) 355 (t3 value => 33)))))
354 <)))
355 356
356(test-error "modify-services: change value for non-existing service" 357(test-error "modify-services: change value for non-existing service"
357 #t 358 #t