r7rs-tests/report.scm

86 lines
3.4 KiB
Scheme
Raw Normal View History

2024-10-05 06:09:07 -04:00
(import (scheme base)
(scheme write)
(scheme file)
(scheme char)
(scheme process-context)
(scheme file)
2024-10-05 07:17:45 -04:00
(srfi 13)
2024-10-05 06:09:07 -04:00
(arvyy mustache))
(include "util.scm")
(include "implementations.scm")
(include "tests.scm")
(define report-top (compile (slurp "templates/Report-top")))
(define report-row (compile (slurp "templates/Report-row")))
(define report-bottom (compile (slurp "templates/Report-bottom")))
(define logfiles (list-tail (command-line) 1))
(call-with-output-file
"reports/results.html"
(lambda (out)
(execute report-top `() out)
(display "<tr>" out)
(newline out)
(display "<th>Test</th>" out)
(for-each
(lambda (implementation)
(display (string-append "<th>" (symbol->string (cdr (assoc 'name implementation))) "</th>") out)
(newline out))
implementations)
(display "</tr>" out)
(newline out)
(newline out)
(for-each
(lambda (test)
2024-10-05 06:34:10 -04:00
(let ((test-name (cdr (assoc 'name test))))
2024-10-05 06:09:07 -04:00
(display (string-append "<tr>") out)
(newline out)
(display (string-append "<td>" test-name "</td>") out)
(newline out)
(for-each
(lambda (implementation)
(letrec* ((name (cdr (assoc 'name implementation)))
(command (cdr (assoc 'command implementation)))
(logfile (string-append "reports/"
2024-10-05 06:38:59 -04:00
(symbol->string (cdr (assoc 'name implementation)))
2024-10-05 06:09:07 -04:00
"-"
test-name
".log"))
(read-results (lambda (line results)
(if (eof-object? line)
results
(read-results (read-line)
2024-10-05 07:17:45 -04:00
(if (string-contains line " out of ")
2024-10-05 06:09:07 -04:00
(begin
(append results
2024-10-05 07:17:45 -04:00
(list line)))
2024-10-05 06:09:07 -04:00
results)))))
2024-10-05 07:17:45 -04:00
(results
(if (file-exists? logfile)
(file-tail logfile 3)
(list)))
(result (apply string-append
(map
(lambda (line)
(string-append line "</br>"))
results))))
2024-10-05 06:09:07 -04:00
(execute report-row
`((name . ,name)
(command . ,command)
(library-command . ,(if (assoc 'library-command implementation)
(cdr (assoc 'library-command implementation))
#f))
(name . ,name)
2024-10-05 07:17:45 -04:00
(result . ,result))
2024-10-05 06:09:07 -04:00
out)
(newline out)))
implementations)
(display (string-append "</tr>") out)))
tests)
(execute report-bottom '() out)
(newline out)))