Skip to content

Commit

Permalink
feat: add a consistency check
Browse files Browse the repository at this point in the history
  • Loading branch information
sorawee committed Jul 13, 2023
1 parent 49f37e6 commit fafe939
Show file tree
Hide file tree
Showing 40 changed files with 20,644 additions and 14 deletions.
4 changes: 2 additions & 2 deletions info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
(define version "0.0.2")
(define pkg-authors '(sorawee))
(define license '(Apache-2.0 OR MIT))
(define compile-omit-files '("tests" "scribblings/examples" "experiments"))
(define test-omit-paths '("tests" "scribblings/examples" "experiments"))
(define compile-omit-files '("tests/test-cases" "tests/benchmarks" "scribblings/examples" "experiments"))
(define test-omit-paths '("tests/test-cases" "tests/benchmarks" "scribblings/examples" "experiments"))
(define raco-commands
'(("fmt"
fmt/raco
Expand Down
9 changes: 5 additions & 4 deletions main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
#:max-blank-lines [max-blank-lines (current-max-blank-lines)]
#:indent [indent (current-indent)])
(define doc (realign (read-all program-source source max-blank-lines)))
(match-define-values [(list s) _ real _]
(match-define-values [(list (info s tainted? _)) _ real _]
(time-apply
(λ ()
(pretty-format/factory
(pretty-format/factory/info
(pretty-doc doc (compose-formatter-map formatter-map standard-formatter-map))
(cost-factory
(match-lambda**
Expand Down Expand Up @@ -70,9 +70,10 @@

(define all-lines (string-split s "\n"))

(log-fmt-debug "([duration ~a] [lines ~a])"
(log-fmt-debug "([duration ~a] [lines ~a] [tainted? ~a])"
(exact->inexact (/ real 1000))
(length all-lines))
(length all-lines)
(if tainted? "true" "false"))

(string-join (for/list ([line (in-list all-lines)])
(string-trim line #:left? #f))
Expand Down
33 changes: 25 additions & 8 deletions regen.rkt
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
;; This file is for regenerating test files

#lang racket

(require file/glob)

(module+ main
(define to-self #;'("conventions.rkt" "core.rkt")
'())
(define to-out (flatten (map glob '("tests/*.rkt"))))
(define paths '("tests/test-cases/*.rkt"
"tests/benchmarks/*.rkt"))

(for ([f to-self])
(system (format "raco fmt -i ~a" (~a f))))
(define out-ext "out")

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

(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)
(delete-file (format "~a.~a" f check-ext))))

0 comments on commit fafe939

Please sign in to comment.