1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
#!@theme_d_guile@ \
-e main -s
!#
;; Copyright (C) 2018, 2025, 2026 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.
(import (theme-d testing test-info))
(define (get-test-name i)
(string->symbol (string-append "test" (number->string i))))
(define (get-str-test-name i)
(string-append "test" (number->string i)))
(define (get-mod-name i)
(let* ((test-name (get-test-name i)))
`(tests ,test-name)))
(define (get-source-filename i s-unit-type)
(let ((str-ext
(case s-unit-type
((proper-program) ".thp")
((script) ".ths")
((body) ".thb")
((interface) ".thi")
(else (raise 'invalid-file-type)))))
(string-append (get-str-test-name i) str-ext)))
(define (get-target-filename i s-unit-type)
(let ((str-ext
(case s-unit-type
((proper-program) ".tcp")
((script) ".tcs")
((body) ".tcb")
((interface) ".tci")
(else (raise 'invalid-file-type)))))
(string-append (get-str-test-name i) str-ext)))
(define (get-source-test-path i s-unit-type)
(let ((filename (get-source-filename i s-unit-type)))
(string-append "../theme-d-code/tests/" filename)))
(define (check-file i s-unit-type)
(let* ((mod-name (get-target-filename i s-unit-type))
(test-path (get-source-test-path i s-unit-type))
(log-filename "link-test-programs.log")
;; (comp-success?
;; (= (run
;; (| (grep ,mod-name "link-test-programs.log")
;; (grep -q succeeded)))
;; 0))
(comp-success?
(= (system (string-append "grep " mod-name
" " log-filename
" | grep -q succeeded"))
0))
;; (comp-failure?
;; (= (run
;; (| (grep ,mod-name "link-test-programs.log")
;; (grep -q failed)))
;; 0))
(comp-failure?
(= (system (string-append "grep " mod-name
" " log-filename
" | grep -q failed"))
0))
;; (expected-success?
;; (=
;; (run
;; (| (grep "Expected results:" ,test-path)
;; (grep -q "translation and running OK")))
;; 0))
;; The following is #t for translation errors, too.
(expected-success?
(and
(= (system (string-append "grep \"Expected results:\" "
test-path
" | grep -q \" OK\""))
0)
(not
(= (system (string-append "grep \"Expected results of modular linking:\" "
test-path
" | grep -q \" failure\""))
0))))
;; (expected-error?
;; (=
;; (run
;; (| (grep "Expected results:" ,test-path)
;; (grep -q "error")))
;; 0))
;; (expected-error?
;; (= (system (string-append "grep \"Expected results:\" "
;; test-path
;; " | grep -q error"))
;; 0))
;; (expected-xlat-error?
;; (=
;; (run
;; (grep -q "Expected results: translation error" ,test-path))
;; 0)))
(expected-xlat-error?
(or
(= (system (string-append "grep \"Expected results:\" "
test-path
" | grep -q \"translation error\""))
0)
(= (system (string-append "grep \"Expected results:\" "
test-path
" | grep -q \"compilation error\""))
0))))
(cond
((eq? comp-success? comp-failure?) (display 'err1) 'error)
;; ((eq? expected-success? expected-error?) (display 'err2) 'error)
((and comp-failure? expected-success?) 'fail)
((and comp-success? expected-xlat-error?) 'fail)
(else 'pass))))
(define (get-result s-result)
(case s-result
((pass) "PASS")
((fail) "FAIL")
((error) "ERROR")
(else (raise 'internal-error))))
(define (check-file2 i s-unit-type)
(let* ((result (check-file i s-unit-type))
(program-filename (get-source-filename i s-unit-type)))
(display program-filename)
(display ": ")
(display (get-result result))
(newline)))
(define (check-files)
(do ((i 1 (+ i 1))) ((> i nr-of-tests))
(cond
((member i l-plugins)
(check-file2 i 'body))
((member i modules)
(check-file2 i 'interface)
(check-file2 i 'body))
((member i scripts)
(check-file2 i 'script))
(else
(check-file2 i 'proper-program)))))
(define (main args)
(check-files))
|