From 3948ac25b1dccc40c7fdf56377f94a0775a835ee Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 13 May 2022 23:40:34 +0200 Subject: services: Make 'description' field mandatory. * gnu/services.scm ()[description]: Remove default value. * tests/services.scm: Add 'description' field to each 'service-type' form. --- gnu/services.scm | 3 +-- tests/services.scm | 38 ++++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/gnu/services.scm b/gnu/services.scm index 234ee372b8..6f0f4d5bdc 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -183,8 +183,7 @@ (define-record-type* service-type make-service-type (default &no-default-value)) ;; Meta-data. - (description service-type-description ;string - (default #f)) + (description service-type-description) ;string (location service-type-location ; (default (and=> (current-source-location) source-properties->location)) diff --git a/tests/services.scm b/tests/services.scm index e64b3e8de8..8e35758209 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -30,8 +30,10 @@ (define-module (test-services) (test-equal "services, default value" '(42 123 234 error) - (let* ((t1 (service-type (name 't1) (extensions '()))) + (let* ((t1 (service-type (name 't1) (extensions '()) + (description ""))) (t2 (service-type (name 't2) (extensions '()) + (description "") (default-value 42)))) (list (service-value (service t2)) (service-value (service t2 123)) @@ -40,13 +42,13 @@ (define-module (test-services) (service t1))))) (test-assert "service-back-edges" - (let* ((t1 (service-type (name 't1) (extensions '()) + (let* ((t1 (service-type (name 't1) (extensions '()) (description "") (compose +) (extend *))) - (t2 (service-type (name 't2) + (t2 (service-type (name 't2) (description "") (extensions (list (service-extension t1 (const '())))) (compose +) (extend *))) - (t3 (service-type (name 't3) + (t3 (service-type (name 't3) (description "") (extensions (list (service-extension t2 identity) (service-extension t1 list))))) @@ -63,16 +65,16 @@ (define-module (test-services) ;; from services of type T3; 'xyz 60' comes from the service of type T2, ;; where 60 = 15 × 4 = (1 + 2 + 3 + 4 + 5) × 4. '(initial-value 5 4 3 2 1 xyz 60) - (let* ((t1 (service-type (name 't1) (extensions '()) + (let* ((t1 (service-type (name 't1) (extensions '()) (description "") (compose concatenate) (extend cons))) - (t2 (service-type (name 't2) + (t2 (service-type (name 't2) (description "") (extensions (list (service-extension t1 (cut list 'xyz <>)))) (compose (cut reduce + 0 <>)) (extend *))) - (t3 (service-type (name 't3) + (t3 (service-type (name 't3) (description "") (extensions (list (service-extension t2 identity) (service-extension t1 list))))) @@ -86,10 +88,10 @@ (define-module (test-services) (service-value r)))) (test-assert "fold-services, ambiguity" - (let* ((t1 (service-type (name 't1) (extensions '()) + (let* ((t1 (service-type (name 't1) (extensions '()) (description "") (compose concatenate) (extend cons))) - (t2 (service-type (name 't2) + (t2 (service-type (name 't2) (description "") (extensions (list (service-extension t1 list))))) (s (service t2 42))) @@ -105,8 +107,8 @@ (define-module (test-services) #f))) (test-assert "fold-services, missing target" - (let* ((t1 (service-type (name 't1) (extensions '()))) - (t2 (service-type (name 't2) + (let* ((t1 (service-type (name 't1) (extensions '()) (description ""))) + (t2 (service-type (name 't2) (description "") (extensions (list (service-extension t1 list))))) (s (service t2 42))) @@ -119,11 +121,11 @@ (define-module (test-services) #f))) (test-assert "instantiate-missing-services" - (let* ((t1 (service-type (name 't1) (extensions '()) + (let* ((t1 (service-type (name 't1) (extensions '()) (description "") (default-value 'dflt) (compose concatenate) (extend cons))) - (t2 (service-type (name 't2) + (t2 (service-type (name 't2) (description "") (extensions (list (service-extension t1 list))))) (s1 (service t1 'hey!)) @@ -135,17 +137,17 @@ (define-module (test-services) (instantiate-missing-services (list s1 s2)))))) (test-assert "instantiate-missing-services, indirect" - (let* ((t1 (service-type (name 't1) (extensions '()) + (let* ((t1 (service-type (name 't1) (extensions '()) (description "") (default-value 'dflt) (compose concatenate) (extend cons))) - (t2 (service-type (name 't2) + (t2 (service-type (name 't2) (description "") (default-value 'dflt2) (compose concatenate) (extend cons) (extensions (list (service-extension t1 list))))) - (t3 (service-type (name 't3) + (t3 (service-type (name 't3) (description "") (extensions (list (service-extension t2 list))))) (s1 (service t1)) @@ -160,8 +162,8 @@ (define-module (test-services) (instantiate-missing-services (list s2 s3)))))) (test-assert "instantiate-missing-services, no default value" - (let* ((t1 (service-type (name 't1) (extensions '()))) - (t2 (service-type (name 't2) + (let* ((t1 (service-type (name 't1) (extensions '()) (description ""))) + (t2 (service-type (name 't2) (description "") (extensions (list (service-extension t1 list))))) (s (service t2 42))) -- cgit v1.2.3