examples: random: Fail evaluation once in a while.
* examples/random-jobs.scm (make-random-jobs): Fail once in a while. (%seed, %state): New variables. (random-derivation): Use %SEED.
This commit is contained in:
parent
2c712d35df
commit
9a7e567bf2
|
@ -30,20 +30,26 @@
|
||||||
(#:description "dummy job")
|
(#:description "dummy job")
|
||||||
(#:long-description "really dummy job"))))
|
(#:long-description "really dummy job"))))
|
||||||
|
|
||||||
|
(define %seed
|
||||||
|
(logxor (cdr (gettimeofday))
|
||||||
|
(car (gettimeofday))
|
||||||
|
(cdr (gettimeofday))))
|
||||||
|
|
||||||
|
(define %state
|
||||||
|
(seed->random-state %seed))
|
||||||
|
|
||||||
(define* (random-derivation store #:optional (suffix ""))
|
(define* (random-derivation store #:optional (suffix ""))
|
||||||
(let ((nonce (random 1e6)))
|
(let ((nonce (random 1e6)))
|
||||||
(run-with-store store
|
(run-with-store store
|
||||||
(gexp->derivation (string-append "random" suffix)
|
(gexp->derivation (string-append "random" suffix)
|
||||||
#~(let* ((seed (logxor #$(cdr (gettimeofday))
|
#~(let ((state (seed->random-state #$%seed)))
|
||||||
(car (gettimeofday))
|
|
||||||
(cdr (gettimeofday))))
|
|
||||||
(state (seed->random-state seed)))
|
|
||||||
(sleep (pk 'sleeping (random 10 state)))
|
(sleep (pk 'sleeping (random 10 state)))
|
||||||
(when (zero? (random 4 state))
|
(when (zero? (random 4 state))
|
||||||
(error "we're faillliiiiing!"))
|
(error "we're faillliiiiing!"))
|
||||||
#$nonce
|
#$nonce
|
||||||
(mkdir #$output))))))
|
(mkdir #$output))))))
|
||||||
|
|
||||||
|
|
||||||
(define (make-random-jobs store arguments)
|
(define (make-random-jobs store arguments)
|
||||||
(let ((checkout (assq-ref arguments 'cuirass)))
|
(let ((checkout (assq-ref arguments 'cuirass)))
|
||||||
(format (current-error-port)
|
(format (current-error-port)
|
||||||
|
@ -51,6 +57,9 @@
|
||||||
(assq-ref checkout 'file-name)
|
(assq-ref checkout 'file-name)
|
||||||
(assq-ref checkout 'revision)))
|
(assq-ref checkout 'revision)))
|
||||||
|
|
||||||
|
(when (zero? (random 7 %state))
|
||||||
|
(error "Evaluation is failing!"))
|
||||||
|
|
||||||
(unfold (cut > <> 10)
|
(unfold (cut > <> 10)
|
||||||
(lambda (i)
|
(lambda (i)
|
||||||
(let ((suffix (number->string i)))
|
(let ((suffix (number->string i)))
|
||||||
|
|
Loading…
Reference in New Issue