diff --git a/Jenkinsfile b/Jenkinsfile index eacea3d..b9d1ddc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -44,6 +44,7 @@ pipeline { stage("${SCHEME}") { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r6rs test-docker" + junit ".tmp/*/*/*.xml" } } } @@ -61,6 +62,7 @@ pipeline { stage("${SCHEME}") { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r7rs test-docker" + junit ".tmp/*/*/*.xml" } } } diff --git a/retropikzel/junit.scm b/retropikzel/junit.scm index 1908e23..e960f18 100644 --- a/retropikzel/junit.scm +++ b/retropikzel/junit.scm @@ -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 (syntax-rules () @@ -21,10 +24,14 @@ (set! indentation (list-tail indentation 2))))) (print (lambda args - (map display (append indentation args)))) + (map (lambda (item) + (display item junit-runner-output-port)) + (append indentation args)))) (println (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 (lambda (str replace with) (list->string diff --git a/retropikzel/junit.sld b/retropikzel/junit.sld index 2e9251a..9ff3067 100644 --- a/retropikzel/junit.sld +++ b/retropikzel/junit.sld @@ -5,5 +5,6 @@ (scheme file) (srfi 19) (srfi 64)) - (export junit-runner) + (export junit-runner + set-junit-runner-output-port!) (include "junit.scm")) diff --git a/retropikzel/junit/README.md b/retropikzel/junit/README.md index c5161ca..ca9fcbb 100644 --- a/retropikzel/junit/README.md +++ b/retropikzel/junit/README.md @@ -2,11 +2,45 @@ JUnit, output for SRFI-64 [JUnit](https://junit.org/) -Usage: +## Usage + (import (scheme base) (srfi 64) (retropikzel junit)) (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)) + diff --git a/retropikzel/junit/VERSION b/retropikzel/junit/VERSION index 0ea3a94..0d91a54 100644 --- a/retropikzel/junit/VERSION +++ b/retropikzel/junit/VERSION @@ -1 +1 @@ -0.2.0 +0.3.0 diff --git a/retropikzel/tap.scm b/retropikzel/tap.scm index 93f5b81..8b546a0 100644 --- a/retropikzel/tap.scm +++ b/retropikzel/tap.scm @@ -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 (syntax-rules () ((_) @@ -16,10 +19,15 @@ (set! indentation (list-tail indentation 2))))) (print (lambda args - (map display (append indentation args)))) + (map (lambda (item) + (display item tap-output-port)) + (append indentation args)))) (println (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)) (started? #f) (current-test-groups (vector)) @@ -39,7 +47,8 @@ (test-runner-on-group-end! runner (lambda (runner) - (println "1.." current-test-group-count) + (when (> current-test-group-count 0) + (println "1.." current-test-group-count)) (decrease-indentation) (set! current-test-groups (list->vector diff --git a/retropikzel/tap.sld b/retropikzel/tap.sld index 6c9fcb7..e293680 100644 --- a/retropikzel/tap.sld +++ b/retropikzel/tap.sld @@ -3,6 +3,7 @@ (import (scheme base) (scheme write) (srfi 64)) - (export tap-runner) + (export tap-runner + set-tap-runner-output-port!) (include "tap.scm")) diff --git a/retropikzel/tap/README.md b/retropikzel/tap/README.md index 8806465..9039b61 100644 --- a/retropikzel/tap/README.md +++ b/retropikzel/tap/README.md @@ -1,12 +1,45 @@ -TAP, the Test Anything Protocol, output for SRFI-64 +TAP output for SRFI-64 [Test Anything Protocol](https://testanything.org/) -Usage: +## Usage + (import (scheme base) (srfi 64) (retropikzel tap)) (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)) diff --git a/retropikzel/tap/VERSION b/retropikzel/tap/VERSION index d917d3e..0ea3a94 100644 --- a/retropikzel/tap/VERSION +++ b/retropikzel/tap/VERSION @@ -1 +1 @@ -0.1.2 +0.2.0 diff --git a/test-headers.scm b/test-headers.scm index a6fd279..c05020b 100644 --- a/test-headers.scm +++ b/test-headers.scm @@ -4,9 +4,16 @@ (scheme char) (scheme file) (scheme process-context) - (srfi 64) - ;(retropikzel mouth) - ;(retropikzel ctrf) - (retropikzel LIBRARY)) + (retropikzel tap) + (retropikzel junit) + (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)))) diff --git a/test-headers.sps b/test-headers.sps index aa49f64..7706e03 100644 --- a/test-headers.sps +++ b/test-headers.sps @@ -1,8 +1,15 @@ (import (except (rnrs) delete-file) + (retropikzel tap) + (retropikzel junit) + (retropikzel LIBRARY) (srfi :64) - (srfi :98) - ;(retropikzel mouth) - ;(retropikzel ctrf) - (retropikzel LIBRARY)) + (srfi :98)) -;(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))))