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.master
parent
f59ec1de94
commit
ccf3dcba3d
|
@ -160,15 +160,17 @@ too expensive to build entirely in the test store."
|
||||||
number->string)
|
number->string)
|
||||||
(logxor (getpid) (car (gettimeofday)))))
|
(logxor (getpid) (car (gettimeofday)))))
|
||||||
|
|
||||||
(define %seed
|
(define (%seed)
|
||||||
(let ((seed (random-seed)))
|
(let ((seed (random-seed)))
|
||||||
(format (current-error-port) "random seed for tests: ~a~%"
|
(format (current-error-port) "random seed for tests: ~a~%"
|
||||||
seed)
|
seed)
|
||||||
(seed->random-state seed)))
|
(let ((result (seed->random-state seed)))
|
||||||
|
(set! %seed (lambda () result))
|
||||||
|
result)))
|
||||||
|
|
||||||
(define (random-text)
|
(define (random-text)
|
||||||
"Return the hexadecimal representation of a random number."
|
"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)
|
(define (random-bytevector n)
|
||||||
"Return a random bytevector of N bytes."
|
"Return a random bytevector of N bytes."
|
||||||
|
@ -176,7 +178,7 @@ too expensive to build entirely in the test store."
|
||||||
(let loop ((i 0))
|
(let loop ((i 0))
|
||||||
(if (< i n)
|
(if (< i n)
|
||||||
(begin
|
(begin
|
||||||
(bytevector-u8-set! bv i (random 256 %seed))
|
(bytevector-u8-set! bv i (random 256 (%seed)))
|
||||||
(loop (1+ i)))
|
(loop (1+ i)))
|
||||||
bv))))
|
bv))))
|
||||||
|
|
||||||
|
|
Reference in New Issue