diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ccwl.scm | 60 | ||||
| -rw-r--r-- | tests/cwl.scm | 16 | ||||
| -rw-r--r-- | tests/echo.cwl | 7 | ||||
| -rw-r--r-- | tests/lang.scm | 30 | ||||
| -rw-r--r-- | tests/ui.scm | 5 | ||||
| -rw-r--r-- | tests/utils.scm | 53 | ||||
| -rw-r--r-- | tests/yaml.scm | 8 |
7 files changed, 139 insertions, 40 deletions
diff --git a/tests/ccwl.scm b/tests/ccwl.scm index 2d755ad..b2da5cd 100644 --- a/tests/ccwl.scm +++ b/tests/ccwl.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021–2024 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2021–2026 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -16,10 +16,11 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with ccwl. If not, see <https://www.gnu.org/licenses/>. -(use-modules (rnrs exceptions) - (srfi srfi-1) +(use-modules (srfi srfi-1) (srfi srfi-64) (srfi srfi-71) + (ice-9 match) + (test-utils utils) (ccwl ccwl) (ccwl conditions)) @@ -45,13 +46,6 @@ ((@@ (ccwl ccwl) construct-type-syntax) #'type-spec))))) -(define-syntax-rule (test-condition test-name condition-predicate test-expression) - (test-assert test-name - (guard (condition - (else (condition-predicate condition))) - (begin test-expression - #f)))) - (define (ccwl-violation-with-message? message) (lambda (condition) (and (ccwl-violation? condition) @@ -60,23 +54,23 @@ (test-begin "ccwl") -(test-assert "stdin input should not have inputBinding" - (not (assoc-ref - (assoc-ref - (assoc-ref - ((@@ (ccwl cwl) command->cwl-scm) - (command #:inputs (file #:type File) - #:run "wc" "-c" - #:stdin file)) - 'inputs) - 'file) - 'inputBinding))) +(test-equal "stdin input should not have inputBinding" + '((file (type . File))) + (assoc-ref + ((@@ (ccwl cwl) command->cwl-scm) + (command #:inputs (file #:type File) + #:run "wc" "-c" + #:stdin file)) + 'inputs)) + +(test-assert "resolve CWL workflow relative to source file" + (cwl-workflow "echo.cwl")) (test-equal "read all forms of inputs and outputs from a CWL workflow" '(((spam string)) ((ham stdout) (eggs stdout))) - (let ((cwl-workflow (cwl-workflow "tests/input-output-parameters.cwl"))) + (let ((cwl-workflow (cwl-workflow "input-output-parameters.cwl"))) (list (map (lambda (input) (list (input-id input) (input-type input))) @@ -110,6 +104,11 @@ ccwl-violation? (output #'(message #:type int string))) +(test-condition "output, when passed a #:binding to an stdout type, must raise a &ccwl-violation condition" + ccwl-violation? + (output #'(message #:type stdout + #:binding ((glob . "output.txt"))))) + (test-condition "command, when passed positional arguments, must raise a &ccwl-violation condition" ccwl-violation? (macroexpand @@ -189,6 +188,16 @@ (workflow () (print-int #:number 42))) +;; TODO: Define this in the lexical scope of the test that requires +;; it. +(define print-workflow + (workflow ((message #:type string)) + (print #:message message))) + +(test-assert "allow literals as arguments to workflows" + (workflow () + (print-workflow #:message "foo"))) + (test-condition "step supplied with an unknown key must raise a &ccwl-violation condition" ccwl-violation? (macroexpand @@ -323,6 +332,13 @@ '(command #:inputs (messages #:type (array string)) #:run "echo" (array messages #:separator foo)))) +(test-condition "Non-boolean #:separate? flag must raise a &ccwl-violation condition" + (ccwl-violation-with-message? + "Invalid #:separate? flag ~a. #:separate? flag must be a boolean.") + (macroexpand + '(command #:inputs (arg #:type string) + #:run "foo" ("-o" arg #:separate? bar)))) + (test-assert "tee must deduplicate global workflow input keys" (let ((keys steps (collect-steps #'(tee (print #:message message) (identity)) diff --git a/tests/cwl.scm b/tests/cwl.scm index ba619ab..ae8fa6b 100644 --- a/tests/cwl.scm +++ b/tests/cwl.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2023 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2023, 2025 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -18,6 +18,12 @@ (use-modules (srfi srfi-64)) +(define make-input + (@@ (ccwl ccwl) make-input)) + +(define input->cwl-scm + (@@ (ccwl cwl) input->cwl-scm)) + (define type->cwl (@@ (ccwl cwl) type->cwl)) @@ -41,4 +47,12 @@ (items . File)))) (type->cwl (make-array-type (make-array-type 'File)))) +(test-equal "Serialize #f defaults in input values" + '("foo" + (type . boolean) + (default . #f) + (label . "foo")) + (input->cwl-scm + (make-input "foo" 'boolean "foo" #f #f #f #t #f #f '()))) + (test-end "cwl") diff --git a/tests/echo.cwl b/tests/echo.cwl new file mode 100644 index 0000000..b957a59 --- /dev/null +++ b/tests/echo.cwl @@ -0,0 +1,7 @@ +cwlVersion: v1.2 +class: CommandLineTool +baseCommand: echo +inputs: + message: + type: string +outputs: {} diff --git a/tests/lang.scm b/tests/lang.scm new file mode 100644 index 0000000..5c506bc --- /dev/null +++ b/tests/lang.scm @@ -0,0 +1,30 @@ +;;; ccwl --- Concise Common Workflow Language +;;; Copyright © 2026 Arun Isaac <arunisaac@systemreboot.net> +;;; +;;; This file is part of ccwl. +;;; +;;; ccwl is free software: you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; ccwl is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with ccwl. If not, see <https://www.gnu.org/licenses/>. + +(use-modules (srfi srfi-64) + (test-utils utils) + (ccwl conditions) + (ccwl lang)) + +(test-begin "lang") + +(test-condition "loading non-existent source file must raise a &ccwl-violation" + ccwl-violation? + (ccwl-load "/non-existent/file.scm")) + +(test-end "lang") diff --git a/tests/ui.scm b/tests/ui.scm index a5741c0..115a20e 100644 --- a/tests/ui.scm +++ b/tests/ui.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2023 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2023, 2025 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -16,7 +16,8 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with ccwl. If not, see <https://www.gnu.org/licenses/>. -(use-modules (srfi srfi-64) +(use-modules (srfi srfi-26) + (srfi srfi-64) (term ansi-color) (ccwl ui) (ccwl conditions)) diff --git a/tests/utils.scm b/tests/utils.scm index 50c3396..735bea8 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021, 2022, 2023 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2021–2023, 2025–2026 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -21,6 +21,7 @@ (srfi srfi-1) (srfi srfi-64) (srfi srfi-71) + (ice-9 filesystem) (ccwl conditions) (ccwl utils)) @@ -89,11 +90,13 @@ '(lambda** (#:key foo #:foo bar) foo)))) -(test-equal "Allow other keys in lambda**" +(test-equal "Allow other keys in lambda**, but raise an exception" 1 - ((lambda** (#:key foo #:allow-other-keys) - foo) - #:foo 1 #:bar 2)) + (with-exception-handler (const #t) + (lambda () + ((lambda** (#:key foo) + foo) + #:foo 1 #:bar 2)))) (test-assert "Unrecognized keyword argument passed to lambda** should raise an &unrecognized-keyword-assertion condition" (guard (exception @@ -138,14 +141,13 @@ ((syntax-lambda** (#:key* foo) foo))) -;; We cannot use test-equal to compare syntax objects, since -;; test-equal does not preserve the lexical contexts of the test -;; expressions. -(test-assert "Allow other keys in syntax-lambda**" - (equal? #'1 - ((syntax-lambda** (#:key foo #:allow-other-keys) - foo) - #'#:foo #'1 #'#:bar #'2))) +(test-equal "Allow other keys in syntax-lambda**, but raise an exception" + 1 + (syntax->datum (with-exception-handler (const #t) + (lambda () + ((syntax-lambda** (#:key foo) + foo) + #'#:foo #'1 #'#:bar #'2))))) (test-assert "syntax-lambda** should raise an &unrecognized-keyword-assertion on unrecognized keywords in arguments" (guard (exception @@ -194,7 +196,17 @@ (let ((squares cubes (mapn (lambda (n) (values (expt n 2) (expt n 3))) - (iota 5)))) + (iota 5) + 2))) + (list squares cubes))) + +(test-equal "mapn on an empty list" + '(() ()) + (let ((squares cubes (mapn (lambda (n) + (values (expt n 2) + (expt n 3))) + '() + 2))) (list squares cubes))) (test-equal "foldn" @@ -211,4 +223,17 @@ '((1 . 2) (3 . 4) (5 . 6)) (pairify (list 1 2 3 4 5 6 7))) +(test-equal "resolve file syntax relative path" + (expand-file-name "foo.scm" + (dirname (current-filename))) + (resolve-file-syntax "foo.scm" #'"foo.scm")) + +(test-equal "resolve file syntax absolute path" + "/foo/bar.scm" + (resolve-file-syntax "/foo/bar.scm" #'"/foo/bar.scm")) + +(test-equal "resolve file syntax relative to current directory" + (expand-file-name "foo.scm") + (resolve-file-syntax "foo.scm" (datum->syntax #f "foo.scm" #:source '()))) + (test-end "utils") diff --git a/tests/yaml.scm b/tests/yaml.scm index f9df12d..c475dd9 100644 --- a/tests/yaml.scm +++ b/tests/yaml.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021, 2023 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2021, 2023, 2026 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -41,6 +41,12 @@ bar: {} " (scm->yaml-string #("*foo" "*bar"))) +(test-equal "strings with whitespace characters other than space must be escaped" + "- \"foo\\nbar\" +- \"foo\\tbar\" +" + (scm->yaml-string #("foo\nbar" "foo\tbar"))) + (test-equal "single element vectors must be serialized on the same line" "[foo] " |
