make plot tests more drdr friendly

This avoids a race-condition when one test deletes the file
that another creates and also avoids cluttering the current
directory.
This commit is contained in:
Robby Findler 2014-05-18 07:38:56 -05:00
parent 6f2fc3ecde
commit 6efa9185bc
6 changed files with 42 additions and 30 deletions

View File

@ -4,14 +4,16 @@
plot/bitmap plot/bitmap
racket/draw) racket/draw)
(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png"))
(check-true (is-a? (plot (function sin -4 4) (check-true (is-a? (plot (function sin -4 4)
#:out-file "sin.png") #:out-file sin.png)
bitmap%)) bitmap%))
(check-true (is-a? (read-bitmap "sin.png") bitmap%)) (check-true (is-a? (read-bitmap sin.png) bitmap%))
(delete-file "sin.png") (delete-file sin.png)
(define times.png (make-temporary-file "plot-bitmap-times-test~a.png"))
(check-true (is-a? (plot3d (contour-intervals3d * -4 4 -4 4) (check-true (is-a? (plot3d (contour-intervals3d * -4 4 -4 4)
#:out-file "times.png") #:out-file times.png)
bitmap%)) bitmap%))
(check-true (is-a? (read-bitmap "times.png") bitmap%)) (check-true (is-a? (read-bitmap times.png) bitmap%))
(delete-file "times.png") (delete-file times.png)

View File

@ -11,10 +11,12 @@
(check-true (is-a? (plot-bitmap (function sin -4 4)) bitmap%)) (check-true (is-a? (plot-bitmap (function sin -4 4)) bitmap%))
(check-true (is-a? (plot3d-bitmap (contour-intervals3d * -4 4 -4 4)) bitmap%)) (check-true (is-a? (plot3d-bitmap (contour-intervals3d * -4 4 -4 4)) bitmap%))
(check-true (void? (plot-file (function sin -4 4) "sin.png"))) (define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png"))
(check-true (is-a? (read-bitmap "sin.png") bitmap%)) (check-true (void? (plot-file (function sin -4 4) sin.png)))
(delete-file "sin.png") (check-true (is-a? (read-bitmap sin.png) bitmap%))
(delete-file sin.png)
(check-true (void? (plot3d-file (contour-intervals3d * -4 4 -4 4) "times.png"))) (define times.png (make-temporary-file "plot-bitmap-times-test~a.png"))
(check-true (is-a? (read-bitmap "times.png") bitmap%)) (check-true (void? (plot3d-file (contour-intervals3d * -4 4 -4 4) times.png)))
(delete-file "times.png") (check-true (is-a? (read-bitmap times.png) bitmap%))
(delete-file times.png)

View File

@ -5,12 +5,14 @@
pict pict
racket/draw) racket/draw)
(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png"))
(check-true (pict? (plot (function sin -4 4) (check-true (pict? (plot (function sin -4 4)
#:out-file "sin.png"))) #:out-file sin.png)))
(check-true (is-a? (read-bitmap "sin.png") bitmap%)) (check-true (is-a? (read-bitmap sin.png) bitmap%))
(delete-file "sin.png") (delete-file sin.png)
(define times.png (make-temporary-file "plot-bitmap-times-test~a.png"))
(check-true (pict? (plot3d (contour-intervals3d * -4 4 -4 4) (check-true (pict? (plot3d (contour-intervals3d * -4 4 -4 4)
#:out-file "times.png"))) #:out-file times.png)))
(check-true (is-a? (read-bitmap "times.png") bitmap%)) (check-true (is-a? (read-bitmap times.png) bitmap%))
(delete-file "times.png") (delete-file times.png)

View File

@ -2,10 +2,12 @@
(require plot/typed/bitmap) (require plot/typed/bitmap)
(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png"))
(plot (function sin -4 4) (plot (function sin -4 4)
#:out-file "sin.png") #:out-file sin.png)
(delete-file "sin.png") (delete-file sin.png)
(define times.png (make-temporary-file "plot-bitmap-times-test~a.png"))
(plot3d (contour-intervals3d * -4 4 -4 4) (plot3d (contour-intervals3d * -4 4 -4 4)
#:out-file "times.png") #:out-file times.png)
(delete-file "times.png") (delete-file times.png)

View File

@ -13,8 +13,10 @@
(plot-bitmap (function sin -4 4)) (plot-bitmap (function sin -4 4))
(plot3d-bitmap (contour-intervals3d * -4 4 -4 4)) (plot3d-bitmap (contour-intervals3d * -4 4 -4 4))
(check-true (void? (plot-file (function sin -4 4) "sin.png"))) (define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png"))
(delete-file "sin.png") (check-true (void? (plot-file (function sin -4 4) sin.png)))
(delete-file sin.png)
(check-true (void? (plot3d-file (contour-intervals3d * -4 4 -4 4) "times.png"))) (define times.png (make-temporary-file "plot-bitmap-times-test~a.png"))
(delete-file "times.png") (check-true (void? (plot3d-file (contour-intervals3d * -4 4 -4 4) times.png)))
(delete-file times.png)

View File

@ -7,10 +7,12 @@
pict pict
[#:opaque Pict pict?]) [#:opaque Pict pict?])
(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png"))
(check-true (pict? (plot (function sin -4 4) (check-true (pict? (plot (function sin -4 4)
#:out-file "sin.png"))) #:out-file sin.png)))
(delete-file "sin.png") (delete-file sin.png)
(define times.png (make-temporary-file "plot-bitmap-times-test~a.png"))
(check-true (pict? (plot3d (contour-intervals3d * -4 4 -4 4) (check-true (pict? (plot3d (contour-intervals3d * -4 4 -4 4)
#:out-file "times.png"))) #:out-file times.png)))
(delete-file "times.png") (delete-file times.png)