From 27b2f99772eebc1cf7bb5e0cc44c2b7046b35937 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 16 Dec 2019 02:04:57 +0530 Subject: tests: Implement custom test runner group begin and end functions. * build-aux/test-driver.scm.in (my-gnu-runner): Add custom test-runner on-group-begin and on-group-end functions. Accept log file port as an argument. --- build-aux/test-driver.scm.in | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'build-aux') diff --git a/build-aux/test-driver.scm.in b/build-aux/test-driver.scm.in index 71aa042..89b9b68 100644 --- a/build-aux/test-driver.scm.in +++ b/build-aux/test-driver.scm.in @@ -1,5 +1,5 @@ ;;; guile-email --- Guile email parser -;;; Copyright © 2018 Arun Isaac +;;; Copyright © 2018, 2019 Arun Isaac ;;; ;;; This file is part of guile-email. ;;; @@ -31,8 +31,17 @@ (expect-failure (value #t)) (enable-hard-errors (value #t)))) -(define (my-gnu-runner trs-port) +(define (my-gnu-runner log-port trs-port) (let ((runner (test-runner-simple))) + (test-runner-on-group-begin! runner + (lambda (runner suite-name count) + (format #t "%%%% Starting test ~a~%" suite-name) + (format log-port "%%%% Starting test ~a~%" suite-name) + ;; Set log-port in the aux-value field for use by other parts + ;; of test-runner-simple + (test-runner-aux-value! runner log-port) + (format #t " (Writing full log to \"~a\")~%" (port-filename log-port)))) + (test-runner-on-group-end! runner (const #f)) (test-runner-on-test-end! runner (lambda (runner) (format trs-port ":test-result: ~A ~A~%" @@ -43,10 +52,11 @@ runner)) (let ((opts (getopt-long (command-line) %options))) - (set! test-log-to-file (string-append "@abs_top_builddir@/" - (option-ref opts 'log-file #f))) - (call-with-output-file (option-ref opts 'trs-file #f) - (lambda (trs-port) - (chdir "@abs_top_srcdir@") - (test-with-runner (my-gnu-runner trs-port) - (load-from-path (option-ref opts 'test-name #f)))))) + (call-with-output-file (string-append "@abs_top_builddir@/" + (option-ref opts 'log-file #f)) + (lambda (log-port) + (call-with-output-file (option-ref opts 'trs-file #f) + (lambda (trs-port) + (chdir "@abs_top_srcdir@") + (test-with-runner (my-gnu-runner log-port trs-port) + (load-from-path (option-ref opts 'test-name #f)))))))) -- cgit v1.2.3