summaryrefslogtreecommitdiff
path: root/tests/cache.scm
diff options
authorRicardo Wurmus <[email protected]>2024-03-26 13:33:04 +0100
committerRicardo Wurmus <[email protected]>2024-03-26 22:24:58 +0100
commitf4442e409cf05d0c7cc4d6a251626d22efaffe8c (patch)
treea8cc891940a2d8e63bd539fc4220c082f56f7775 /tests/cache.scm
parent9db762cc380cdd4b1fdfab5d0e45a7d38f5041e7 (diff)
downloadgwl-master.tar.gz
Use more hash tables instead of alists.HEADmaster
* gwl/cache.scm (workflow->data-hashes, make-process->cache-prefix): Use a hash table for FREE-INPUTS-MAP. * gwl/workflows.scm (compute-workflow): Use hash table instead of LSET-INTERSECTION. (inputs->map): Return hash table. (prepare-inputs): Expect a hash table for INPUTS-MAP. * tests/cache.scm, tests/workflows.scm: Update to deal with hash tables.
Diffstat (limited to 'tests/cache.scm')
-rw-r--r--tests/cache.scm66
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