-#!../libguile/guile \
+#!../meta/guile \
-e main -s
!#
;;;; guile-test --- run the Guile test suite
;;;; Jim Blandy <jimb@red-bean.com> --- May 1999
;;;;
-;;;; Copyright (C) 1999, 2001, 2006 Free Software Foundation, Inc.
+;;;; Copyright (C) 1999, 2001, 2006, 2010, 2014 Free Software Foundation, Inc.
;;;;
;;;; This program is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
:use-module (ice-9 getopt-long)
:use-module (ice-9 and-let-star)
:use-module (ice-9 rdelim)
+ :use-module (system vm coverage)
+ :use-module (srfi srfi-11)
+ :use-module (system vm vm)
:export (main data-file-name test-file-name))
\f
;;; User configurable settings:
-(define default-test-suite
- (string-append (getenv "HOME") "/bogus-path/test-suite"))
+(define (default-test-suite)
+ (let ((argv0 (car (program-arguments))))
+ (if (string=? (basename argv0) "guile-test")
+ (dirname argv0)
+ (error "Cannot find default test suite."))))
\f
;;; Variables that will receive their actual values later.
-(define test-suite default-test-suite)
+(define test-suite)
(define tmp-dir #f)
(let ((root-len (+ 1 (string-length test-dir)))
(tests '()))
(for-each-file (lambda (file)
- (if (has-suffix? file ".test")
+ (if (string-suffix? ".test" file)
(let ((short-name
(substring file root-len)))
(set! tests (cons short-name tests))))
(log-file
(single-char #\l)
(value #t))
+ (coverage
+ (single-char #\c))
(debug
(single-char #\d))))))
(define (opt tag default)
(set! test-suite
(or (opt 'test-suite #f)
(getenv "TEST_SUITE_DIR")
- default-test-suite))
+ (default-test-suite)))
;; directory where temporary files are created.
;; when run from "make check", this must be under the build-dir,
;; Open the log file.
(let ((log-port (open-output-file log-file)))
+ ;; Allow for arbitrary Unicode characters in the log file.
+ (set-port-encoding! log-port "UTF-8")
+
+ ;; Don't fail if we can't display a test name to stdout/stderr.
+ (set-port-conversion-strategy! (current-output-port) 'escape)
+ (set-port-conversion-strategy! (current-error-port) 'escape)
+
;; Register some reporters.
(let ((global-pass #t)
(counter (make-count-reporter)))
(set! global-pass #f)))))
;; Run the tests.
- (for-each (lambda (test)
- (display (string-append "Running " test "\n"))
- (with-test-prefix test
- (load (test-file-name test))))
- tests)
+ (let ((run-tests
+ (lambda ()
+ (for-each (lambda (test)
+ (display (string-append "Running " test "\n"))
+ (when (defined? 'setlocale)
+ (setlocale LC_ALL "C"))
+ (with-test-prefix test
+ (load (test-file-name test))))
+ tests))))
+ (if (opt 'coverage #f)
+ (let-values (((coverage-data _)
+ (with-code-coverage (the-vm) run-tests)))
+ (let ((out (open-output-file "guile.info")))
+ (coverage-data->lcov coverage-data out)
+ (close out)))
+ (run-tests)))
;; Display the final counts, both to the user and in the log
;; file.