aboutsummaryrefslogtreecommitdiff
path: root/ccwl/ccwl.scm
diff options
context:
space:
mode:
authorArun Isaac2023-10-16 15:19:27 +0100
committerArun Isaac2023-10-16 15:22:08 +0100
commit5e774d8f08d9a89352873289d856d0d5c2a47f41 (patch)
tree4f19693fae08ff3010f2780570de204e59df4833 /ccwl/ccwl.scm
parent2a3ba9b993575da807ecf0f99a5c77ab5076a003 (diff)
downloadccwl-5e774d8f08d9a89352873289d856d0d5c2a47f41.tar.gz
ccwl-5e774d8f08d9a89352873289d856d0d5c2a47f41.tar.lz
ccwl-5e774d8f08d9a89352873289d856d0d5c2a47f41.zip
ccwl: Check if inputs in command definitions are defined.
* ccwl/ccwl.scm (command): Check if inputs used in #:run arguments of command definitions are actually defined. * tests/ccwl.scm ("command definitions with undefined inputs in their #:run arguments must raise a &ccwl-violation condition", "command definitions with undefined prefix inputs in their #:run arguments must raise a &ccwl-violation condition"): New tests.
Diffstat (limited to 'ccwl/ccwl.scm')
-rw-r--r--ccwl/ccwl.scm47
1 files changed, 31 insertions, 16 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index 05cb6e6..a319105 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -319,22 +319,37 @@ RUN-ARGS. If such an input is not present in RUN-ARGS, return #f."
#,(run-arg-prefix id run))))
inputs))
(list #,@(map output outputs))
- (list #,@(map (lambda (x)
- (syntax-case x ()
- ;; Replace input symbol with quoted symbol.
- (input (identifier? #'input)
- #''input)
- ;; Leave string as is.
- (string-arg (string? (syntax->datum #'string-arg))
- #'string-arg)
- ;; Replace prefixed input symbol with
- ;; quoted symbol.
- ((prefix input) (and (string? (syntax->datum #'prefix))
- (identifier? #'input))
- #''input)
- (_ (error "Invalid command element:"
- (syntax->datum x)))))
- run))
+ (list #,@(let ((ensure-input-is-defined
+ ;; Ensure that specified input is
+ ;; defined in #:inputs of command
+ ;; definition.
+ (lambda (input)
+ (unless (memq (syntax->datum input)
+ (map input-spec-id inputs))
+ (raise-exception
+ (condition (ccwl-violation input)
+ (formatted-message "Undefined input ~a"
+ (syntax->datum input))))))))
+ (map (lambda (x)
+ (syntax-case x ()
+ ;; Replace input symbol with quoted symbol.
+ (input (identifier? #'input)
+ (begin
+ (ensure-input-is-defined #'input)
+ #''input))
+ ;; Leave string as is.
+ (string-arg (string? (syntax->datum #'string-arg))
+ #'string-arg)
+ ;; Replace prefixed input symbol with
+ ;; quoted symbol.
+ ((prefix input) (and (string? (syntax->datum #'prefix))
+ (identifier? #'input))
+ (begin
+ (ensure-input-is-defined #'input)
+ #''input))
+ (_ (error "Invalid command element:"
+ (syntax->datum x)))))
+ run)))
#,(and stdin #`'#,stdin)
#,(if (and stderr
(not (string? (syntax->datum stderr))))