Commit 4b00fd30 authored by Sarah Spall's avatar Sarah Spall Committed by Vikram Narayanan

A new test runner written in racket instead of python.

parent d1d6b9a0
all:
raco exe test_runner.rkt
run:
raco exe test_runner.rkt
./test_runner
clean:
rm test_runner
#!/usr/bin/env python3
from os import getcwd, listdir
from os.path import join
from subprocess import check_call, check_output, CalledProcessError
def main():
current_dir = getcwd()
test_dir = join(current_dir, "test")
comp_dir = join(current_dir, "compiler")
out_dir = join(test_dir, "out")
for file in listdir(test_dir):
if file.endswith(".idl"):
try:
print("in loop: " + file)
idl_file = join("test", file)
out_file = join("test", file+".h")
print(out_file)
print(idl_file)
check_call([comp_dir, '-header', idl_file, '-out', out_file])
except Exception as e:
print("f")
if __name__ == '__main__':
main()
#lang racket
;; just check if extention is .idl
(define (is-test-case? path)
(let* ([split-path (string-split (path->string path) "/")]
[reversed (reverse split-path)]
[directory (cadr reversed)]
[file (car reversed)]
[ext (string-split file ".")])
(and (equal? directory "test_cases")
(equal? ext "idl"))))
(define exec (string->path "../compiler"))
(define test-cases
(with-handlers ([exn:fail? (lambda (exn) '())])
(find-files is-test-case? #f)))
(define (run-server-header-test tests)
(if (empty? tests)
(void)
(let* ([test (path->string (car tests))]
[out-file (apply build-path (reverse (cons (string-append (car (reverse (string-split test "/")))
"server.h")
(cdr (reverse (string-split test "/"))))))])
(displayln `(server header test: ,test) (current-error-port))
(system* exec "-serverheader" test out-file))))
(define (run-server-source-test tests)
(if (empty? tests)
(void)
(let* ([test (path->string (car tests))]
[out-file (apply build-path (reverse (cons (string-append (car (reverse (string-split test "/")))
"server.c")
(cdr (reverse (string-split test "/"))))))])
(displayln `(server source test: ,test) (current-error-port))
(system* exec "-serversource" test out-file))))
(define (run-client-header-test tests)
(if (empty? tests)
(void)
(let* ([test (path->string (car tests))]
[out-file (apply build-path (reverse (cons (string-append (car (reverse (string-split test "/")))
"client.h")
(cdr (reverse (string-split test "/"))))))])
(displayln `(client header test: ,test) (current-error-port))
(system* exec "-clientheader" test out-file))))
(define (run-client-source-test tests)
(if (empty? tests)
(void)
(let* ([test (path->string (car tests))]
[out-file (apply build-path (reverse (cons (string-append (car (reverse (string-split test "/")))
"client.c")
(cdr (reverse (string-split test "/"))))))])
(displayln `(client source test: ,test) (current-error-port))
(system* exec "-clientsource" test out-file))))
(define (run-tests tests)
(displayln "Running server header test")
(run-server-header-test tests)
(displayln "Running server source test")
(run-server-source-test tests)
(displayln "Running client header test")
(run-client-header-test tests)
(displayln "Running client source test")
(run-client-source-test tests))
;;(run-tests test-cases)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment