Debugging

original commit: 3ff7b0461c
This commit is contained in:
Jay McCarthy 2010-05-28 16:12:14 -06:00
commit 684a88a0e8
6 changed files with 179 additions and 125 deletions

View File

@ -228,6 +228,11 @@
(traverse-stx expr visit)] (traverse-stx expr visit)]
[(wrapped? expr) [(wrapped? expr)
(traverse-wrapped expr visit)] (traverse-wrapped expr visit)]
[(hash? expr)
(when (visit expr)
(for ([(k v) (in-hash expr)])
(traverse-data k visit)
(traverse-data v visit)))]
[else [else
(void)])) (void)]))
@ -987,16 +992,18 @@
(for ([v (in-vector expr)]) (for ([v (in-vector expr)])
(out-data v out))] (out-data v out))]
[(hash? expr) [(hash? expr)
(out-byte CPT_HASH_TABLE out) (out-shared expr out
(out-number (cond (lambda ()
[(hash-eqv? expr) 2] (out-byte CPT_HASH_TABLE out)
[(hash-eq? expr) 0] (out-number (cond
[else 1]) [(hash-eqv? expr) 2]
out) [(hash-eq? expr) 0]
(out-number (hash-count expr) out) [else 1])
(for ([(k v) (in-hash expr)]) out)
(out-data k out) (out-number (hash-count expr) out)
(out-data v out))] (for ([(k v) (in-hash expr)])
(out-data k out)
(out-data v out))))]
[(svector? expr) [(svector? expr)
(let* ([vec (svector-vec expr)] (let* ([vec (svector-vec expr)]
[len (vector-length vec)]) [len (vector-length vec)])

View File

@ -15,8 +15,6 @@
Lines 628, 630 seem to be only for debugging and should probably throw errors Lines 628, 630 seem to be only for debugging and should probably throw errors
unmarshal-stx-get also seems to be for debugging and should probably throw an error
vector and pair cases of decode-wraps seem to do different things from the corresponding C code vector and pair cases of decode-wraps seem to do different things from the corresponding C code
Line 816: This should be an eqv placeholder (but they don't exist) Line 816: This should be an eqv placeholder (but they don't exist)
@ -29,8 +27,6 @@
collects/browser/compiled/browser_scrbl.zo (eg) contains a all-from-module that looks like: (#<module-path-index> 0 (1363072) . #f) --- that doesn't seem to match the spec collects/browser/compiled/browser_scrbl.zo (eg) contains a all-from-module that looks like: (#<module-path-index> 0 (1363072) . #f) --- that doesn't seem to match the spec
We seem to leave placeholders for hash-tables in the structs
|# |#
;; ---------------------------------------- ;; ----------------------------------------
;; Bytecode unmarshalers for various forms ;; Bytecode unmarshalers for various forms
@ -501,15 +497,9 @@
;; ---------------------------------------- ;; ----------------------------------------
;; Syntax unmarshaling ;; Syntax unmarshaling
(define (decode-stx cp v) (define (decode-stx cp v)
(if (integer? v) (if (integer? v)
(let-values ([(v2 decoded?) (unmarshal-stx-get cp v)]) (unmarshal-stx-get/decode cp v decode-stx)
(if decoded?
v2
(let ([v2 (decode-stx cp v2)])
(unmarshal-stx-set! cp v v2)
v2)))
(let loop ([v v]) (let loop ([v v])
(let-values ([(cert-marks v encoded-wraps) (let-values ([(cert-marks v encoded-wraps)
(match v (match v
@ -564,29 +554,17 @@
(map loop (cdr (vector->list (struct->vector v)))))))] (map loop (cdr (vector->list (struct->vector v)))))))]
[else (add-wrap v)])))))) [else (add-wrap v)]))))))
(define (decode-wraps cp w) (define (decode-wraps cp w)
; A wraps is either a indirect reference or a list of wrap-elems (from stxobj.c:252) ; A wraps is either a indirect reference or a list of wrap-elems (from stxobj.c:252)
(if (integer? w) (if (integer? w)
(let-values ([(w2 decoded?) (unmarshal-stx-get cp w)]) (unmarshal-stx-get/decode cp w decode-wraps)
(if decoded?
w2
(let ([w2 (decode-wraps cp w2)])
(unmarshal-stx-set! cp w w2)
w2)))
(map (lambda (a) (map (lambda (a)
(let aloop ([a a]) (let aloop ([a a])
; A wrap-elem is either ; A wrap-elem is either
(cond (cond
; A reference ; A reference
[(integer? a) [(integer? a)
(let-values ([(a2 decoded?) (unmarshal-stx-get cp a)]) (unmarshal-stx-get/decode cp a (lambda (cp v) (aloop v)))]
(if decoded?
a2
(let ([a2 (aloop a2)])
(unmarshal-stx-set! cp a a2)
a2)))]
; A mark (not actually a number as the C says, but a (list <num>) ; A mark (not actually a number as the C says, but a (list <num>)
[(and (pair? a) (null? (cdr a)) (number? (car a))) [(and (pair? a) (null? (cdr a)) (number? (car a)))
(make-wrap-mark (car a))] (make-wrap-mark (car a))]
@ -704,23 +682,6 @@
[module-path-index [module-path-index
(make-simple-module-binding module-path-index)])))) (make-simple-module-binding module-path-index)]))))
(define (unmarshal-stx-get cp pos)
(if (pos . >= . (vector-length (cport-symtab cp)))
(values `(#%bad-index ,pos) #t)
(let ([v (vector-ref (cport-symtab cp) pos)])
(if (not-ready? v)
(let ([save-pos (cport-pos cp)])
(set-cport-pos! cp (vector-ref (cport-shared-offsets cp) (sub1 pos)))
(let ([v (read-compact cp)])
(vector-set! (cport-symtab cp) pos v)
(set-cport-pos! cp save-pos)
(values v #f)))
(values v (vector-ref (cport-decoded cp) pos))))))
(define (unmarshal-stx-set! cp pos v)
(vector-set! (cport-symtab cp) pos v)
(vector-set! (cport-decoded cp) pos #t))
(define (parse-module-path-index cp s) (define (parse-module-path-index cp s)
s) s)
;; ---------------------------------------- ;; ----------------------------------------
@ -738,15 +699,7 @@
(case cpt-tag (case cpt-tag
[(delayed) [(delayed)
(let ([pos (read-compact-number cp)]) (let ([pos (read-compact-number cp)])
(let ([v (vector-ref (cport-symtab cp) pos)]) (read-sym cp pos))]
(if (not-ready? v)
(let ([save-pos (cport-pos cp)])
(set-cport-pos! cp (vector-ref (cport-shared-offsets cp) (sub1 pos)))
(let ([v (read-compact cp)])
(vector-set! (cport-symtab cp) pos v)
(set-cport-pos! cp save-pos)
v))
v)))]
[(escape) [(escape)
(let* ([len (read-compact-number cp)] (let* ([len (read-compact-number cp)]
[s (cport-get-bytes cp len)]) [s (cport-get-bytes cp len)])
@ -841,9 +794,8 @@
[len (read-compact-number cp)]) [len (read-compact-number cp)])
((case eq ((case eq
[(0) make-hasheq-placeholder] [(0) make-hasheq-placeholder]
; XXX One of these should be eqv
[(1) make-hash-placeholder] [(1) make-hash-placeholder]
[(2) make-hash-placeholder]) [(2) make-hasheqv-placeholder])
(for/list ([i (in-range len)]) (for/list ([i (in-range len)])
(cons (read-compact cp) (cons (read-compact cp)
(read-compact cp)))))] (read-compact cp)))))]
@ -894,16 +846,8 @@
(read-compact cp))))]) (read-compact cp))))])
(read (open-input-bytes #"x")))))] (read (open-input-bytes #"x")))))]
[(symref) [(symref)
(let* ([l (read-compact-number cp)] (let* ([l (read-compact-number cp)])
[v (vector-ref (cport-symtab cp) l)]) (read-sym cp l))]
(if (not-ready? v)
(let ([pos (cport-pos cp)])
(set-cport-pos! cp (vector-ref (cport-shared-offsets cp) (sub1 l)))
(let ([v (read-compact cp)])
(set-cport-pos! cp pos)
(vector-set! (cport-symtab cp) l v)
v))
v))]
[(weird-symbol) [(weird-symbol)
(let ([uninterned (read-compact-number cp)] (let ([uninterned (read-compact-number cp)]
[str (read-compact-chars cp (read-compact-number cp))]) [str (read-compact-chars cp (read-compact-number cp))])
@ -934,7 +878,7 @@
[(closure) [(closure)
(let* ([l (read-compact-number cp)] (let* ([l (read-compact-number cp)]
[ind (make-indirect #f)]) [ind (make-indirect #f)])
(vector-set! (cport-symtab cp) l ind) (placeholder-set! (vector-ref (cport-symtab cp) l) ind)
(let* ([v (read-compact cp)] (let* ([v (read-compact cp)]
[cl (make-closure v (gensym [cl (make-closure v (gensym
(let ([s (lam-name v)]) (let ([s (lam-name v)])
@ -956,6 +900,36 @@
[else [else
(cons v (loop (sub1 need-car) proper))])))) (cons v (loop (sub1 need-car) proper))]))))
(define (unmarshal-stx-get/decode cp pos decode-stx)
(define v2 (read-sym cp pos))
(define decoded? (vector-ref (cport-decoded cp) pos))
(if decoded?
v2
(let ([dv2 (decode-stx cp v2)])
(placeholder-set! (vector-ref (cport-symtab cp) pos) dv2)
(vector-set! (cport-decoded cp) pos #t)
dv2)))
(require unstable/markparam)
(define read-sym-mark (mark-parameter))
(define (read-sym cp i)
(define symtab (cport-symtab cp))
(define ph (vector-ref symtab i))
; We are reading this already, so return the placeholder
(if (memq i (mark-parameter-all read-sym-mark))
ph
; Otherwise, try to read it and return the real thing
(local [(define vv (placeholder-get ph))]
(when (not-ready? vv)
(local [(define save-pos (cport-pos cp))]
(set-cport-pos! cp (vector-ref (cport-shared-offsets cp) (sub1 i)))
(mark-parameterize
([read-sym-mark i])
(let ([v (read-compact cp)])
(placeholder-set! ph v)))
(set-cport-pos! cp save-pos)))
(placeholder-get ph))))
;; path -> bytes ;; path -> bytes
;; implementes read.c:read_compiled ;; implementes read.c:read_compiled
(define (zo-parse port) (define (zo-parse port)
@ -990,18 +964,17 @@
(unless (eof-object? (read-byte port)) (unless (eof-object? (read-byte port))
(error 'zo-parse "File too big")) (error 'zo-parse "File too big"))
(define symtab (make-vector symtabsize (make-not-ready))) (define nr (make-not-ready))
(define symtab
(build-vector symtabsize (λ (i) (make-placeholder nr))))
(define cp (make-cport 0 shared-size port size* rst-start symtab so* (make-vector symtabsize #f) (make-hash) (make-hash))) (define cp (make-cport 0 shared-size port size* rst-start symtab so* (make-vector symtabsize #f) (make-hash) (make-hash)))
(for/list ([i (in-range 1 symtabsize)]) (for/list ([i (in-range 1 symtabsize)])
(define vv (vector-ref symtab i)) (read-sym cp i))
(when (not-ready? vv)
(set-cport-pos! cp (vector-ref so* (sub1 i)))
(let ([v (read-compact cp)])
(vector-set! symtab i v))))
(set-cport-pos! cp shared-size) (set-cport-pos! cp shared-size)
(read-marshalled 'compilation-top-type cp))) (make-reader-graph
(read-marshalled 'compilation-top-type cp))))
;; ---------------------------------------- ;; ----------------------------------------

View File

@ -22,7 +22,7 @@
(define-syntax-rule (define-form-struct* id id+par ([field-id field-contract] ...)) (define-syntax-rule (define-form-struct* id id+par ([field-id field-contract] ...))
(begin (begin
(define-struct id+par (field-id ...) #:transparent) (define-struct id+par (field-id ...) #:prefab)
(provide/contract (provide/contract
[struct id ([field-id field-contract] ...)]))) [struct id ([field-id field-contract] ...)])))
@ -57,7 +57,7 @@
(define-form-struct (expr form) ()) (define-form-struct (expr form) ())
;; A static closure can refer directly to itself, creating a cycle ;; A static closure can refer directly to itself, creating a cycle
(define-struct indirect ([v #:mutable]) #:transparent) (define-struct indirect ([v #:mutable]) #:prefab)
(define-form-struct compilation-top ([max-let-depth exact-nonnegative-integer?] [prefix prefix?] [code (or/c form? indirect? any/c)])) ; compiled code always wrapped with this (define-form-struct compilation-top ([max-let-depth exact-nonnegative-integer?] [prefix prefix?] [code (or/c form? indirect? any/c)])) ; compiled code always wrapped with this

View File

@ -0,0 +1,22 @@
#lang racket
(require compiler/zo-parse
compiler/zo-marshal
tests/eli-tester)
(define (roundtrip ct)
(define bs (zo-marshal ct))
(test bs
(zo-parse (open-input-bytes bs)) => ct))
(test
(local [(define (hash-test make-hash-placeholder)
(roundtrip
(compilation-top 0
(prefix 0 empty empty)
(local [(define ht-ph (make-placeholder #f))
(define ht (make-hash-placeholder (list (cons 'g ht-ph))))]
(placeholder-set! ht-ph ht)
(make-reader-graph ht)))))]
(hash-test make-hash-placeholder)
(hash-test make-hasheq-placeholder)
(hash-test make-hasheqv-placeholder)))

52
collects/tests/compiler/zo-test.rkt Normal file → Executable file
View File

@ -1,3 +1,8 @@
#!/bin/sh
#|
exec racket -t "$0" -- -s -t 60 -v -R $*
|#
#lang scheme #lang scheme
(require compiler/zo-parse (require compiler/zo-parse
compiler/zo-marshal compiler/zo-marshal
@ -5,9 +10,40 @@
setup/dirs) setup/dirs)
;; Helpers ;; Helpers
(define (bytes->hex-string bs)
(apply string-append
(for/list ([b bs])
(format "~a~x"
(if (b . <= . 15) "0" "")
b))))
(define (show-bytes-side-by-side orig new)
(define max-length
(max (bytes-length orig) (bytes-length new)))
(define BYTES-PER-LINE 38)
(define lines
(ceiling (/ max-length BYTES-PER-LINE)))
(define (subbytes* b s e)
(subbytes b (min s (bytes-length b)) (min e (bytes-length b))))
(for ([line (in-range lines)])
(define start (* line BYTES-PER-LINE))
(define end (* (add1 line) BYTES-PER-LINE))
(printf "+ ~a\n" (bytes->hex-string (subbytes* orig start end)))
(printf "- ~a\n" (bytes->hex-string (subbytes* new start end)))))
(define (bytes-gulp f) (define (bytes-gulp f)
(with-input-from-file f (with-input-from-file f
(λ () (port->bytes (current-input-port))))) (λ () (port->bytes (current-input-port)))))
(define (read-compiled-bytes bs)
(define ib (open-input-bytes bs))
(dynamic-wind void
(lambda ()
(parameterize ([read-accept-compiled #t])
(read ib)))
(lambda ()
(close-input-port ib))))
(define (zo-parse/bytes bs) (define (zo-parse/bytes bs)
(define ib (open-input-bytes bs)) (define ib (open-input-bytes bs))
(dynamic-wind void (dynamic-wind void
@ -245,6 +281,13 @@
(lambda (file) (lambda (file)
(run/stages* file [stage serious? e] ...))))) (run/stages* file [stage serious? e] ...)))))
(define debugging? (make-parameter #f))
(define (print-bytes orig new)
(when (debugging?)
(show-bytes-side-by-side orig new))
#t)
(define-stages (stages run!) (define-stages (stages run!)
file file
[read-orig [read-orig
@ -279,6 +322,12 @@
[decompile-parsed [decompile-parsed
#t #t
(decompile parse-orig)] (decompile parse-orig)]
[show-orig-and-marshal-parsed
#f
(print-bytes read-orig marshal-parsed)]
[c-parse-marshalled
#f
(read-compiled-bytes marshal-parsed)]
[compare-orig-to-marshalled [compare-orig-to-marshalled
#f #f
(bytes-not-equal?-error read-orig marshal-parsed)]) (bytes-not-equal?-error read-orig marshal-parsed)])
@ -345,6 +394,9 @@
#;(current-command-line-arguments #("-s" "/home/bjohn3x/development/plt/collects/browser/compiled/browser_scrbl.zo")) #;(current-command-line-arguments #("-s" "/home/bjohn3x/development/plt/collects/browser/compiled/browser_scrbl.zo"))
(command-line #:program "zo-test" (command-line #:program "zo-test"
#:once-each #:once-each
[("-D")
"Enable debugging output"
(debugging? #t)]
[("-s" "--stop-on-first-error") [("-s" "--stop-on-first-error")
"Stop testing when first error is encountered" "Stop testing when first error is encountered"
(stop-on-first-error #t)] (stop-on-first-error #t)]

View File

@ -103,10 +103,10 @@
(prepare dest filename) (prepare dest filename)
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((#t (lib ,filename "tests" "mzscheme"))) `((#t (lib ,filename "tests" "racket")))
null null
#f #f
`(,(flags "l") ,(string-append "tests/mzscheme/" filename))) `(,(flags "l") ,(string-append "tests/racket/" filename)))
(try-exe dest expect mred?) (try-exe dest expect mred?)
;; Try explicit prefix: ;; Try explicit prefix:
@ -116,7 +116,7 @@
(prepare dest filename) (prepare dest filename)
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((,pfx (lib ,filename "tests" "mzscheme")) `((,pfx (lib ,filename "tests" "racket"))
(#t (lib "scheme/init"))) (#t (lib "scheme/init")))
null null
#f #f
@ -133,7 +133,7 @@
;; Try full path, and use literal S-exp to start ;; Try full path, and use literal S-exp to start
(printf ">>>literal sexp\n") (printf ">>>literal sexp\n")
(prepare dest filename) (prepare dest filename)
(let ([path (build-path (collection-path "tests" "mzscheme") filename)]) (let ([path (build-path (collection-path "tests" "racket") filename)])
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((#t ,path)) `((#t ,path))
@ -146,7 +146,7 @@
;; Use `file' form: ;; Use `file' form:
(printf ">>>file\n") (printf ">>>file\n")
(prepare dest filename) (prepare dest filename)
(let ([path (build-path (collection-path "tests" "mzscheme") filename)]) (let ([path (build-path (collection-path "tests" "racket") filename)])
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((#t (file ,(path->string path)))) `((#t (file ,(path->string path))))
@ -159,7 +159,7 @@
;; Use relative path ;; Use relative path
(printf ">>>relative path\n") (printf ">>>relative path\n")
(prepare dest filename) (prepare dest filename)
(parameterize ([current-directory (collection-path "tests" "mzscheme")]) (parameterize ([current-directory (collection-path "tests" "racket")])
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((#f ,filename)) `((#f ,filename))
@ -174,13 +174,13 @@
(prepare dest filename) (prepare dest filename)
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((#t (lib ,filename "tests" "mzscheme")) `((#t (lib ,filename "tests" "racket"))
(#t (lib "embed-me3.ss" "tests" "mzscheme"))) (#t (lib "embed-me3.rkt" "tests" "racket")))
null null
(base-compile (base-compile
`(begin `(begin
(namespace-require '(lib "embed-me3.ss" "tests" "mzscheme")) (namespace-require '(lib "embed-me3.rkt" "tests" "racket"))
(namespace-require '(lib ,filename "tests" "mzscheme")))) (namespace-require '(lib ,filename "tests" "racket"))))
`(,(flags ""))) `(,(flags "")))
(try-exe dest (string-append "3 is here, too? #t\n" expect) mred?) (try-exe dest (string-append "3 is here, too? #t\n" expect) mred?)
@ -195,14 +195,14 @@
'(namespace-require ''#%kernel))))) '(namespace-require ''#%kernel)))))
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((#t (lib ,filename "tests" "mzscheme"))) `((#t (lib ,filename "tests" "racket")))
(list (list
tmp tmp
(build-path (collection-path "tests" "mzscheme") "embed-me4.ss")) (build-path (collection-path "tests" "racket") "embed-me4.rktl"))
`(with-output-to-file "stdout" `(with-output-to-file "stdout"
(lambda () (display "... and more!\n")) (lambda () (display "... and more!\n"))
'append) 'append)
`(,(flags "l") ,(string-append "tests/mzscheme/" filename))) `(,(flags "l") ,(string-append "tests/racket/" filename)))
(delete-file tmp)) (delete-file tmp))
(try-exe dest (string-append (try-exe dest (string-append
"This is the literal expression 4.\n" "This is the literal expression 4.\n"
@ -210,12 +210,12 @@
expect) expect)
mred?))) mred?)))
(one-mz-test "embed-me1.ss" "This is 1\n" #t) (one-mz-test "embed-me1.rkt" "This is 1\n" #t)
(one-mz-test "embed-me1b.ss" "This is 1b\n" #f) (one-mz-test "embed-me1b.rkt" "This is 1b\n" #f)
(one-mz-test "embed-me1c.ss" "This is 1c\n" #f) (one-mz-test "embed-me1c.rkt" "This is 1c\n" #f)
(one-mz-test "embed-me1d.ss" "This is 1d\n" #f) (one-mz-test "embed-me1d.rkt" "This is 1d\n" #f)
(one-mz-test "embed-me1e.ss" "This is 1e\n" #f) (one-mz-test "embed-me1e.rkt" "This is 1e\n" #f)
(one-mz-test "embed-me2.ss" "This is 1\nThis is 2: #t\n" #t) (one-mz-test "embed-me2.rkt" "This is 1\nThis is 2: #t\n" #t)
;; Try unicode expr and cmdline: ;; Try unicode expr and cmdline:
(prepare dest "unicode") (prepare dest "unicode")
@ -238,13 +238,13 @@
(mz-tests #t) (mz-tests #t)
(begin (begin
(prepare mr-dest "embed-me5.ss") (prepare mr-dest "embed-me5.rkt")
(make-embedding-executable (make-embedding-executable
mr-dest #t #f mr-dest #t #f
`((#t (lib "embed-me5.ss" "tests" "mzscheme"))) `((#t (lib "embed-me5.rkt" "tests" "racket")))
null null
#f #f
`("-l" "tests/mzscheme/embed-me5.ss")) `("-l" "tests/racket/embed-me5.rkt"))
(try-exe mr-dest "This is 5: #<class:button%>\n" #t)) (try-exe mr-dest "This is 5: #<class:button%>\n" #t))
;; Try the mzc interface: ;; Try the mzc interface:
@ -260,15 +260,15 @@
(system* mzc (system* mzc
(if mred? "--gui-exe" "--exe") (if mred? "--gui-exe" "--exe")
(path->string (mk-dest mred?)) (path->string (mk-dest mred?))
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me1.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me1.rkt")))
(try-exe (mk-dest mred?) "This is 1\n" mred?) (try-exe (mk-dest mred?) "This is 1\n" mred?)
;; Check that etc.ss isn't found if it's not included: ;; Check that etc.rkt isn't found if it's not included:
(printf ">>not included\n") (printf ">>not included\n")
(system* mzc (system* mzc
(if mred? "--gui-exe" "--exe") (if mred? "--gui-exe" "--exe")
(path->string (mk-dest mred?)) (path->string (mk-dest mred?))
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me6.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me6.rkt")))
(try-exe (mk-dest mred?) "This is 6\nno etc.ss\n" mred?) (try-exe (mk-dest mred?) "This is 6\nno etc.ss\n" mred?)
;; And it is found if it is included: ;; And it is found if it is included:
@ -276,8 +276,8 @@
(system* mzc (system* mzc
(if mred? "--gui-exe" "--exe") (if mred? "--gui-exe" "--exe")
(path->string (mk-dest mred?)) (path->string (mk-dest mred?))
"++lib" "mzlib/etc.ss" "++lib" "mzlib/etc.rkt"
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me6.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me6.rkt")))
(try-exe (mk-dest mred?) "This is 6\n#t\n" mred?) (try-exe (mk-dest mred?) "This is 6\n#t\n" mred?)
;; Or, it's found if we set the collection path: ;; Or, it's found if we set the collection path:
@ -287,7 +287,7 @@
(path->string (mk-dest mred?)) (path->string (mk-dest mred?))
"--collects-path" "--collects-path"
(path->string (find-collects-dir)) (path->string (find-collects-dir))
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me6.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me6.rkt")))
;; Don't try a distribution for this one: ;; Don't try a distribution for this one:
(try-one-exe (mk-dest mred?) "This is 6\n#t\n" mred?) (try-one-exe (mk-dest mred?) "This is 6\n#t\n" mred?)
@ -296,10 +296,10 @@
(system* mzc (system* mzc
(if mred? "--gui-exe" "--exe") (if mred? "--gui-exe" "--exe")
(path->string (mk-dest mred?)) (path->string (mk-dest mred?))
"++lib" "mzlib/etc.ss" "++lib" "mzlib/etc.rkt"
"--collects-dest" "cts" "--collects-dest" "cts"
"--collects-path" "cts" "--collects-path" "cts"
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me6.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me6.rkt")))
(try-exe (mk-dest mred?) "This is 6\n#t\n" mred? void "cts") ; <- cts copied to distribution (try-exe (mk-dest mred?) "This is 6\n#t\n" mred? void "cts") ; <- cts copied to distribution
(delete-directory/files "cts") (delete-directory/files "cts")
(test #f system* (mk-dest mred?)) (test #f system* (mk-dest mred?))
@ -326,17 +326,17 @@
(system-library-subpath))) (system-library-subpath)))
(define ext-file (define ext-file
(build-path ext-dir (append-extension-suffix "embed-me8_ss"))) (build-path ext-dir (append-extension-suffix "embed-me8_rkt")))
(define ss-file (define ss-file
(build-path (find-system-path 'temp-dir) "embed-me9.ss")) (build-path (find-system-path 'temp-dir) "embed-me9.rkt"))
(make-directory* ext-dir) (make-directory* ext-dir)
(system* mzc (system* mzc
"--cc" "--cc"
"-d" (path->string (path-only obj-file)) "-d" (path->string (path-only obj-file))
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me8.c"))) (path->string (build-path (collection-path "tests" "racket") "embed-me8.c")))
(system* mzc (system* mzc
"--ld" "--ld"
(path->string ext-file) (path->string ext-file)
@ -344,7 +344,7 @@
(when (file-exists? ss-file) (when (file-exists? ss-file)
(delete-file ss-file)) (delete-file ss-file))
(copy-file (build-path (collection-path "tests" "mzscheme") "embed-me9.ss") (copy-file (build-path (collection-path "tests" "racket") "embed-me9.rkt")
ss-file) ss-file)
(system* mzc (system* mzc
@ -361,7 +361,7 @@
(system* mzc (system* mzc
(if mred? "--gui-exe" "--exe") (if mred? "--gui-exe" "--exe")
(path->string (mk-dest mred?)) (path->string (mk-dest mred?))
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me10.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me10.rkt")))
(try-exe (mk-dest mred?) "#t\n" mred?))) (try-exe (mk-dest mred?) "#t\n" mred?)))
(extension-test #f) (extension-test #f)
@ -372,7 +372,7 @@
(system* mzc (system* mzc
"--gui-exe" "--gui-exe"
(path->string (mk-dest #t)) (path->string (mk-dest #t))
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me5.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me5.rkt")))
(try-exe (mk-dest #t) "This is 5: #<class:button%>\n" #t)) (try-exe (mk-dest #t) "This is 5: #<class:button%>\n" #t))
;; Another GRacket-specific: try embedding plot, which has extra DLLs and font files: ;; Another GRacket-specific: try embedding plot, which has extra DLLs and font files:
@ -382,34 +382,34 @@
(test #t (test #t
system* (build-path (find-console-bin-dir) "mred") system* (build-path (find-console-bin-dir) "mred")
"-qu" "-qu"
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me7.ss")) (path->string (build-path (collection-path "tests" "racket") "embed-me7.rkt"))
(path->string direct)) (path->string direct))
(system* mzc (system* mzc
"--gui-exe" "--gui-exe"
(path->string (mk-dest #t)) (path->string (mk-dest #t))
(path->string (build-path (collection-path "tests" "mzscheme") "embed-me7.ss"))) (path->string (build-path (collection-path "tests" "racket") "embed-me7.rkt")))
(try-exe (mk-dest #t) "plotted\n" #t)) (try-exe (mk-dest #t) "plotted\n" #t))
;; Try including source that needs a reader extension ;; Try including source that needs a reader extension
(define (try-reader-test mred?) (define (try-reader-test mred?)
(define dest (mk-dest mred?)) (define dest (mk-dest mred?))
(define filename "embed-me11.ss") (define filename "embed-me11.rkt")
(define (flags s) (define (flags s)
(string-append "-" s)) (string-append "-" s))
(create-embedding-executable (create-embedding-executable
dest dest
#:modules `((#t (lib ,filename "tests" "mzscheme"))) #:modules `((#t (lib ,filename "tests" "racket")))
#:cmdline `(,(flags "l") ,(string-append "tests/mzscheme/" filename)) #:cmdline `(,(flags "l") ,(string-append "tests/racket/" filename))
#:src-filter (lambda (f) #:src-filter (lambda (f)
(let-values ([(base name dir?) (split-path f)]) (let-values ([(base name dir?) (split-path f)])
(equal? name (string->path filename)))) (equal? name (string->path filename))))
#:get-extra-imports (lambda (f code) #:get-extra-imports (lambda (f code)
(let-values ([(base name dir?) (split-path f)]) (let-values ([(base name dir?) (split-path f)])
(if (equal? name (string->path filename)) (if (equal? name (string->path filename))
'((lib "embed-me11-rd.ss" "tests" "mzscheme")) '((lib "embed-me11-rd.rkt" "tests" "racket"))
null))) null)))
#:mred? mred?) #:mred? mred?)