fix bug in exe creation where 'lib runtime-paths could be mis-parsed as mzlib paths

svn: r11966

original commit: 89f2315374
This commit is contained in:
Matthew Flatt 2008-10-07 16:00:36 +00:00
parent 42ec054ab9
commit 9794d09d56
3 changed files with 98 additions and 77 deletions

View File

@ -0,0 +1,9 @@
#lang scheme/base
(require scheme/runtime-path
(for-syntax scheme/base))
(define-runtime-path file '(lib "icons/file.gif"))
(with-output-to-file "stdout"
(lambda () (printf "This is 1b~n"))
#:exists 'append)

View File

@ -0,0 +1,9 @@
#lang scheme/base
(require scheme/runtime-path
(for-syntax scheme/base))
(define-runtime-path file '(lib "etc.ss")) ; in mzlib
(with-output-to-file "stdout"
(lambda () (printf "This is 1c~n"))
#:exists 'append)

View File

@ -98,7 +98,7 @@
(define dest (if mred? mr-dest mz-dest)) (define dest (if mred? mr-dest mz-dest))
(define (flags s) (define (flags s)
(string-append "-" s)) (string-append "-" s))
(define (one-mz-test filename expect) (define (one-mz-test filename expect literal?)
;; Try simple mode: one module, launched from cmd line: ;; Try simple mode: one module, launched from cmd line:
(prepare dest filename) (prepare dest filename)
(make-embedding-executable (make-embedding-executable
@ -129,88 +129,91 @@
(w/prefix #f) (w/prefix #f)
(w/prefix 'before:)) (w/prefix 'before:))
;; Try full path, and use literal S-exp to start (when literal?
(printf ">>>literal sexp\n") ;; Try full path, and use literal S-exp to start
(prepare dest filename) (printf ">>>literal sexp\n")
(let ([path (build-path (collection-path "tests" "mzscheme") filename)]) (prepare dest filename)
(let ([path (build-path (collection-path "tests" "mzscheme") filename)])
(make-embedding-executable
dest mred? #f
`((#t ,path))
null
(base-compile
`(namespace-require '(file ,(path->string path))))
`(,(flags ""))))
(try-exe dest expect mred?)
;; Use `file' form:
(printf ">>>file\n")
(prepare dest filename)
(let ([path (build-path (collection-path "tests" "mzscheme") filename)])
(make-embedding-executable
dest mred? #f
`((#t (file ,(path->string path))))
null
(base-compile
`(namespace-require '(file ,(path->string path))))
`(,(flags ""))))
(try-exe dest expect mred?)
;; Use relative path
(printf ">>>relative path\n")
(prepare dest filename)
(parameterize ([current-directory (collection-path "tests" "mzscheme")])
(make-embedding-executable
dest mred? #f
`((#f ,filename))
null
(base-compile
`(namespace-require '',(string->symbol (regexp-replace #rx"[.].*$" filename ""))))
`(,(flags ""))))
(try-exe dest expect mred?)
;; Try multiple modules
(printf ">>>multiple\n")
(prepare dest filename)
(make-embedding-executable (make-embedding-executable
dest mred? #f dest mred? #f
`((#t ,path)) `((#t (lib ,filename "tests" "mzscheme"))
(#t (lib "embed-me3.ss" "tests" "mzscheme")))
null null
(base-compile (base-compile
`(namespace-require '(file ,(path->string path)))) `(begin
`(,(flags "")))) (namespace-require '(lib "embed-me3.ss" "tests" "mzscheme"))
(try-exe dest expect mred?) (namespace-require '(lib ,filename "tests" "mzscheme"))))
`(,(flags "")))
(try-exe dest (string-append "3 is here, too? #t\n" expect) mred?)
;; Use `file' form: ;; Try a literal file
(printf ">>>file\n") (printf ">>>literal\n")
(prepare dest filename) (prepare dest filename)
(let ([path (build-path (collection-path "tests" "mzscheme") filename)]) (let ([tmp (make-temporary-file)])
(make-embedding-executable (with-output-to-file tmp
dest mred? #f #:exists 'truncate
`((#t (file ,(path->string path)))) (lambda ()
null (write (kernel-compile
(base-compile '(namespace-require ''#%kernel)))))
`(namespace-require '(file ,(path->string path)))) (make-embedding-executable
`(,(flags "")))) dest mred? #f
(try-exe dest expect mred?) `((#t (lib ,filename "tests" "mzscheme")))
(list
tmp
(build-path (collection-path "tests" "mzscheme") "embed-me4.ss"))
`(with-output-to-file "stdout"
(lambda () (display "... and more!\n"))
'append)
`(,(flags "l") ,(string-append "tests/mzscheme/" filename)))
(delete-file tmp))
(try-exe dest (string-append
"This is the literal expression 4.\n"
"... and more!\n"
expect)
mred?)))
;; Use relative path (one-mz-test "embed-me1.ss" "This is 1\n" #t)
(printf ">>>relative path\n") (one-mz-test "embed-me1b.ss" "This is 1b\n" #f)
(prepare dest filename) (one-mz-test "embed-me1c.ss" "This is 1c\n" #f)
(parameterize ([current-directory (collection-path "tests" "mzscheme")]) (one-mz-test "embed-me2.ss" "This is 1\nThis is 2: #t\n" #t)
(make-embedding-executable
dest mred? #f
`((#f ,filename))
null
(base-compile
`(namespace-require '',(string->symbol (regexp-replace #rx"[.].*$" filename ""))))
`(,(flags ""))))
(try-exe dest expect mred?)
;; Try multiple modules
(printf ">>>multiple\n")
(prepare dest filename)
(make-embedding-executable
dest mred? #f
`((#t (lib ,filename "tests" "mzscheme"))
(#t (lib "embed-me3.ss" "tests" "mzscheme")))
null
(base-compile
`(begin
(namespace-require '(lib "embed-me3.ss" "tests" "mzscheme"))
(namespace-require '(lib ,filename "tests" "mzscheme"))))
`(,(flags "")))
(try-exe dest (string-append "3 is here, too? #t\n" expect) mred?)
;; Try a literal file
(printf ">>>literal\n")
(prepare dest filename)
(let ([tmp (make-temporary-file)])
(with-output-to-file tmp
#:exists 'truncate
(lambda ()
(write (kernel-compile
'(namespace-require ''#%kernel)))))
(make-embedding-executable
dest mred? #f
`((#t (lib ,filename "tests" "mzscheme")))
(list
tmp
(build-path (collection-path "tests" "mzscheme") "embed-me4.ss"))
`(with-output-to-file "stdout"
(lambda () (display "... and more!\n"))
'append)
`(,(flags "l") ,(string-append "tests/mzscheme/" filename)))
(delete-file tmp))
(try-exe dest (string-append
"This is the literal expression 4.\n"
"... and more!\n"
expect)
mred?))
(one-mz-test "embed-me1.ss" "This is 1\n")
(one-mz-test "embed-me2.ss" "This is 1\nThis is 2: #t\n")
;; Try unicode expr and cmdline: ;; Try unicode expr and cmdline:
(prepare dest "unicode") (prepare dest "unicode")