This repository has been archived by the owner on May 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtap-harness
executable file
·81 lines (68 loc) · 2.62 KB
/
tap-harness
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
#!guile -s
-*- scheme -*-
!#
(use-modules (ice-9 getopt-long)
(test tap-harness))
(define *name* 'tap-harness)
(define *version* '((major . 0)
(minor . 0)
(patch . 1)))
(define (pp-version v)
(string-join (map (compose number->string cdr) v) "."))
(define option-spec
'((debug (single-char #\D))
(help (single-char #\h))
(verbose (single-char #\v))
(version (single-char #\V))
(exec (single-char #\e) (value #t))))
(define opts (getopt-long (command-line) option-spec
#:stop-at-first-non-option #t))
(define (opt o)
(option-ref opts o #f))
(define (arguments)
(opt '()))
(define (with-arguments?)
((compose not zero? length) (arguments)))
(when (opt 'help)
(newline)
(format #t " Usage: tap-harness [OPTION(s)...] [PROGRAM(s)...]~%")
(newline)
(format #t " --help, -h Print this help text.~%")
(format #t " --version, -V Print version information about the program.~%")
(format #t " --debug, -D Enable debugging output in the program.~%")
(format #t " --verbose, -v Enable verbose harness operation.~%")
(newline)
(format #t " --exec EXEC, -e EXEC Run PROGRAM(s) via EXEC.~%")
(newline)
(quit 0))
(when (opt 'version)
(format #t "~a version ~a~%" *name* (pp-version *version*))
(quit 0))
(when (and (opt 'exec) (not (with-arguments?)))
(format #t "~a: Option --exec (-e) requires non-option arguments to run.~%"
*name*)
(quit 1))
(define harness-callback
(if (opt 'verbose)
(make-harness-callback #:test render-parsed
#:plan render-parsed
#:diagnostic render-parsed
#:version render-parsed
#:bailout render-parsed)
(make-harness-callback #:plan progress-plan
#:test progress-test
#:bailout render-parsed
#:completion progress-completion)))
(quit
(harness-combined-result
(if (with-arguments?)
(harness-analyse ((if (opt 'debug)
pp-harness-state
identity) (harness-run #:run-programs (arguments)
#:runner (opt 'exec)
#:callback harness-callback))
#:pre-summary (lambda (_) (newline)))
(harness-analyse ((if (opt 'debug)
pp-harness-state
identity) (harness-stdin harness-callback))
#:pre-summary (lambda (_) (newline))))))