Switch testing to TAP and JUnit

This commit is contained in:
retropikzel 2026-07-19 15:52:47 +03:00
parent 085b87194d
commit cbf860fcc0
11 changed files with 123 additions and 22 deletions

2
Jenkinsfile vendored
View File

@ -44,6 +44,7 @@ pipeline {
stage("${SCHEME}") { stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r6rs test-docker" sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r6rs test-docker"
junit ".tmp/*/*/*.xml"
} }
} }
} }
@ -61,6 +62,7 @@ pipeline {
stage("${SCHEME}") { stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r7rs test-docker" sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r7rs test-docker"
junit ".tmp/*/*/*.xml"
} }
} }
} }

View File

@ -1,3 +1,6 @@
(define junit-runner-output-port (current-output-port))
(define (set-junit-runner-output-port! port)
(set! junit-runner-output-port port))
(define-syntax junit-runner (define-syntax junit-runner
(syntax-rules () (syntax-rules ()
@ -21,10 +24,14 @@
(set! indentation (list-tail indentation 2))))) (set! indentation (list-tail indentation 2)))))
(print (print
(lambda args (lambda args
(map display (append indentation args)))) (map (lambda (item)
(display item junit-runner-output-port))
(append indentation args))))
(println (println
(lambda args (lambda args
(map display (append indentation args)) (newline))) (map (lambda (item)
(display item junit-runner-output-port))
(append indentation args)) (newline junit-runner-output-port)))
(string-replace (string-replace
(lambda (str replace with) (lambda (str replace with)
(list->string (list->string

View File

@ -5,5 +5,6 @@
(scheme file) (scheme file)
(srfi 19) (srfi 19)
(srfi 64)) (srfi 64))
(export junit-runner) (export junit-runner
set-junit-runner-output-port!)
(include "junit.scm")) (include "junit.scm"))

View File

@ -2,11 +2,45 @@ JUnit, output for SRFI-64
[JUnit](https://junit.org/) [JUnit](https://junit.org/)
Usage:
## Usage
(import (scheme base) (import (scheme base)
(srfi 64) (srfi 64)
(retropikzel junit)) (retropikzel junit))
(test-runner-current (junit-runner)) (test-runner-current (junit-runner))
## Jenkins usage tip
Use JUnit test runner in Jenkins and output to file, use TAP anywhere else and
output to stdout.
(cond
;; In Jenkins
((get-environment-variable "JENKINS_URL")
(let ((junit-file "junit-result.xml"))
(test-runner-current (junit-runner))
(when (file-exists? junit-file) (delete-file junit-file))
(set-junit-runner-output-port! (open-output-file junit-file))))
(else (test-runner-current (tap-runner))))
## Reference
(**junit-runner**)
Get the JUnit test runner.
(**set-junit-runner-output-port!** port)
Set the output port of the test runner. To output to file you can do:
(define junit-file "junit-result.xml")
(when (file-exists? junit-file) (delete-file junit-file))
(set-junit-runner-output-port! (open-output-file junit-file))

View File

@ -1 +1 @@
0.2.0 0.3.0

View File

@ -1,3 +1,6 @@
(define tap-output-port (current-output-port))
(define (set-tap-runner-output-port! port)
(set! tap-output-port port))
(define-syntax tap-runner (define-syntax tap-runner
(syntax-rules () (syntax-rules ()
((_) ((_)
@ -16,10 +19,15 @@
(set! indentation (list-tail indentation 2))))) (set! indentation (list-tail indentation 2)))))
(print (print
(lambda args (lambda args
(map display (append indentation args)))) (map (lambda (item)
(display item tap-output-port))
(append indentation args))))
(println (println
(lambda args (lambda args
(map display (append indentation args)) (display "\n"))) (map (lambda (item)
(display item tap-output-port))
(append indentation args))
(display "\n" tap-output-port)))
(runner (test-runner-null)) (runner (test-runner-null))
(started? #f) (started? #f)
(current-test-groups (vector)) (current-test-groups (vector))
@ -39,7 +47,8 @@
(test-runner-on-group-end! (test-runner-on-group-end!
runner runner
(lambda (runner) (lambda (runner)
(println "1.." current-test-group-count) (when (> current-test-group-count 0)
(println "1.." current-test-group-count))
(decrease-indentation) (decrease-indentation)
(set! current-test-groups (set! current-test-groups
(list->vector (list->vector

View File

@ -3,6 +3,7 @@
(import (scheme base) (import (scheme base)
(scheme write) (scheme write)
(srfi 64)) (srfi 64))
(export tap-runner) (export tap-runner
set-tap-runner-output-port!)
(include "tap.scm")) (include "tap.scm"))

View File

@ -1,12 +1,45 @@
TAP, the Test Anything Protocol, output for SRFI-64 TAP output for SRFI-64
[Test Anything Protocol](https://testanything.org/) [Test Anything Protocol](https://testanything.org/)
Usage:
## Usage
(import (scheme base) (import (scheme base)
(srfi 64) (srfi 64)
(retropikzel tap)) (retropikzel tap))
(test-runner-current (tap-runner)) (test-runner-current (tap-runner))
## Jenkins usage tip
Use JUnit test runner in Jenkins and output to file, use TAP anywhere else and
output to stdout.
(cond
;; In Jenkins
((get-environment-variable "JENKINS_URL")
(let ((junit-file "junit-result.xml"))
(test-runner-current (junit-runner))
(when (file-exists? junit-file) (delete-file junit-file))
(set-junit-runner-output-port! (open-output-file junit-file))))
(else (test-runner-current (tap-runner))))
## Reference
(**tap-runner**)
Get the TAP test runner.
(**set-tap-runner-output-port!** port)
Set the output port of the test runner. To output to file you can do:
(define tap-file "tap-result.txt")
(when (file-exists? tap-file) (delete-file tap-file))
(set-tap-runner-output-port! (open-output-file tap-file))

View File

@ -1 +1 @@
0.1.2 0.2.0

View File

@ -4,9 +4,16 @@
(scheme char) (scheme char)
(scheme file) (scheme file)
(scheme process-context) (scheme process-context)
(srfi 64) (retropikzel tap)
;(retropikzel mouth) (retropikzel junit)
;(retropikzel ctrf) (retropikzel LIBRARY)
(retropikzel LIBRARY)) (srfi 64))
;(test-runner-current (ctrf-runner)) (cond
;; In Jenkins
((get-environment-variable "WORKSPACE")
(let ((junit-file "junit-result.xml"))
(test-runner-current (junit-runner))
(when (file-exists? junit-file) (delete-file junit-file))
(set-junit-runner-output-port! (open-output-file junit-file))))
(else (test-runner-current (tap-runner))))

View File

@ -1,8 +1,15 @@
(import (except (rnrs) delete-file) (import (except (rnrs) delete-file)
(retropikzel tap)
(retropikzel junit)
(retropikzel LIBRARY)
(srfi :64) (srfi :64)
(srfi :98) (srfi :98))
;(retropikzel mouth)
;(retropikzel ctrf)
(retropikzel LIBRARY))
;(test-runner-current (ctrf-runner)) (cond
;; In Jenkins
((get-environment-variable "WORKSPACE")
(let ((junit-file "junit-result.xml"))
(test-runner-current (junit-runner))
(when (file-exists? junit-file) (delete-file junit-file))
(set-junit-runner-output-port! (open-output-file junit-file))))
(else (test-runner-current (tap-runner))))