diff options
| author | Arun Isaac | 2026-06-25 17:19:39 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-06-26 01:39:25 +0100 |
| commit | 7db773fdb71b15353e9c15c908867d308b887a7b (patch) | |
| tree | dc8cbef825748b88c47425601903a115ef01adfc | |
| parent | 3c4a04a11589c630a9601ecc3ed418424724eb1e (diff) | |
| download | ccwl-7db773fdb71b15353e9c15c908867d308b887a7b.tar.gz ccwl-7db773fdb71b15353e9c15c908867d308b887a7b.tar.lz ccwl-7db773fdb71b15353e9c15c908867d308b887a7b.zip | |
lang: Raise &ccwl-violation when loading non-existent source files.
| -rw-r--r-- | ccwl/lang.scm | 25 | ||||
| -rw-r--r-- | tests/lang.scm | 6 |
2 files changed, 24 insertions, 7 deletions
diff --git a/ccwl/lang.scm b/ccwl/lang.scm index c9ebae3..1189287 100644 --- a/ccwl/lang.scm +++ b/ccwl/lang.scm @@ -66,11 +66,22 @@ it." (condition-irritants c))))) (read-syntax port))) -(define (ccwl-load file) +(define (ccwl-load-helper file file-syntax) + "Load ccwl source @var{file}. @var{file-syntax} is the syntax object +wrapping @var{file}." + (if (file-exists? file) + (let ((source-path (canonicalize-path file))) + ;; Change directory before loading source file. The source + ;; file may reference other files with paths relative to its + ;; directory. + (call-with-current-directory (dirname source-path) + (lambda () + (load source-path ccwl-read)))) + (raise-continuable + (condition (ccwl-violation file-syntax) + (formatted-message "File ~a does not exist" + file))))) + +(define-syntax-rule (ccwl-load file) "Load ccwl source @var{file}." - (let ((source-path (canonicalize-path file))) - ;; Change directory before loading source file. The source file - ;; may reference other files with paths relative to its directory. - (call-with-current-directory (dirname source-path) - (lambda () - (load source-path ccwl-read))))) + (ccwl-load-helper file #'file)) diff --git a/tests/lang.scm b/tests/lang.scm index 247f2e1..d8a891b 100644 --- a/tests/lang.scm +++ b/tests/lang.scm @@ -17,6 +17,8 @@ ;;; 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") @@ -24,4 +26,8 @@ (test-assert "load source file referencing external CWL workflow relative to it" (ccwl-load "test-data/external-cwl-workflow.scm")) +(test-condition "loading non-existent source file must raise a &ccwl-violation" + ccwl-violation? + (ccwl-load "/non-existent/file.scm")) + (test-end "lang") |
