trying to make the tests robust to current-directory
This commit is contained in:
parent
5576e962f6
commit
3198c18b7d
|
@ -107,6 +107,14 @@
|
|||
|
||||
|
||||
;; parse-bytecode: (U Input-Port Path) -> Expression
|
||||
;;
|
||||
;; Given an input port, assumes the input is the byte representation of compiled-code.
|
||||
;;
|
||||
;; Given a path, assumes the path is for a module. It gets the module bytecode, and parses
|
||||
;; that.
|
||||
;;
|
||||
;; TODO: this may be doing too much work. It doesn't quite feel like the right elements
|
||||
;; are being manipulated here.
|
||||
(define (parse-bytecode in)
|
||||
(cond
|
||||
[(input-port? in)
|
||||
|
@ -128,7 +136,6 @@
|
|||
(error 'parse-bytecode "Don't know how to parse from ~e" in)]))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"test-browser-evaluate.rkt"
|
||||
"test-package.rkt"
|
||||
"test-conform-browser.rkt"
|
||||
"test-earley-browser.rkt")
|
||||
"test-earley-browser.rkt"
|
||||
"test-get-dependencies.rkt")
|
||||
|
||||
|
||||
;; This test takes a bit too much time.
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
"package.rkt"
|
||||
"js-assembler/get-runtime.rkt"
|
||||
racket/port
|
||||
racket/runtime-path)
|
||||
racket/runtime-path
|
||||
racket/runtime-path
|
||||
(for-syntax racket/base))
|
||||
|
||||
(define-runtime-path earley-file-path (build-path "tests" "earley"))
|
||||
|
||||
|
||||
(define evaluate (make-evaluate
|
||||
|
@ -45,5 +49,5 @@ EOF
|
|||
(printf " ok (~a milliseconds)\n" (evaluated-t result))))))]))
|
||||
|
||||
|
||||
(test (read (open-input-file "tests/earley/earley.sch"))
|
||||
(port->string (open-input-file "tests/earley/expected.txt")))
|
||||
(test (read (open-input-file (build-path earley-file-path "earley.sch")))
|
||||
(port->string (open-input-file (build-path earley-file-path "expected.txt"))))
|
|
@ -1,14 +1,63 @@
|
|||
#lang racket
|
||||
(require "get-dependencies.rkt"
|
||||
"get-module-bytecode.rkt"
|
||||
"parse-bytecode-5.1.1.rkt")
|
||||
|
||||
"parse-bytecode-5.1.1.rkt"
|
||||
"lexical-structs.rkt"
|
||||
racket/path
|
||||
racket/runtime-path
|
||||
rackunit)
|
||||
|
||||
(define-runtime-path this-path ".")
|
||||
|
||||
(define e
|
||||
(parse-bytecode (build-path "get-dependencies.rkt")))
|
||||
(parse-bytecode (build-path this-path "get-dependencies.rkt")))
|
||||
(void (get-dependencies e))
|
||||
|
||||
(get-dependencies e)
|
||||
(void (get-dependencies
|
||||
(parse-bytecode
|
||||
(build-path
|
||||
"/home/dyoo/local/racket-5.1.1/lib/racket/collects/scheme/base.rkt"))))
|
||||
|
||||
|
||||
|
||||
(define collects-dir
|
||||
(normalize-path
|
||||
(let ([p (find-system-path 'collects-dir)])
|
||||
(cond
|
||||
[(relative-path? p)
|
||||
(find-executable-path (find-system-path 'exec-file)
|
||||
(find-system-path 'collects-dir))]
|
||||
[else
|
||||
p]))))
|
||||
|
||||
|
||||
|
||||
(define (module-name< x y)
|
||||
(string<? (symbol->string (ModuleName-name x))
|
||||
(symbol->string (ModuleName-name y))))
|
||||
|
||||
|
||||
|
||||
|
||||
(get-dependencies (parse-bytecode (build-path "/home/dyoo/local/racket-5.1.1/lib/racket/collects/scheme/base.rkt")))
|
||||
;; This should have three dependencies: racket/base, racket/match, and get-module-bytecode.
|
||||
(check-equal?
|
||||
(sort (get-dependencies (parse-bytecode
|
||||
(open-input-bytes
|
||||
(get-module-bytecode
|
||||
(open-input-string (format #<<EOF
|
||||
(module foo racket/base
|
||||
(require racket/math
|
||||
(file "~a/get-module-bytecode.rkt"))
|
||||
(exp 1))
|
||||
EOF
|
||||
(path->string (normalize-path this-path)))
|
||||
)))))
|
||||
module-name<)
|
||||
(sort
|
||||
(list (make-ModuleName 'collects/racket/base.rkt
|
||||
(build-path collects-dir "racket" "base.rkt"))
|
||||
(make-ModuleName 'collects/racket/math.rkt
|
||||
(build-path collects-dir "racket" "math.rkt"))
|
||||
(make-ModuleName 'whalesong/get-module-bytecode.rkt
|
||||
(normalize-path (build-path this-path "get-module-bytecode.rkt"))))
|
||||
module-name<))
|
Loading…
Reference in New Issue
Block a user