diff --git a/pollen/test/data/poly-output-path/pollen.rkt b/pollen/test/data/poly-output-path/pollen.rkt new file mode 100644 index 0000000..4fbb9d7 --- /dev/null +++ b/pollen/test/data/poly-output-path/pollen.rkt @@ -0,0 +1,5 @@ +#lang racket/base + +(module setup racket/base + (provide poly-targets) + (define poly-targets '(html txt))) \ No newline at end of file diff --git a/pollen/test/data/poly-output-path/test.poly.pm b/pollen/test/data/poly-output-path/test.poly.pm new file mode 100644 index 0000000..888b9ae --- /dev/null +++ b/pollen/test/data/poly-output-path/test.poly.pm @@ -0,0 +1,3 @@ +#lang pollen + +hello world \ No newline at end of file diff --git a/pollen/test/test-poly-output-path.rkt b/pollen/test/test-poly-output-path.rkt new file mode 100644 index 0000000..7436535 --- /dev/null +++ b/pollen/test/test-poly-output-path.rkt @@ -0,0 +1,29 @@ +#lang at-exp racket/base +(require rackunit racket/runtime-path pollen/render racket/file racket/system pollen/setup) + +;; define-runtime-path only allowed at top level +(define-runtime-path poly-output-path-dir "data/poly-output-path") +(define-runtime-path pollen.rkt "data/poly-output-path/pollen.rkt") +(define-runtime-path test.poly.pm "data/poly-output-path/test.poly.pm") +(define-runtime-path test.txt "data/poly-output-path/test.txt") +(define-runtime-path test.html "data/poly-output-path/test.html") +(define-runtime-path pollen-cache "data/poly-output-path/compiled") + +(parameterize ([current-output-port (open-output-string)] + [current-directory poly-output-path-dir] + [current-project-root poly-output-path-dir]) + + (for ([parallel? (list #true #false)]) + ;; passing "text.txt" as argument should force use of txt rendering + (render-batch #:parallel parallel? test.txt) + (check-equal? (file->string test.txt) "(root hello world)") + (delete-file test.txt) + (check-false (file-exists? test.html)) + + ;; passing poly source as argument should result in default (html) rendering + (render-batch #:parallel parallel? test.poly.pm) + (check-equal? (file->string test.html) "hello world") + (delete-file test.html) + (check-false (file-exists? test.txt)))) + +(delete-directory/files pollen-cache) \ No newline at end of file