forked from philhofer/distill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plan-test.scm
68 lines (61 loc) · 1.97 KB
/
plan-test.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(import
scheme
(chicken file)
(only (chicken io) read-string)
(distill hash)
(distill filepath)
(distill plan))
(include "test-helpers.scm")
(define (make-empty dir)
(when (directory-exists? dir)
(delete-directory dir #t))
(create-directory dir))
(for-each make-empty '("./test-artifacts" "./test-plans"))
(artifact-dir "./test-artifacts")
(plan-dir "./test-plans")
(define build
(interned
"/build" #o755
(lambda ()
(display "#!/bin/sh -e")
(newline)
(display "echo OK! > /out/script-out")
(newline))))
(let ((text "#!/bin/sh -e\necho OK! > /out/script-out\n")
(path (filepath-join (artifact-dir) (artifact-hash build))))
(test (hash-of text)
(artifact-hash build))
(test path (file-exists? path))
(test text (with-input-from-file path read-string)))
(let* ((foo (interned
"/etc/foo" #o755 "file is foo"))
(frob (interned
"/etc/frob" #o755 "file is frob"))
(pln (make-plan
name: "test-match-plan"
null-build: #t
inputs: (list
(make-input
basedir: "/out"
link: foo)
(make-input
basedir: "/out"
link: frob)))))
(build-graph! (list pln))
(let ((art (plan-outputs pln)))
(let* ((globs '("./etc/f*"))
(deriv (make-plan
name: "test-deriv"
null-build: #t
inputs: (list
(make-input
basedir: "/out"
link: pln
wrap: (lambda (art)
(sub-archive art globs))))))
(art2 (plan-outputs (begin (build-graph! (list deriv)) deriv))))
(test string=?
(artifact-hash art)
(artifact-hash art2)))))
(delete-directory "./test-artifacts" #t)
(delete-directory "./test-plans" #t)