Skip to content

Commit

Permalink
fixed compile looping. Final fix for Issue #21
Browse files Browse the repository at this point in the history
  • Loading branch information
florence committed Jan 24, 2015
1 parent 0499f7e commit 1639151
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
22 changes: 13 additions & 9 deletions cover.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ in "coverage.rkt". This raw coverage information is converted to a usable form b
(->absolute p))))
(define abs-paths (map (lambda (p) (if (list? p) (first p) p)) abs))
(parameterize ([current-load/use-compiled (make-cover-load/use-compiled abs-paths)]
[use-compiled-file-paths
(cons (build-path "compiled" "cover")
(use-compiled-file-paths))]

[current-output-port
(if (verbose) (current-output-port) (open-output-nowhere))])
(define tests-failed #f)
Expand Down Expand Up @@ -88,20 +86,25 @@ in "coverage.rkt". This raw coverage information is converted to a usable form b
(define (make-cover-load/use-compiled paths)
(define load/use-compiled (current-load/use-compiled))
(define load (current-load))
(define compile (current-compile))
(define cover-compile (make-cover-compile))
(define cover-use-compiled-file-paths
(cons (build-path "compiled" "cover")
(use-compiled-file-paths)))
(lambda (path sym)
(define abs (->absolute path))
(define lst (explode-path abs))
(define dir-list (take lst (sub1 (length lst))))
(parameterize ([current-load-relative-directory (apply build-path dir-list)])
(if (member abs paths)
(parameterize ([current-compile cover-compile])
(parameterize ([current-compile cover-compile]
[use-compiled-file-paths
cover-use-compiled-file-paths])
(load path sym))
(parameterize ([current-compile compile])
(load/use-compiled path sym))))))
(load/use-compiled path sym)))))

;; -> Compiler
;; makes a value sutable for current-compile, such that compile
;; annotates the source code. should only be used by `make-cover-load/uze-compiled`
(define (make-cover-compile)
(define compile (current-compile))
(define reg (namespace-module-registry ns))
Expand Down Expand Up @@ -238,9 +241,10 @@ in "coverage.rkt". This raw coverage information is converted to a usable form b
(for-each (lambda (f) (when (file-exists? f) (delete-file f)))
compiled)
(check-false (ormap file-exists? compiled))
(#;check-not-exn
(check-not-exn
(lambda ()
(parameterize ([current-compile (make-cover-compile)]
(parameterize ([current-load/use-compiled
(make-cover-load/use-compiled (list (->absolute prog.rkt)))]
[current-namespace ns])
(managed-compile-zo prog.rkt))))
(check-true (andmap file-exists? compiled))
Expand Down
10 changes: 4 additions & 6 deletions strace.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
(require errortrace/stacktrace
racket/function
racket/syntax
syntax/parse
racket/unit
syntax/kerncase
racket/runtime-path
"private/file-utils.rkt"
"private/shared.rkt"
Expand Down Expand Up @@ -69,12 +69,11 @@
(define inspector (variable-reference->module-declaration-inspector
(#%variable-reference)))
(let loop ([expr expr] [top #t])
(syntax-parse (syntax-disarm expr inspector)
#:literal-sets (kernel-literals)
(kernel-syntax-case (syntax-disarm expr inspector) #f
[(module name lang mb)
(with-syntax ([cover cover-name]
[srcloc srcloc-name])
(syntax-parse (syntax-disarm #'mb inspector)
(syntax-case (syntax-disarm #'mb inspector) ()
[(#%module-begin b ...)
(with-syntax ([(body ...)
(map (lambda (e) (loop e #f)) (syntax->list #'(b ...)))])
Expand All @@ -92,8 +91,7 @@
;; in order to write modules to disk the top level needs to
;; be a module. so we trust that the module is loaded and trim the expression
(define (annotate-clean e)
(syntax-parse e
#:literal-sets (kernel-literals)
(kernel-syntax-case e #f
[(begin e mod)
(eval #'e)
#'mod]
Expand Down

0 comments on commit 1639151

Please sign in to comment.