[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08/11: tests: Do not fetch and print the random seed from the top level.
From: |
guix-commits |
Subject: |
08/11: tests: Do not fetch and print the random seed from the top level. |
Date: |
Tue, 20 Oct 2020 10:32:10 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit ccf3dcba3dbddd4fd8daf0b5641ba997de12647a
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Oct 20 15:57:35 2020 +0200
tests: Do not fetch and print the random seed from the top level.
* guix/tests.scm (%seed): Turn into a memoizing procedure.
(random-text, random-bytevector): Adjust accordingly.
---
guix/tests.scm | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/guix/tests.scm b/guix/tests.scm
index 3ccf049..fc3d521 100644
--- a/guix/tests.scm
+++ b/guix/tests.scm
@@ -160,15 +160,17 @@ too expensive to build entirely in the test store."
number->string)
(logxor (getpid) (car (gettimeofday)))))
-(define %seed
+(define (%seed)
(let ((seed (random-seed)))
(format (current-error-port) "random seed for tests: ~a~%"
seed)
- (seed->random-state seed)))
+ (let ((result (seed->random-state seed)))
+ (set! %seed (lambda () result))
+ result)))
(define (random-text)
"Return the hexadecimal representation of a random number."
- (number->string (random (expt 2 256) %seed) 16))
+ (number->string (random (expt 2 256) (%seed)) 16))
(define (random-bytevector n)
"Return a random bytevector of N bytes."
@@ -176,7 +178,7 @@ too expensive to build entirely in the test store."
(let loop ((i 0))
(if (< i n)
(begin
- (bytevector-u8-set! bv i (random 256 %seed))
+ (bytevector-u8-set! bv i (random 256 (%seed)))
(loop (1+ i)))
bv))))
- branch master updated (6ea61b4 -> 5f92f51), guix-commits, 2020/10/20
- 02/11: doc: Replace @example with @lisp in "Build Phases"., guix-commits, 2020/10/20
- 01/11: download: Update docstring., guix-commits, 2020/10/20
- 04/11: gnu: guile2.0-git: Remove now unnecessary libgit2 special case., guix-commits, 2020/10/20
- 05/11: packages: Better preserve object identity when rewriting., guix-commits, 2020/10/20
- 07/11: graph: Fix typo in docstring., guix-commits, 2020/10/20
- 03/11: graph: Adjust test for recent OCaml changes., guix-commits, 2020/10/20
- 08/11: tests: Do not fetch and print the random seed from the top level.,
guix-commits <=
- 09/11: guix build: Add '--with-debug-info'., guix-commits, 2020/10/20
- 11/11: news: Add entry for '--with-debug-info'., guix-commits, 2020/10/20
- 06/11: gnu: poppler: Always use the same 'cairo-sans-poppler' variant., guix-commits, 2020/10/20
- 10/11: guix build: Move package transformation options behind '--help-transform'., guix-commits, 2020/10/20