Skip to content

Commit

Permalink
test: correct the consistency check
Browse files Browse the repository at this point in the history
  • Loading branch information
sorawee committed Jul 19, 2023
1 parent a7c0089 commit f1f1d10
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions regen.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,38 @@

#lang racket

(require file/glob)
(require file/glob
raco/all-tools)

(define paths '("tests/test-cases/*.rkt"
"tests/benchmarks/*.rkt"))

(define out-ext "out")

(define raco-fmt (hash-ref (all-tools) "fmt"))

(define (regen ext)
(for ([f (flatten (map glob paths))])
(for ([f (flatten (map glob paths))] [i (in-naturals)])
(printf "formatting ~a\n" f)
(system (format "raco fmt ~a > ~a.~a" f f ext))))

(with-output-to-file (format "~a.~a" f ext)
#:exists 'replace
(λ ()
(parameterize ([current-command-line-arguments (vector (~a f))]
[current-namespace (make-base-namespace)])
(dynamic-require (second raco-fmt) #f))))))

(module+ main
(regen out-ext))

(module+ test
(require rackunit)

(define-check (check-file f)
(unless (equal? (file->string (format "~a.~a" f check-ext))
(file->string (format "~a.~a" f out-ext)))
(fail-check (format "Found a mismatch on '~a'" f))))

(define check-ext "out-check")
(regen check-ext)
(for ([f (flatten (map glob paths))])
(check-file f)
(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))))

0 comments on commit f1f1d10

Please sign in to comment.