-
Notifications
You must be signed in to change notification settings - Fork 7
/
regen.rkt
45 lines (35 loc) · 1.34 KB
/
regen.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
;; This file is for regenerating test files
#lang racket
(require file/glob
raco/all-tools)
(define paths '(["tests/test-cases/*.rkt" ()]
["tests/benchmarks/*.rkt" ()]
["tests/config-tests/file.rkt" ("--config" "tests/config-tests/config.rkt")]))
(define out-ext "out")
(define raco-fmt (hash-ref (all-tools) "fmt"))
(define (regen ext)
(for ([test-suite (in-list paths)])
(match-define (list path args) test-suite)
(for ([f (in-list (glob path))])
(printf "formatting ~a\n" f)
(time
(with-output-to-file (format "~a.~a" f ext)
#:exists 'replace
(λ ()
(parameterize ([current-command-line-arguments
(apply vector (append args (list (~a f))))]
[current-namespace (make-base-namespace)])
(dynamic-require (second raco-fmt) #f))))))))
(module+ main
(regen out-ext))
(module+ test
(require rackunit)
(define check-ext "out-check")
(regen check-ext)
(for ([test-suite (in-list paths)])
(match-define (list path _) test-suite)
(for ([f (in-list (glob path))])
(with-check-info (['filename f])
(check-equal? (file->string (format "~a.~a" f check-ext))
(file->string (format "~a.~a" f out-ext))))
(delete-file (format "~a.~a" f check-ext)))))