From 2f85a1955f6842fb75e993c792dc5c0ceb52e2c0 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 3 Sep 2015 17:04:02 -0700 Subject: [PATCH] add unit test to cache --- cache.rkt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cache.rkt b/cache.rkt index 5fd1bfe..8d71303 100644 --- a/cache.rkt +++ b/cache.rkt @@ -4,7 +4,7 @@ ;; The cache is a hash with paths as keys. ;; The cache values are also hashes, with key/value pairs for that path. -(provide reset-cache preheat-cache cached-require paths->key) +(provide reset-cache preheat-cache cached-require paths->key key->source-path) (define (reset-cache [starting-dir (world:current-project-root)]) @@ -82,13 +82,18 @@ (define pollen-env (getenv "POLLEN")) (define path+mod-time-pairs (map (λ(ps) (and ps (let ([cp (->complete-path ps)]) - (cons (path->string cp) (file-or-directory-modify-seconds cp))))) path-strings)) + (cons (path->string cp) (with-handlers ([exn:fail? (λ _ 0)]) + (file-or-directory-modify-seconds cp)))))) path-strings)) (list* pollen-env poly-flag path+mod-time-pairs)) (define (key->source-path key) (car (caddr key))) +(require sugar/test) +(module-test-external + (define ps "/users/nobody/project/source.html.pm") + (check-equal? (key->source-path (paths->key ps)) ps)) (define-namespace-anchor anchor-to-this-namespace)