From babd03bd4529fa0457dd2f2c1305137561985e98 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 27 Jan 2020 14:34:26 -0800 Subject: [PATCH] refac --- quad/qtest/paths-to-test.rkt | 19 +++++++++++++++---- quad/qtest/update-tests.rkt | 9 ++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/quad/qtest/paths-to-test.rkt b/quad/qtest/paths-to-test.rkt index 0370ba3c..cae331c8 100644 --- a/quad/qtest/paths-to-test.rkt +++ b/quad/qtest/paths-to-test.rkt @@ -1,14 +1,25 @@ #lang racket/base -(require racket/runtime-path) +(require racket/runtime-path + racket/match + quadwriter) (provide (all-defined-out)) (define-runtime-path here ".") -(define (test-paths) +(define (find-test-paths) (for/list ([test-path (in-directory here)] #:when (regexp-match #rx"test-.*.rkt$" (path->string test-path))) - test-path)) + test-path)) (define (test-pdf-name path) - (path-add-extension (path-replace-extension path #".pdf") #"" #"-tester.")) \ No newline at end of file + (path-add-extension (path-replace-extension path #".pdf") #"" #"-tester.")) + +(define (update-test-pdf test-path-arg) + (define test-path (match test-path-arg + [(? absolute-path? ap) ap] + [rp (build-path here rp)])) + (define-values (dir name _) (split-path test-path)) + (displayln (path->string name)) + (time (parameterize ([quadwriter-test-mode #t]) + (render-pdf (dynamic-require test-path 'doc) (test-pdf-name test-path) test-path)))) \ No newline at end of file diff --git a/quad/qtest/update-tests.rkt b/quad/qtest/update-tests.rkt index 8cf2ab85..564f71de 100644 --- a/quad/qtest/update-tests.rkt +++ b/quad/qtest/update-tests.rkt @@ -1,9 +1,4 @@ #lang racket/base -(require quadwriter - "paths-to-test.rkt") +(require quadwriter "paths-to-test.rkt") -(for ([test-path (in-list (test-paths))]) - (define-values (dir name _) (split-path test-path)) - (displayln (path->string name)) - (time (parameterize ([quadwriter-test-mode #t]) - (render-pdf (dynamic-require test-path 'doc) (test-pdf-name test-path) test-path)))) \ No newline at end of file +(for-each update-test-pdf (find-test-paths))