summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-06-18 22:37:20 +0200
committerLudovic Courtès <ludo@gnu.org>2022-06-24 23:18:20 +0200
commitfb7e6ccba7cc243cd96cdc3fde3daa9a5f08e531 (patch)
tree2818996e5527553d52cdabd431dd245acc33a8da /tests
parent43137d058fe575a70707073bede3465b4c5f555a (diff)
services: configuration: Report the location of field type errors.
Previously field type errors would be reported in a non-standard way, and without any source location information. This fixes it. * gnu/services/configuration.scm (configuration-field-error): Add a 'loc' parameter and honor it. Use 'formatted-message' instead of plain 'format'. (define-configuration-helper)[field-sanitizer]: New procedure. Use it. Use STEM as the identifier of the syntactic constructor of the record type. Add a 'sanitize' property to each field. Remove now useless STEM macro that would call 'validate-configuration'. * gnu/services/mail.scm (serialize-listener-configuration): Adjust to new 'configuration-field-error' prototype. * tests/services/configuration.scm ("wrong type for a field"): New test. * po/guix/POTFILES.in: Add gnu/services/configuration.scm.
Diffstat (limited to 'tests')
-rw-r--r--tests/services/configuration.scm13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm
index 334a1e409b7..6268525317a 100644
--- a/tests/services/configuration.scm
+++ b/tests/services/configuration.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> 2;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
3;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> 3;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
4;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -19,6 +20,7 @@
19 20
20(define-module (tests services configuration) 21(define-module (tests services configuration)
21 #:use-module (gnu services configuration) 22 #:use-module (gnu services configuration)
23 #:use-module (guix diagnostics)
22 #:use-module (guix gexp) 24 #:use-module (guix gexp)
23 #:use-module (srfi srfi-34) 25 #:use-module (srfi srfi-34)
24 #:use-module (srfi srfi-64)) 26 #:use-module (srfi srfi-64))
@@ -43,6 +45,17 @@
43 80 45 80
44 (port-configuration-port (port-configuration))) 46 (port-configuration-port (port-configuration)))
45 47
48(test-equal "wrong type for a field"
49 '("configuration.scm" 57 11) ;error location
50 (guard (c ((configuration-error? c)
51 (let ((loc (error-location c)))
52 (list (basename (location-file loc))
53 (location-line loc)
54 (location-column loc)))))
55 (port-configuration
56 ;; This is line 56; the test relies on line/column numbers!
57 (port "This is not a number!"))))
58
46(define-configuration port-configuration-cs 59(define-configuration port-configuration-cs
47 (port (number 80) "The port number." empty-serializer)) 60 (port (number 80) "The port number." empty-serializer))
48 61