61 lines
1.4 KiB
Scheme
61 lines
1.4 KiB
Scheme
(cond-expand
|
|
(r7rs)
|
|
(chicken (import (r7rs))))
|
|
(import-for-syntax (r7rs))
|
|
|
|
(define-library (gherken)
|
|
(import r7rs
|
|
utf8
|
|
(chicken irregex)
|
|
(chicken port)
|
|
(chicken file)
|
|
shell
|
|
medea
|
|
srfi-1
|
|
srfi-69
|
|
srfi-78
|
|
srfi-123
|
|
srfi-133
|
|
srfi-152
|
|
srfi-197)
|
|
(export given run-features)
|
|
(begin
|
|
(define lang-registry (make-hash-table))
|
|
|
|
(define-syntax given
|
|
(syntax-rules ()
|
|
((given picklex args ...)
|
|
(hash-table-set! lang-registry picklex (lambda args ...)))))
|
|
|
|
(define (run-step data)
|
|
#t)
|
|
|
|
(define (run-pickle data tags)
|
|
(vector-map
|
|
(lambda (chunk)
|
|
(vector-map
|
|
(lambda (step)
|
|
(run-step data))
|
|
(alist-ref 'steps chunk)))
|
|
data)))
|
|
|
|
(define (run-feature filename tags)
|
|
(let ((pickles (chain (capture ("./gherkinexe" "--no-ast" "--no-source" filename))
|
|
(string-trim-both _)
|
|
(string-split _ "\n")
|
|
(string-join _ ", ")
|
|
(list "[" _ "]")
|
|
(string-concatenate _)
|
|
(with-input-from-string _ read-json)
|
|
(vector-map (lambda (x) (alist-ref 'pickle x)) _))))
|
|
(vector-map
|
|
(lambda (x) (run-pickle x tags))
|
|
pickles)))
|
|
|
|
(define (run-features dir #!rest tags)
|
|
(let ((featurefiles (find-files dir test: '(: (* any) ".feature"))))
|
|
(map
|
|
(lambda (x) (run-feature x tags))
|
|
featurefiles)))
|
|
))
|