From bc6bc78ac3079822dcd5bc51e36983a7470fdc04 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 16 Oct 2023 17:32:57 +0100 Subject: ccwl: Error out on prefixes that are not strings. * ccwl/ccwl.scm (run-args): Error out on prefixes that are not strings. * tests/ccwl.scm ("command definitions with non-string prefixes in prefixed inputs must raise a &ccwl-violation condition"): New test. --- ccwl/ccwl.scm | 6 ++++++ tests/ccwl.scm | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index a476406..f9243aa 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -307,6 +307,12 @@ identifiers defined in the commands." ((prefix string-arg) (and (string? (syntax->datum #'prefix)) (string? (syntax->datum #'string-arg))) (list #'prefix #'string-arg)) + ;; Prefixes that are not strings + ((prefix _) + (raise-exception + (condition (ccwl-violation #'prefix) + (formatted-message "Invalid prefix ~a. Prefixes must be strings." + (syntax->datum #'prefix))))) (_ (raise-exception (condition (ccwl-violation x) diff --git a/tests/ccwl.scm b/tests/ccwl.scm index 7cbb2c0..b26e854 100644 --- a/tests/ccwl.scm +++ b/tests/ccwl.scm @@ -264,4 +264,14 @@ (test-assert "tolerate prefixed string arguments in command definitions" (command #:run "echo" ("-x" "foo"))) +(test-assert "command definitions with non-string prefixes in prefixed inputs must raise a &ccwl-violation condition" + (guard (exception + (else (and (ccwl-violation? exception) + (string=? (formatted-message-format exception) + "Invalid prefix ~a. Prefixes must be strings.")))) + (begin (macroexpand + '(command #:inputs (number #:type int) + #:run "echo" (-x number))) + #f))) + (test-end "ccwl") -- cgit v1.2.3