hash: Close or flush sha256 output ports before calling their 'get' procedure.

Slightly different buffering of custom binary output ports in Guile 2.1.7
would lead tests missing 'close-port' or 'force-output' to fail.

* tests/hash.scm ("open-sha256-port, hello"): Add call to 'force-output'
before call to 'get'.
* tests/nar.scm ("write-file puts file in C locale collation order"):
Call 'close-port' before calling 'get-hash'.
This commit is contained in:
Ludovic Courtès 2017-03-08 15:04:18 +01:00
parent 19c1ac8d88
commit 6f38960055
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 4 additions and 2 deletions

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013, 2014, 2017 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -67,6 +67,7 @@ (define (supports-unbuffered-cbip?)
(let-values (((port get) (let-values (((port get)
(open-sha256-port))) (open-sha256-port)))
(put-bytevector port (string->utf8 "hello world")) (put-bytevector port (string->utf8 "hello world"))
(force-output port)
(get))) (get)))
(test-assert "port-sha256" (test-assert "port-sha256"

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -186,6 +186,7 @@ (define (touch file)
(lambda () (lambda ()
(let-values (((port get-hash) (open-sha256-port))) (let-values (((port get-hash) (open-sha256-port)))
(write-file input port) (write-file input port)
(close-port port)
(get-hash))) (get-hash)))
(lambda () (lambda ()
(rm-rf input))))) (rm-rf input)))))