about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.guix/ccwl-package.scm8
-rw-r--r--Makefile10
-rw-r--r--README.org11
-rw-r--r--build-aux/test-driver.scm92
-rw-r--r--ccwl/cwl.scm9
-rwxr-xr-xscripts/ccwl101
-rw-r--r--tests/ccwl.scm3
-rw-r--r--tests/cwl.scm16
-rw-r--r--tests/ui.scm5
9 files changed, 104 insertions, 151 deletions
diff --git a/.guix/ccwl-package.scm b/.guix/ccwl-package.scm
index a70e3e0..d585daa 100644
--- a/.guix/ccwl-package.scm
+++ b/.guix/ccwl-package.scm
@@ -1,5 +1,5 @@
 ;;; ccwl --- Concise Common Workflow Language
-;;; Copyright © 2021, 2023–2024 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2021, 2023–2025 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of ccwl.
 ;;;
@@ -20,6 +20,7 @@
   #:use-module ((gnu packages bioinformatics) #:prefix guix:)
   #:use-module ((gnu packages emacs) #:select (emacs-minimal))
   #:use-module ((gnu packages fonts) #:select (font-charter font-fira-code))
+  #:use-module ((gnu packages guile-xyz) #:select (guile-run64))
   #:use-module ((guix build-system guile) #:select (%guile-build-system-modules))
   #:use-module (guix gexp)
   #:use-module (guix git-download)
@@ -34,7 +35,10 @@
                         "ccwl-checkout"
                         #:recursive? #t
                         #:select? (or (git-predicate (dirname (current-source-directory)))
