From 6efa9185bca30f1760fbdf405cbd80e64587ff9a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 18 May 2014 07:38:56 -0500 Subject: [PATCH] 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. --- .../plot-pkgs/plot-test/plot/tests/plot-bitmap.rkt | 14 ++++++++------ .../plot-pkgs/plot-test/plot/tests/plot-no-gui.rkt | 14 ++++++++------ pkgs/plot-pkgs/plot-test/plot/tests/plot-pict.rkt | 14 ++++++++------ .../plot-test/plot/tests/typed/plot-bitmap.rkt | 10 ++++++---- .../plot-test/plot/tests/typed/plot-no-gui.rkt | 10 ++++++---- .../plot-test/plot/tests/typed/plot-pict.rkt | 10 ++++++---- 6 files changed, 42 insertions(+), 30 deletions(-) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/plot-bitmap.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/plot-bitmap.rkt index 6ebc9ef892..55bfc3076e 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/plot-bitmap.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/plot-bitmap.rkt @@ -4,14 +4,16 @@ plot/bitmap racket/draw) +(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png")) (check-true (is-a? (plot (function sin -4 4) - #:out-file "sin.png") + #:out-file sin.png) bitmap%)) -(check-true (is-a? (read-bitmap "sin.png") bitmap%)) -(delete-file "sin.png") +(check-true (is-a? (read-bitmap sin.png) bitmap%)) +(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) - #:out-file "times.png") + #:out-file times.png) bitmap%)) -(check-true (is-a? (read-bitmap "times.png") bitmap%)) -(delete-file "times.png") +(check-true (is-a? (read-bitmap times.png) bitmap%)) +(delete-file times.png) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/plot-no-gui.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/plot-no-gui.rkt index a11d9b19c2..ad4f2093dd 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/plot-no-gui.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/plot-no-gui.rkt @@ -11,10 +11,12 @@ (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 (void? (plot-file (function sin -4 4) "sin.png"))) -(check-true (is-a? (read-bitmap "sin.png") bitmap%)) -(delete-file "sin.png") +(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png")) +(check-true (void? (plot-file (function sin -4 4) 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"))) -(check-true (is-a? (read-bitmap "times.png") bitmap%)) -(delete-file "times.png") +(define times.png (make-temporary-file "plot-bitmap-times-test~a.png")) +(check-true (void? (plot3d-file (contour-intervals3d * -4 4 -4 4) times.png))) +(check-true (is-a? (read-bitmap times.png) bitmap%)) +(delete-file times.png) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/plot-pict.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/plot-pict.rkt index d0f7209468..c38bbda683 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/plot-pict.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/plot-pict.rkt @@ -5,12 +5,14 @@ pict racket/draw) +(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png")) (check-true (pict? (plot (function sin -4 4) - #:out-file "sin.png"))) -(check-true (is-a? (read-bitmap "sin.png") bitmap%)) -(delete-file "sin.png") + #:out-file sin.png))) +(check-true (is-a? (read-bitmap sin.png) bitmap%)) +(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) - #:out-file "times.png"))) -(check-true (is-a? (read-bitmap "times.png") bitmap%)) -(delete-file "times.png") + #:out-file times.png))) +(check-true (is-a? (read-bitmap times.png) bitmap%)) +(delete-file times.png) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-bitmap.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-bitmap.rkt index 4d1f660b26..b5aa188a13 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-bitmap.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-bitmap.rkt @@ -2,10 +2,12 @@ (require plot/typed/bitmap) +(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png")) (plot (function sin -4 4) - #:out-file "sin.png") -(delete-file "sin.png") + #:out-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) - #:out-file "times.png") -(delete-file "times.png") + #:out-file times.png) +(delete-file times.png) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-no-gui.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-no-gui.rkt index 813dc516d7..0e097da533 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-no-gui.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-no-gui.rkt @@ -13,8 +13,10 @@ (plot-bitmap (function sin -4 4)) (plot3d-bitmap (contour-intervals3d * -4 4 -4 4)) -(check-true (void? (plot-file (function sin -4 4) "sin.png"))) -(delete-file "sin.png") +(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.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"))) -(delete-file "times.png") +(define times.png (make-temporary-file "plot-bitmap-times-test~a.png")) +(check-true (void? (plot3d-file (contour-intervals3d * -4 4 -4 4) times.png))) +(delete-file times.png) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-pict.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-pict.rkt index 178e688b69..1e24ee360d 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-pict.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/typed/plot-pict.rkt @@ -7,10 +7,12 @@ pict [#:opaque Pict pict?]) +(define sin.png (make-temporary-file "plot-bitmap-sin-test~a.png")) (check-true (pict? (plot (function sin -4 4) - #:out-file "sin.png"))) -(delete-file "sin.png") + #:out-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) - #:out-file "times.png"))) -(delete-file "times.png") + #:out-file times.png))) +(delete-file times.png)