From ce72c780746776a86f59747f5eff8731cb4ff39b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 5 Mar 2015 22:00:11 +0100 Subject: store: Attempt to decode build logs as UTF-8. * guix/serialization.scm (read-maybe-utf8-string): New procedure. * guix/store.scm (process-stderr): Use it for the build log and errors. * tests/store.scm ("current-build-output-port, UTF-8", "current-build-output-port, UTF-8 + garbage"): New tests. --- tests/store.scm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/store.scm b/tests/store.scm index ee783be846..9ed78be085 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -25,6 +25,7 @@ #:use-module (guix packages) #:use-module (guix derivations) #:use-module (guix serialization) + #:use-module (guix gexp) #:use-module (gnu packages) #:use-module (gnu packages bootstrap) #:use-module (ice-9 match) @@ -268,6 +269,42 @@ (list a b c d w x y))) (lset= string=? s1 s3))))) +(test-assert "current-build-output-port, UTF-8" + ;; Are UTF-8 strings in the build log properly interpreted? + (string-contains + (with-fluids ((%default-port-encoding "UTF-8")) ;for the string port + (call-with-output-string + (lambda (port) + (parameterize ((current-build-output-port port)) + (let* ((s "Here’s a Greek letter: λ.") + (d (build-expression->derivation + %store "foo" `(display ,s) + #:guile-for-build + (package-derivation s %bootstrap-guile (%current-system))))) + (guard (c ((nix-protocol-error? c) #t)) + (build-derivations %store (list d)))))))) + "Here’s a Greek letter: λ.")) + +(test-assert "current-build-output-port, UTF-8 + garbage" + ;; What about a mixture of UTF-8 + garbage? + (string-contains + (with-fluids ((%default-port-encoding "UTF-8")) ;for the string port + (call-with-output-string + (lambda (port) + (parameterize ((current-build-output-port port)) + (let ((d (build-expression->derivation + %store "foo" + `(begin + (use-modules (rnrs io ports)) + (display "garbage: ") + (put-bytevector (current-output-port) #vu8(128)) + (display "lambda: λ\n")) + #:guile-for-build + (package-derivation %store %bootstrap-guile)))) + (guard (c ((nix-protocol-error? c) #t)) + (build-derivations %store (list d)))))))) + "garbage: ?lambda: λ")) + (test-assert "log-file, derivation" (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '())) (s (add-to-store %store "bash" #t "sha256" -- cgit v1.2.3