diff options
Diffstat (limited to 'tests/cache.scm')
| -rw-r--r-- | tests/cache.scm | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/tests/cache.scm b/tests/cache.scm index 28e0f8d..3bb53ca 100644 --- a/tests/cache.scm +++ b/tests/cache.scm @@ -1,4 +1,4 @@ -;;; Copyright © 2020, 2021, 2022 Ricardo Wurmus <[email protected]> +;;; Copyright © 2020-2024 Ricardo Wurmus <[email protected]> ;;; ;;; This program is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ #:select (u8-list->bytevector)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-64) + #:use-module (ice-9 hash-table) #:use-module (ice-9 match)) (test-begin "cache") @@ -85,27 +86,28 @@ (define workflow->data-hashes (@@ (gwl cache) workflow->data-hashes)) -(test-assert "workflow->data-hashes returns a list" - (list? (workflow->data-hashes wf - ordered-processes - '() - scripts-table))) +(test-assert "workflow->data-hashes returns a hash table" + (hash-table? (workflow->data-hashes wf + ordered-processes + (alist->hash-table '()) + scripts-table))) -(test-assert "workflow->data-hashes returns an alist where all processes are keys" +(test-assert "workflow->data-hashes returns a hash table where all processes are keys" (let ((hashes (workflow->data-hashes wf ordered-processes - '() + (alist->hash-table '()) scripts-table))) (every (lambda (process) - (assoc-ref hashes process)) + (hash-ref hashes process)) ordered-processes))) -(test-assert "workflow->data-hashes returns an alist where all values are strings" - (let ((hashes (workflow->data-hashes wf - ordered-processes - '() - scripts-table))) - (every string? (map cdr hashes)))) +(test-assert "workflow->data-hashes returns an hash table where all values are strings" + (let* ((hashes (workflow->data-hashes wf + ordered-processes + (alist->hash-table '()) + scripts-table)) + (vals (hash-map->list (compose cdr cons) hashes))) + (every string? vals))) (define process->hash (@@ (gwl cache) process->hash)) @@ -120,34 +122,34 @@ (test-equal "workflow->data-hashes hashes just the script for an independent process" (hashes->hash-string (list (process->hash p1 scripts-table))) - (assoc-ref (workflow->data-hashes wf - ordered-processes - '() - scripts-table) - p1)) + (hash-ref (workflow->data-hashes wf + ordered-processes + (alist->hash-table '()) + scripts-table) + p1)) (test-equal "workflow->data-hashes hashes the script and its inputs" (hashes->hash-string (list (process->hash p4 scripts-table) (hash-input-file* input-file))) - (assoc-ref (workflow->data-hashes wf - ordered-processes - (list - (list input-file input-file)) - scripts-table) - p4)) + (hash-ref (workflow->data-hashes wf + ordered-processes + (alist->hash-table + `((,input-file . ,input-file))) + scripts-table) + p4)) (test-equal "workflow->data-hashes hashes all dependencies of a process" (hashes->hash-string (list (process->hash p3 scripts-table) (process->hash p4 scripts-table) (hash-input-file* input-file))) - (assoc-ref (workflow->data-hashes wf - ordered-processes - (list - (list input-file input-file)) - scripts-table) - p3)) + (hash-ref (workflow->data-hashes wf + ordered-processes + (alist->hash-table + `((,input-file . ,input-file))) + scripts-table) + p3)) (test-assert "cache! creates directories as needed" (begin |
