Changeset 38947 in project


Ignore:
Timestamp:
08/30/20 19:32:06 (4 weeks ago)
Author:
Kon Lovett
Message:

update test runner

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/5/sha2/trunk/tests/run.scm

    r35856 r38947  
     1;;;; run.scm -*- Scheme -*-
     2
     3(import scheme)
     4
     5;;; Create Egg Const
    16
    27(define EGG-NAME "sha2")
     
    49;chicken-install invokes as "<csi> -s run.scm <eggnam> <eggdir>"
    510
    6 (import
    7   (only (chicken pathname) make-pathname)
    8   (only (chicken process) system)
    9   (only (chicken process-context) argv)
    10   (only (chicken format) format))
     11(import (only (chicken pathname)
     12  make-pathname pathname-file pathname-replace-directory pathname-strip-extension))
     13(import (only (chicken process) system))
     14(import (only (chicken process-context) argv))
     15(import (only (chicken format) format))
     16(import (only (chicken file) file-exists? find-files))
     17(import (only (chicken irregex) irregex irregex-match?))
    1118
    1219(define *args* (argv))
    1320
    14 ;no -disable-interrupts
    15 (define *csc-options* "-inline-global \
     21(define (egg-name args #!optional (def EGG-NAME))
     22  (cond
     23    ((<= 4 (length *args*)) (cadddr *args*) )
     24    (def                    def )
     25    (else
     26      (error 'run "cannot determine egg-name") ) ) )
     27
     28(define *current-directory* (cond-expand (unix "./") (else #f)))
     29(define *egg* (egg-name *args*))
     30
     31;no -disable-interrupts or -no-lambda-info
     32(define *csc-options* "-inline-global -local -inline \
    1633  -specialize -optimize-leaf-routines -clustering -lfa2 \
    17   -local -inline \
    18   -no-trace -no-lambda-info \
    19   -unsafe")
     34  -no-trace -unsafe \
     35  -strict-types")
    2036
    21 (define (test-name #!optional (eggnam EGG-NAME))
    22   (string-append eggnam "-test") )
     37(define *test-files-rx* (irregex '(: (+ graph) #\- "test" #\. "scm")))
     38(define (test-filename name) (string-append name "-test"))
     39(define (test-files) (find-files "." #:test *test-files-rx* #:limit 1))
    2340
    24 (define (egg-name #!optional (def EGG-NAME))
    25   (cond
    26     ((<= 4 (length *args*))
    27       (cadddr *args*) )
    28     (def
    29       def )
    30     (else
    31       (error 'test "cannot determine egg-name") ) ) )
     41(define (ensure-test-source-name name)
     42  (if (irregex-match? *test-files-rx* name)
     43    name
     44    (make-pathname *current-directory* (test-filename name) "scm") ) )
     45
     46(define (run-test-evaluated source)
     47  (format #t "*** ~A - csi ***~%" (pathname-file source))
     48  (system (string-append "csi -s " source)) )
     49
     50(define (run-test-compiled source csc-options)
     51  (format #t "*** ~A - csc ~A ***~%" (pathname-file source) csc-options)
     52  ;csc output is in current directory
     53  (system (string-append "csc" " " csc-options " " source))
     54  (system (pathname-replace-directory (pathname-strip-extension source) *current-directory*)) )
    3255
    3356;;;
    3457
    35 (set! EGG-NAME (egg-name))
     58(define (run-test #!optional (name *egg*) (csc-options *csc-options*))
     59  (let (
     60    (source (ensure-test-source-name name)) )
     61    (unless (file-exists? source)
     62      (error 'run "no such file" source) )
     63    (run-test-evaluated source)
     64    (newline)
     65    (run-test-compiled source csc-options) ) )
    3666
    37 (define (run-test #!optional (eggnam EGG-NAME) (cscopts *csc-options*))
    38   (let ((tstnam (test-name eggnam)))
    39     (format #t "*** csi ***~%")
    40     (system (string-append "csi -s " (make-pathname #f tstnam "scm")))
    41     (newline)
    42     (format #t "*** csc ~s ***~%" cscopts)
    43     (system (string-append "csc" " " cscopts " " (make-pathname #f tstnam "scm")))
    44     (system (make-pathname (cond-expand (unix "./") (else #f)) tstnam)) ) )
     67(define (run-tests #!optional (tests (test-files)) (csc-options *csc-options*))
     68  (for-each (cut run-test <> csc-options) tests) )
    4569
    46 (define (run-tests eggnams #!optional (cscopts *csc-options*))
    47   (for-each (cut run-test <> cscopts) eggnams) )
     70;;; Do Test
    4871
    49 ;;;
    50 
    51 (run-test)
     72(run-tests)
Note: See TracChangeset for help on using the changeset viewer.