Skip to content

Commit 3415fc6

Browse files
authored
Migrate the plot tests to use draw step files (#63)
Migrate the plot tests which generate plots to save and verify the draw steps using the method introduced in 05ac34e (pull request #62) From this migration experience, the following updates were made to the test method: * test data files are now compressed using `gzip` as some of the plots generated files larger than 10Mb * the plots are updated in-place, rather than moving them to a separate folder (named "auto"), this allows for easier inspection of a file' history (the ci.yml file was updated to upload new files from all sub-directories of the "plot-test" package) * the test run in ci.yml now runs all the files, even if they don't have a test module -- some of the plot tests already used rackunit, but the tests were not in a seprate submodule, these tests are now running in Github Actions (they were already running in DrDr) * some of the tests were not moved, and were left as they were -- these require a GUI visualization (e.g. the animation or slideshow tests), and they don't fit in this test model.
1 parent 891c435 commit 3415fc6

File tree

1,042 files changed

+2871
-1851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,042 files changed

+2871
-1851
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
racket-version: ["7.7", "current"]
1010
racket-variant: ["regular", "CS"]
1111
steps:
12-
- uses: actions/checkout@master
12+
- uses: actions/checkout@v2
1313
- uses: Bogdanp/[email protected]
1414
with:
1515
architecture: x64
@@ -38,12 +38,12 @@ jobs:
3838
# are in the `plot-test` package, so we don't expect any tests here, but
3939
# just in case someone wrote a test module...
4040

41-
- run: sudo xvfb-run raco test --no-run-if-absent --deps --package plot
41+
- run: sudo xvfb-run raco test --deps --package plot
4242

4343
# Install the plot-test package and run the tests
4444

4545
- run: sudo raco pkg install --batch --auto plot-test
46-
- run: sudo xvfb-run raco test --no-run-if-absent --package plot-test
46+
- run: sudo xvfb-run raco test --package plot-test
4747

4848
# If any of the plot-test tests failed, they will generate new draw step
4949
# files and sample images. Upload these as an Github Actions Artifact,
@@ -52,5 +52,5 @@ jobs:
5252
- uses: actions/upload-artifact@v2
5353
if: failure()
5454
with:
55-
name: 'Updated Data Files'
56-
path: plot-test/plot/tests/auto/data/new-*
55+
name: New Test Data Files ${{ matrix.racket-version }} ${{ matrix.racket-variant }}
56+
path: plot-test/plot/tests/**/test-data/new-*

plot-test/plot/tests/PRs/13620.rkt

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
#lang racket
2+
(require rackunit
3+
plot
4+
plot/utils
5+
racket/draw
6+
racket/runtime-path
7+
"../helpers.rkt")
28

3-
;; These tests pass when they terminate
9+
;; https://github.com/racket/gnats-bugs/blob/7e4bb9a65cd4783bef9936b576c5e06a5da3fb01/all/13620
410

5-
(require plot)
11+
(define (do-plot-contour-intervals output-fn)
12+
(output-fn (contour-intervals * -1 1 -1 1 #:alphas '())))
613

7-
(printf "The following three plots should be blank:~n")
8-
(plot (contour-intervals * -1 1 -1 1 #:alphas '()))
9-
(plot3d (contour-intervals3d * -1 1 -1 1 #:alphas '()))
10-
(plot3d (isosurfaces3d * -1 1 -1 1 -1 1 #:alphas '()))
14+
(define (do-plot-contour-intervals3d output-fn)
15+
(output-fn (contour-intervals3d * -1 1 -1 1 #:alphas '())))
1116

12-
(with-handlers ([exn? (λ (_) (void))])
13-
(plot (stacked-histogram (list (vector 'a 1))
14-
#:alphas '())))
17+
(define (do-plot-isosurface3d output-fn)
18+
(output-fn (isosurfaces3d * -1 1 -1 1 -1 1 #:alphas '())))
1519

16-
(with-handlers ([exn? (λ (_) (void))])
17-
(plot3d (stacked-histogram3d (list (vector 'a 'a 1))
18-
#:alphas '())))
20+
(define-runtime-path gnats13620-ci-data "./test-data/gnats13620-ci.dat")
21+
(define-runtime-path gnats13620-ci3d-data "./test-data/gnats13620-ci3d.dat")
22+
(define-runtime-path gnats13620-is3d-data "./test-data/gnats13620-is3d.dat")
23+
24+
(define gnats13620-test-suite
25+
(test-suite
26+
"GNATS#13620: stacked-histogram loops when given an empty list of labels"
27+
(test-case "gnats13620-contour-intervals"
28+
(check-draw-steps do-plot-contour-intervals gnats13620-ci-data))
29+
(test-case "gnats13620-contour-intervals3d"
30+
(check-draw-steps-3d do-plot-contour-intervals3d gnats13620-ci3d-data))
31+
(test-case "gnats13620-isosurface3d"
32+
(check-draw-steps-3d do-plot-isosurface3d gnats13620-is3d-data))
33+
(test-case "gnats13620-stacked-histogram"
34+
;; Should fail with a "could not determine sensible plot bounds" message
35+
(check-exn
36+
exn:fail?
37+
(lambda () (plot (stacked-histogram (list (vector 'a 1)) #:alphas '())))))
38+
(test-case "gnats13620-histogram3d"
39+
;; Should fail with a "could not determine sensible plot bounds" message
40+
(check-exn
41+
exn:fail?
42+
(lambda () (plot3d (stacked-histogram3d (list (vector 'a 'a 1)) #:alphas '())))))))
43+
44+
(module+ test
45+
(require rackunit/text-ui)
46+
(run-tests gnats13620-test-suite))

plot-test/plot/tests/PRs/24.rkt

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
1-
#lang racket/base
2-
(require plot plot/utils)
1+
#lang racket
2+
(require rackunit
3+
plot
4+
plot/utils
5+
racket/draw
6+
racket/runtime-path
7+
"../helpers.rkt")
8+
9+
;; Tests for: https://github.com/racket/plot/pull/24
310

411
;; Plot all `known-point-symbols`.
5-
;; This test succeeds when it terminates.
12+
(define (do-plot output-fn)
13+
(define NUM-ROWS 3)
14+
(define YOFFSET 4)
15+
(parameterize ([plot-x-axis? #f]
16+
[plot-y-axis? #f]
17+
[plot-x-far-axis? #f]
18+
[plot-y-far-axis? #f]
19+
[plot-decorations? #f])
20+
(output-fn
21+
(for/list ([s (in-list known-point-symbols)]
22+
[i (in-naturals)])
23+
(points (list (list (modulo i NUM-ROWS) (- (* YOFFSET (quotient i NUM-ROWS)))))
24+
#:sym s
25+
#:size 10))
26+
#:x-min -1
27+
#:x-max NUM-ROWS
28+
#:y-min (- (* YOFFSET (add1 (quotient (length known-point-symbols) NUM-ROWS))))
29+
#:y-max 1)))
30+
31+
(define-runtime-path pr24-data "./test-data/pr24.dat")
632

7-
(define NUM-ROWS 3)
8-
(define YOFFSET 4)
33+
(define pr24-test-suite
34+
(test-suite
35+
"PR#24: Fix typo, 'cirlce2' => 'circle2'"
36+
(test-case "pr24" (check-draw-steps do-plot pr24-data))))
937

10-
(parameterize ([plot-x-axis? #f]
11-
[plot-y-axis? #f]
12-
[plot-x-far-axis? #f]
13-
[plot-y-far-axis? #f]
14-
[plot-decorations? #f])
15-
(plot
16-
(for/list ([s (in-list known-point-symbols)]
17-
[i (in-naturals)])
18-
(points (list (list (modulo i NUM-ROWS) (- (* YOFFSET (quotient i NUM-ROWS)))))
19-
#:sym s
20-
#:size 10))
21-
#:x-min -1
22-
#:x-max NUM-ROWS
23-
#:y-min (- (+ 1 (* YOFFSET (quotient (length known-point-symbols) NUM-ROWS))))
24-
#:y-max 1))
38+
(module+ test
39+
(require rackunit/text-ui)
40+
(run-tests pr24-test-suite))

0 commit comments

Comments
 (0)