diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-03-16 15:03:01 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-03-16 15:48:52 +0100 |
commit | 47960b55268220ca1cb7d2fed41c53873181d816 (patch) | |
tree | a0ca790a00c22231eabc008d6cf3f5fa60830c5f /tests | |
parent | 5d4af22ef21b71556e0f9a2ddc2d33366858813b (diff) | |
download | guix-47960b55268220ca1cb7d2fed41c53873181d816.tar.gz |
system: Improve 'read-boot-parameters' incompatibility diagnostic.
Previously, when reading an incompatible "parameters" file, 'guix system' would print a warning and then crash with a wrong-type-arg backtrace because code expects 'read-boot-parameters' to always return a <boot-parameters> record. * gnu/system.scm (read-boot-parameters): Upon incompatibility, raise an error instead of returning #f. Also raise a '&fix-hint' condition. * tests/boot-parameters.scm ("read, construction, mandatory fields"): Define 'test-read-boot-parameters' as a macro; expect 'formatted-message?' exceptions rather than #f returns.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/boot-parameters.scm | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/boot-parameters.scm b/tests/boot-parameters.scm index d4b680df2e..8e48e1775e 100644 --- a/tests/boot-parameters.scm +++ b/tests/boot-parameters.scm @@ -28,9 +28,11 @@ #:use-module (gnu system) #:use-module (gnu system file-systems) #:use-module (gnu system uuid) + #:use-module ((guix diagnostics) #:select (formatted-message?)) #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix tests) + #:use-module (srfi srfi-34) #:use-module (srfi srfi-64) #:use-module (rnrs bytevectors)) @@ -151,13 +153,18 @@ ;; XXX: <warning: unrecognized boot parameters at '#f'> (test-assert "read, construction, mandatory fields" - (not (or (test-read-boot-parameters #:version #false) - (test-read-boot-parameters #:version 'false) - (test-read-boot-parameters #:version -1) - (test-read-boot-parameters #:version "0") - (test-read-boot-parameters #:root-device #false) - (test-read-boot-parameters #:kernel #false) - (test-read-boot-parameters #:label #false)))) + (let-syntax ((test-read-boot-parameters + (syntax-rules () + ((_ args ...) + (guard (c ((formatted-message? c) #f)) + (test-read-boot-parameters args ...)))))) + (not (or (test-read-boot-parameters #:version #false) + (test-read-boot-parameters #:version 'false) + (test-read-boot-parameters #:version -1) + (test-read-boot-parameters #:version "0") + (test-read-boot-parameters #:root-device #false) + (test-read-boot-parameters #:kernel #false) + (test-read-boot-parameters #:label #false))))) (test-assert "read, construction, optional fields" (and (test-read-boot-parameters #:bootloader-name #false) |