guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 02/05: comm: Serialize pairs.


From: Ludovic Courtès
Subject: [shepherd] 02/05: comm: Serialize pairs.
Date: Wed, 8 May 2019 10:24:36 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit 15c032da1cd294f8141607e0bf36e257f8b1d91a
Author: Ludovic Courtès <address@hidden>
Date:   Wed May 8 15:49:24 2019 +0200

    comm: Serialize pairs.
    
    Fixes <https://bugs.gnu.org/35631>.
    Reported by Gábor Boskovits <address@hidden>.
    
    Previously shepherd would die on 'syntax-error exceptions: its arguments
    include an alist for the source location, and there was no
    'result->sexp' method for pairs.
    
    * modules/shepherd/comm.scm (result->sexp <pair>): New method.
    * tests/basic.sh: Add test.
---
 modules/shepherd/comm.scm | 4 +++-
 tests/basic.sh            | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/shepherd/comm.scm b/modules/shepherd/comm.scm
index 25c1a7e..b90b893 100644
--- a/modules/shepherd/comm.scm
+++ b/modules/shepherd/comm.scm
@@ -1,5 +1,5 @@
 ;; comm.scm -- Communication between processes and general output.
-;; Copyright (C) 2013, 2014, 2016, 2018 Ludovic Courtès <address@hidden>
+;; Copyright (C) 2013, 2014, 2016, 2018, 2019 Ludovic Courtès <address@hidden>
 ;; Copyright (C) 2002, 2003 Wolfgang Jährling <address@hidden>
 ;; Copyright (C) 2018 Danny Milosavljevic <address@hidden>
 ;;
@@ -163,6 +163,8 @@ wrong---premature end-of-file, invalid sexp, etc."
 (define-method (result->sexp (symbol <symbol>)) symbol)
 (define-method (result->sexp (string <string>)) string)
 (define-method (result->sexp (list <list>)) (map result->sexp list))
+(define-method (result->sexp (pair <pair>))
+  (cons (result->sexp (car pair)) (result->sexp (cdr pair))))
 (define-method (result->sexp (kw <keyword>)) kw)
 (define-method (result->sexp (obj <top>)) (object->string obj))
 
diff --git a/tests/basic.sh b/tests/basic.sh
index a54b5a5..2d67b1c 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -215,6 +215,15 @@ $herd eval root "(action root-service 'unload 
\"test-loaded\")"
 if $herd status test-loaded
 then false; else true; fi
 
+# Load code that triggers a syntax error and make sure that shepherd survives.
+cat > "$confdir/some-conf.scm" <<EOF
+(define x y z)
+EOF
+
+if $herd load root "$confdir/some-conf.scm"
+then false; else true; fi
+$herd status                   # still here?
+
 # Evaluate silly code, make sure nothing breaks.
 if $herd eval root '(/ 0 0)'
 then false; else true; fi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]