From bb6b3e677cc35c8f55d8e167b2c35b915e3a8dfe Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 16 Oct 2023 15:30:55 +0100 Subject: ccwl: Raise &ccwl-violation on invalid command #:run arguments. * ccwl/ccwl.scm (command): Raise &ccwl-violation on invalid command #:run arguments. * tests/ccwl.scm ("command definitions with invalid #:run arguments must raise a &ccwl-violation condition"): New test. --- ccwl/ccwl.scm | 7 +++++-- tests/ccwl.scm | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index a319105..695fa8d 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -347,8 +347,11 @@ RUN-ARGS. If such an input is not present in RUN-ARGS, return #f." (begin (ensure-input-is-defined #'input) #''input)) - (_ (error "Invalid command element:" - (syntax->datum x))))) + (_ + (raise-exception + (condition (ccwl-violation x) + (formatted-message "Invalid command element ~a. Command elements must either be input identifiers or literal strings." + (syntax->datum x))))))) run))) #,(and stdin #`'#,stdin) #,(if (and stderr diff --git a/tests/ccwl.scm b/tests/ccwl.scm index 334633b..aef2a85 100644 --- a/tests/ccwl.scm +++ b/tests/ccwl.scm @@ -252,4 +252,13 @@ #:run "echo" ("-x" n))) #f))) +(test-assert "command definitions with invalid #:run arguments must raise a &ccwl-violation condition" + (guard (exception + (else (and (ccwl-violation? exception) + (string=? (formatted-message-format exception) + "Invalid command element ~a. Command elements must either be input identifiers or literal strings.")))) + (begin (macroexpand + '(command #:run "echo" 42)) + #f))) + (test-end "ccwl") -- cgit v1.2.3