-                                      (const #t))))))
+                                      (const #t))))
+    (native-inputs
+     (modify-inputs (package-native-inputs guix:ccwl)
+       (prepend guile-run64)))))
 
 (define ccwl-website-gexp
   (let ((development-profile
diff --git a/Makefile b/Makefile
index f4487d9..5a9b07f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 # ccwl --- Concise Common Workflow Language
-# Copyright © 2022, 2024 Arun Isaac <arunisaac@systemreboot.net>
+# Copyright © 2022, 2024–2025 Arun Isaac <arunisaac@systemreboot.net>
 #
 # This file is part of ccwl.
 #
@@ -24,12 +24,12 @@ GIT = git
 GPG = gpg
 GUILD = guild
 GUILE = guile
+GUILE_RUN64 = guile-run64
 LZIP = lzip
 SKRIBILO = skribilo
 
 FIND_DEPENDENCIES = build-aux/find-dependencies.scm
 GENERATE_CWL_OUTPUT = build-aux/generate-cwl-output.sh
-TEST_DRIVER = build-aux/test-driver.scm
 
 top_level_module_dir = $(project)
 sources = $(wildcard $(top_level_module_dir)/*.scm)
@@ -46,7 +46,7 @@ fonts = $(addprefix $(GUIX_ENVIRONMENT)/share/fonts/web/, charter_regular.woff2
 distribute_files = $(sources) $(scripts) $(tests) $(test_data) \
                    $(doc_sources) doc/skribilo.scm $(doc_data) $(DOC_SCM) $(DOC_OTHER) \
                    pre-inst-env guix.scm Makefile configure configure.scm \
-		   $(FIND_DEPENDENCIES) $(GENERATE_CWL_OUTPUT) $(TEST_DRIVER) \
+		   $(FIND_DEPENDENCIES) $(GENERATE_CWL_OUTPUT) \
 		   COPYING NEWS.org README.org
 
 scmdir = $(datarootdir)/guile/site/$(guile_effective_version)/$(top_level_module_dir)
@@ -63,8 +63,8 @@ all: $(objects)
 
 # Run tests
 
-check: $(tests) $(TEST_DRIVER)
-	$(GUILE) --no-auto-compile -L . $(TEST_DRIVER) $(tests)
+check:
+	./pre-inst-env $(GUILE_RUN64) $(tests)
 
 # Build documentation
 
diff --git a/README.org b/README.org
index 3d8e31a..3084234 100644
--- a/README.org
+++ b/README.org
@@ -36,14 +36,14 @@ Download the Docker image from [[https://github.com/arunisaac/ccwl/releases][the
 it. Then, run ccwl with command-line arguments of your choice.
 #+BEGIN_SRC shell
   $ docker load -i ccwl-docker.tar.gz
-  $ docker run ccwl [ARGS...]
+  $ docker run ccwl ccwl [ARGS...]
 #+END_SRC
 
 When passing files into the Docker container, remember to share the
 filesystem. The following command is one way to share the current
 directory with the container.
 #+BEGIN_SRC shell
-  $ docker run -v "$PWD:$PWD" -w "$PWD" ccwl compile foo.scm
+  $ docker run -v "$PWD:$PWD" -w "$PWD" ccwl ccwl compile foo.scm
 #+END_SRC
 
 ** Using Guix
@@ -80,8 +80,11 @@ introduction to ccwl.
 * Contributing
 
 Feedback, suggestions, feature requests, bug reports and pull requests
-are all welcome. Unclear and unspecific error messages are considered
-a bug. Do report them!
+are all welcome. Please write to [[mailto:ccwl@systemreboot.net][ccwl@systemreboot.net]]. You may also
+browse the [[https://lists.systemreboot.net/ccwl][archives]] of previous discussions. Unclear and unspecific
+error messages are considered a bug. Do report them!
+
+We do not accept issues or pull requests on GitHub. Thank you!
 
 To hack on ccwl, you can use GNU Guix to quickly drop into a
 development environment by running
diff --git a/build-aux/test-driver.scm b/build-aux/test-driver.scm
deleted file mode 100644
index adac481..0000000
--- a/build-aux/test-driver.scm
+++ /dev/null
@@ -1,92 +0,0 @@
-;;; ccwl --- Concise Common Workflow Language
-;;; Copyright © 2021, 2022 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/>.
-
-;;; Commentary:
-
-;; This is a better test driver for Guile's (srfi srfi-64).
-;;
-;; TODO: Improve Guile's test driver so this module won't be
-;; necessary.
-
-;;; Code:
-
-(use-modules (ice-9 format)
-             (ice-9 match)
-             (srfi srfi-26)
-             (srfi srfi-64)
-             (term ansi-color))
-
-(define (color color-symbol str color?)
-  (if color?
-      (colorize-string str color-symbol)
-      str))
-
-(define red (cut color 'RED <> <>))
-(define green (cut color 'GREEN <> <>))
-(define magenta (cut color 'MAGENTA <> <>))
-
-(define (my-gnu-runner color?)
-  (let ((runner (test-runner-null)))
-    (test-runner-on-group-begin! runner
-      (lambda (runner suite-name count)
-        (format #t (magenta "%%%% ~a~%" color?) suite-name)))
-    (test-runner-on-group-end! runner
-      (lambda _
-        (newline)))
-    (test-runner-on-test-end! runner
-      (lambda (runner)
-        (let ((name (test-runner-test-name runner))
-              (result (string-upcase
-                       (symbol->string (test-result-kind runner))))
-              (result-alist (test-result-alist runner)))
-          (format #t "~a ~a~%"
-                  (case (test-result-kind runner)
-                    ((pass) (green result color?))
-                    (else (red result color?)))
-                  name)
-          ;; If test did not pass, print details.
-          (unless (eq? (test-result-kind runner) 'pass)
-            (format (current-error-port)
-                    "~a:~a~%expected: ~s~%actual: ~s~%"
-                    (assq-ref result-alist 'source-file)
-                    (assq-ref result-alist 'source-line)
-                    (match (assq-ref result-alist 'source-form)
-                      (('test-assert _ ...) #t)
-                      (_ (assq-ref result-alist 'expected-value)))
-                    (assq-ref result-alist 'actual-value))))))
-    runner))
-
-(match (command-line)
-  ((_ test-files ...)
-   (let ((runner (my-gnu-runner #t)))
-     (test-with-runner runner
-       (for-each load-from-path test-files)
-       (display (magenta "SUMMARY" #t))
-       (newline)
-       (format #t "PASS: ~a
-FAIL: ~a
-XPASS: ~a
-XFAIL: ~a
-SKIP: ~a
-"
-               (test-runner-pass-count runner)
-               (test-runner-fail-count runner)
-               (test-runner-xpass-count runner)
-               (test-runner-xfail-count runner)
-               (test-runner-skip-count runner))
-       (exit (zero? (test-runner-fail-count runner)))))))
diff --git a/ccwl/cwl.scm b/ccwl/cwl.scm
index baef519..0f600ca 100644
--- a/ccwl/cwl.scm
+++ b/ccwl/cwl.scm
@@ -1,5 +1,5 @@
 ;;; ccwl --- Concise Common Workflow Language
-;;; Copyright © 2021, 2023–2024 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2021, 2023–2025 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of ccwl.
 ;;;
@@ -136,10 +136,13 @@ CWL YAML specification."
   "Render @var{input}, a @code{<input>} object, into a CWL tree."
   `(,(input-id input)
     (type . ,(type->cwl (input-type input)))
+    ;; The default property is special because a value of #f is
+    ;; meaningful and must be serialized.
+    ,@(if (unspecified-default? (input-default input))
+          '()
+          `((default . ,(input-default input))))
     ,@(or (filter-alist
            `((label . ,(input-label input))
-             (default . ,(and (not (unspecified-default? (input-default input)))
-                              (input-default input)))
              ;; inputBinding is only relevant to commands, not
              ;; workflows. But, the input position and prefix are not set
              ;; for worklow inputs and therefore this sub-expression has
diff --git a/scripts/ccwl b/scripts/ccwl
index 984d22a..fbd549d 100755
--- a/scripts/ccwl
+++ b/scripts/ccwl
@@ -3,7 +3,7 @@
 exec guile --no-auto-compile -e main -s "$0" "$@"
 !#
 ;;; ccwl --- Concise Common Workflow Language
-;;; Copyright © 2021–2024 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2021–2025 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of ccwl.
 ;;;
@@ -28,6 +28,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
 
 (use-modules (rnrs conditions)
              (rnrs exceptions)
+             (srfi srfi-26)
              (srfi srfi-28)
              (srfi srfi-37)
              (ice-9 match)
@@ -49,6 +50,52 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
           (lambda (opt name arg result)
             (acons 'help #t result))))
 
+(define %options
+  (list (option (list #\t "to") #t #f
+                (lambda (opt name arg result)
+                  (let ((supported (list "cwl" "dot")))
+                    (unless (member arg supported)
+                      (raise-exception
+                       (formatted-message "Invalid target ~a argument ~s. Supported targets are ~a."
+                                          (if (char? name)
+                                              (string #\- name)
+                                              (string-append "--" name))
+                                          arg
+                                          (string-join supported ", ")))))
+                  (acons 'to (string->symbol arg)
+                         result)))
+        (option (list #\o "output") #t #f
+                (lambda (opt name arg result)
+                  (acons 'output-file arg result)))
+        %help-option))
+
+(define (ccwl-compile source to port)
+  "Compile @var{source} file to @var{to} format writing output to
+@var{port}. @var{to} is either @code{'cwl} or @code{'dot}."
+  ;; We don't need to compile ccwl files. Loading is sufficient for
+  ;; our purposes. Besides, compiling would fail since the workflow
+  ;; macro cannot access command definitions.
+  (set! %load-should-auto-compile #f)
+  ((case to
+     ((cwl) function->cwl)
+     ((dot) function->dot))
+   (let ((result (guard (exception
+                         ;; Handle syntax violation exceptions by
+                         ;; reporting them and exiting.
+                         ((ccwl-violation? exception)
+                          (report-ccwl-violation exception)
+                          (exit #f)))
+                   (load (canonicalize-path source)
+                         read-syntax))))
+     (if (or (command? result)
+             (js-expression? result)
+             (workflow? result))
+         result
+         (raise-exception
+          (formatted-message "Last expression in file ~a returns none of workflow, command or js-expression"
+                             source))))
+   port))
+
 (define (main args)
   (with-exception-handler
       (lambda (condition)
@@ -75,30 +122,17 @@ Thank you!
       (match args
         ((program "compile" args ...)
          (let* ((args (args-fold args
-                                 (list (option (list #\t "to") #t #f
-                                               (lambda (opt name arg result)
-                                                 (let ((supported (list "cwl" "dot")))
-                                                   (unless (member arg supported)
-                                                     (scm-error 'misc-error
-                                                                #f
-                                                                "Invalid target ~A argument ~S. Supported targets are ~A."
-                                                                (list (if (char? name)
-                                                                          (string #\- name)
-                                                                          (string-append "--" name))
-                                                                      arg
-                                                                      (string-join supported ", "))
-                                                                #f)))
-                                                 (acons 'to arg result)))
-                                       %help-option)
+                                 %options
                                  invalid-option
                                  (lambda (arg result)
                                    (acons 'source-file arg result))
-                                 '((to . "cwl")))))
+                                 '((to . cwl)))))
            (when (or (assq 'help args)
                      (not (assq-ref args 'source-file)))
              (display (format "Usage: ~a compile [OPTIONS] SOURCE-FILE
 Compile SOURCE-FILE.
 
+  -o, --output=FILE  write compiled output to file
   -t, --to=TARGET    compile SOURCE-FILE to TARGET language;
                      Supported targets are cwl (default) and dot.
 
@@ -106,30 +140,15 @@ Compile SOURCE-FILE.
                               program)
                       (current-error-port))
              (exit (assq 'help args)))
-           ;; We don't need to compile ccwl files. Loading is sufficient
-           ;; for our purposes. Besides, compiling would fail since the
-           ;; workflow macro cannot access command definitions.
-           (set! %load-should-auto-compile #f)
-           (let ((to (assq-ref args 'to)))
-             ((cond
-               ((string=? to "cwl") function->cwl)
-               ((string=? to "dot") function->dot))
-              (guard (exception
-                      ;; Handle syntax violation exceptions by reporting
-                      ;; them and exiting.
-                      ((ccwl-violation? exception)
-                       (report-ccwl-violation exception)
-                       (exit #f)))
-                (let ((result (load (canonicalize-path (assq-ref args 'source-file))
-                                      read-syntax)))
-                  (if (or (command? result)
-                          (js-expression? result)
-                          (workflow? result))
-                      result
-                      (raise-exception
-                       (condition (formatted-message "Last expression in file ~a returns none of workflow, command or js-expression"
-                                                     (assq-ref args 'source-file)))))))
-              (current-output-port)))))
+           (if (assq-ref args 'output-file)
+               (call-with-output-file (assq-ref args 'output-file)
+                 (cut ccwl-compile
+                      (assq-ref args 'source-file)
+                      (assq-ref args 'to)
+                      <>))
+               (ccwl-compile (assq-ref args 'source-file)
+                             (assq-ref args 'to)
+                             (current-output-port)))))
         ((program args ...)
          (let ((args (args-fold args
                                 (list %help-option)
diff --git a/tests/ccwl.scm b/tests/ccwl.scm
index 2d755ad..e10d9f2 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–2025 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of ccwl.
 ;;;
@@ -20,6 +20,7 @@
              (srfi srfi-1)
              (srfi srfi-64)
              (srfi srfi-71)
+             (ice-9 match)
              (ccwl ccwl)
              (ccwl conditions))
 
diff --git a/tests/cwl.scm b/tests/cwl.scm
index ba619ab..8009a2e 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 #f '())))
+
 (test-end "cwl")
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))