substrate-lang 0.9.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +1 -1
  2. package/build/compiler/{binary.cdd2ffb408dd@0+0.wasm → binary.2d43b43d1600@0+0.wasm} +0 -0
  3. package/build/compiler/checker.4dd4556dd421@0+0.wasm +0 -0
  4. package/build/compiler/{compile.da85f9bc4478@0+0.wasm → compile.5d8f6407af2a@0+0.wasm} +0 -0
  5. package/build/compiler/{core.0410ffbdc488@0+0.wasm → core.f2defb75e00b@0+0.wasm} +0 -0
  6. package/build/compiler/expander.967ce443d379@0+0.wasm +0 -0
  7. package/build/compiler/fs.01b8aab4a9a8@0+0.wasm +0 -0
  8. package/build/compiler/{leb128.ba77430f659f@0+0.wasm → leb128.15d814b7b4f2@0+0.wasm} +0 -0
  9. package/build/compiler/{link.be6e641afa93@0+0.wasm → link.b826ea7c8f17@0+0.wasm} +0 -0
  10. package/build/compiler/{macros.b695763c0ca3@0+0.wasm → macros.b269e0c42784@0+0.wasm} +0 -0
  11. package/build/compiler/{main.cbbdf42e34c2@0+0.wasm → main.4fc52f204d54@0+0.wasm} +0 -0
  12. package/build/compiler/{ops.324f0a665fab@0+0.wasm → ops.515b5e05f646@0+0.wasm} +0 -0
  13. package/build/compiler/{path.1b5fd988b6f3@0+0.wasm → path.5a6286472cd4@0+0.wasm} +0 -0
  14. package/build/compiler/program +21 -21
  15. package/build/compiler/{prune.29dde307bdee@0+0.wasm → prune.406215c3e4f8@0+0.wasm} +0 -0
  16. package/build/compiler/reader.694b03770bf0@0+0.wasm +0 -0
  17. package/build/compiler/roots.cefd10e93684@0+0.wasm +0 -0
  18. package/build/compiler/{running.b99787c2d180@0+0.wasm → running.0d25dbaec018@0+0.wasm} +0 -0
  19. package/build/compiler/serialize.b0d82f3d63d2@0+0.wasm +0 -0
  20. package/build/compiler/{sha256.f6c742932dde@0+0.wasm → sha256.a6c32b04d799@0+0.wasm} +0 -0
  21. package/build/compiler/substrate.5ee5d0b4d3e7@0+0.wasm +0 -0
  22. package/build/compiler/{syntax.fadc832db29f@0+0.wasm → syntax.32f3e40b61c7@0+0.wasm} +0 -0
  23. package/build/compiler/{writer.550227768eb9@0+0.wasm → writer.00b7802cbe39@0+0.wasm} +0 -0
  24. package/build/sub/{base64.454b045156d2@0+0.wasm → base64.a26bdcf60a2d@0+0.wasm} +0 -0
  25. package/build/sub/build.459c5b9412bd@0+0.wasm +0 -0
  26. package/build/sub/chromium.3d5818f2707d@0+0.wasm +0 -0
  27. package/build/sub/common.1edc613607a0@0+0.wasm +0 -0
  28. package/build/sub/deflate.23f7c4679260@0+0.wasm +0 -0
  29. package/build/sub/doc.0775df5de6fe@0+0.wasm +0 -0
  30. package/build/sub/{doc.f18ad14060e9@0+0.wasm → doc.ef9965d5d402@0+0.wasm} +0 -0
  31. package/build/sub/env.e5451da6e747@0+0.wasm +0 -0
  32. package/build/sub/events.bf5473ebf220@0+0.wasm +0 -0
  33. package/build/sub/fetch.7790d4943758@0+0.wasm +0 -0
  34. package/build/sub/fetch.96b2d10f025e@0+0.wasm +0 -0
  35. package/build/sub/files.ad0469fdf6fa@0+0.wasm +0 -0
  36. package/build/sub/fs.01b8aab4a9a8@0+0.wasm +0 -0
  37. package/build/sub/git.dc4c0e757ebe@0+0.wasm +0 -0
  38. package/build/sub/grants.c54776c0d7e3@0+0.wasm +0 -0
  39. package/build/sub/gzip.16e372eda1cf@0+0.wasm +0 -0
  40. package/build/sub/hash.660682e4f491@0+0.wasm +0 -0
  41. package/build/sub/{html.0b0362932a75@0+0.wasm → html.a23126eb949a@0+0.wasm} +0 -0
  42. package/build/sub/{html.3b3c8d7d9971@0+0.wasm → html.e9ed37f34977@0+0.wasm} +0 -0
  43. package/build/sub/{inflate.3cfa17586072@0+0.wasm → inflate.59bb61f14001@0+0.wasm} +0 -0
  44. package/build/sub/json.55590d2f518a@0+0.wasm +0 -0
  45. package/build/sub/manifest.ef317480deb0@0+0.wasm +0 -0
  46. package/build/sub/{map.e582eae03ec2@0+0.wasm → map.f455cca6a42a@0+0.wasm} +0 -0
  47. package/build/sub/pack.e02836264f6a@0+0.wasm +0 -0
  48. package/build/sub/{path.1b5fd988b6f3@0+0.wasm → path.5a6286472cd4@0+0.wasm} +0 -0
  49. package/build/sub/path.6891ffea73ca@0+0.wasm +0 -0
  50. package/build/sub/process.7106571fa723@0+0.wasm +0 -0
  51. package/build/sub/program +48 -48
  52. package/build/sub/read.0b93933d62a2@0+0.wasm +0 -0
  53. package/build/sub/{reader.d256e69e09e2@0+0.wasm → reader.694b03770bf0@0+0.wasm} +0 -0
  54. package/build/sub/{root.02141d04d568@0+0.wasm → root.f10a4906f460@0+0.wasm} +0 -0
  55. package/build/sub/{roots.e366210c01d6@0+0.wasm → roots.cefd10e93684@0+0.wasm} +0 -0
  56. package/build/sub/{sha256.f6c742932dde@0+0.wasm → sha256.a6c32b04d799@0+0.wasm} +0 -0
  57. package/build/sub/{sha512.9fee24e95460@0+0.wasm → sha512.c24a792d7891@0+0.wasm} +0 -0
  58. package/build/sub/site.1732b58ec0e8@0+0.wasm +0 -0
  59. package/build/sub/site.ae3913b0b0f4@0+0.wasm +0 -0
  60. package/build/sub/store.a24d7a25daa6@0+0.wasm +0 -0
  61. package/build/sub/stream.126e3bd5d626@0+0.wasm +0 -0
  62. package/build/sub/sub.2e3092140706@0+0.wasm +0 -0
  63. package/build/sub/substrate.5ee5d0b4d3e7@0+0.wasm +0 -0
  64. package/build/sub/{syntax.fadc832db29f@0+0.wasm → syntax.32f3e40b61c7@0+0.wasm} +0 -0
  65. package/build/sub/tar.2a633861e654@0+0.wasm +0 -0
  66. package/build/sub/test.9bd59c73f65e@0+0.wasm +0 -0
  67. package/build/sub/{text.8ff142d72fd7@0+0.wasm → text.1bc90482bd43@0+0.wasm} +0 -0
  68. package/build/sub/{timer.d3454726b3bf@0+0.wasm → timer.f35eb62ae446@0+0.wasm} +0 -0
  69. package/build/sub/upgrade.39ee449b00d5@0+0.wasm +0 -0
  70. package/build/sub/{utf8.e82afeb9e953@0+0.wasm → utf8.e7216bd054e1@0+0.wasm} +0 -0
  71. package/build/sub/worker.762a9d642af0@0+0.wasm +0 -0
  72. package/build/sub/writer.00b7802cbe39@0+0.wasm +0 -0
  73. package/package.json +1 -1
  74. package/std/archive/tar.sub +30 -23
  75. package/std/browser/chromium.sub +5 -4
  76. package/std/browser/devtools.sub +24 -19
  77. package/std/compress/gzip.sub +18 -16
  78. package/std/compress/inflate.sub +7 -4
  79. package/std/crypto/password.sub +3 -3
  80. package/std/doc/doc.sub +2 -2
  81. package/std/encoding/json.sub +20 -8
  82. package/std/encoding/wire.sub +9 -7
  83. package/std/http/form.sub +2 -2
  84. package/std/http/multipart.sub +8 -10
  85. package/std/http/route.sub +9 -4
  86. package/std/http/server.sub +14 -11
  87. package/std/http/session.sub +2 -2
  88. package/std/http/static.sub +5 -5
  89. package/std/meta/derive.sub +0 -2
  90. package/std/meta/method.sub +41 -0
  91. package/std/meta/type-info.sub +30 -37
  92. package/std/package/files.sub +24 -25
  93. package/std/package/git.sub +26 -33
  94. package/std/package/hash.sub +8 -8
  95. package/std/package/manifest.sub +67 -42
  96. package/std/package/map.sub +1 -1
  97. package/std/package/pack.sub +13 -13
  98. package/std/package/read.sub +7 -6
  99. package/std/package/site.sub +7 -7
  100. package/std/package/store.sub +16 -12
  101. package/std/package.sub +6 -6
  102. package/std/test/browser.sub +9 -8
  103. package/std/test/build.sub +2 -2
  104. package/std/test/page.sub +31 -26
  105. package/std/test/run.sub +8 -7
  106. package/std/test/test.sub +12 -13
  107. package/std/vector/vector.sub +75 -0
  108. package/substrate/VERSION +1 -1
  109. package/substrate/compiler/checker.sub +40 -212
  110. package/substrate/compiler/compile.sub +3 -3
  111. package/substrate/compiler/expander.sub +32 -50
  112. package/substrate/compiler/main.sub +9 -9
  113. package/substrate/compiler/reader.sub +4 -4
  114. package/substrate/compiler/roots.sub +8 -8
  115. package/substrate/compiler/running.sub +1 -1
  116. package/substrate/compiler/serialize.sub +56 -49
  117. package/substrate/compiler/substrate.sub +53 -11
  118. package/substrate/host/errors.mjs +3 -2
  119. package/substrate/host/events.sub +3 -16
  120. package/substrate/host/fs.mjs +5 -4
  121. package/substrate/host/fs.sub +135 -102
  122. package/substrate/host/grants.mjs +1 -1
  123. package/substrate/host/grants.sub +8 -7
  124. package/substrate/host/modules/fake.mjs +1 -1
  125. package/substrate/host/modules/websocket.mjs +4 -4
  126. package/substrate/host/modules/websocket.sub +8 -6
  127. package/substrate/host/node/env.mjs +12 -6
  128. package/substrate/host/node/env.sub +21 -16
  129. package/substrate/host/node/fs.mjs +1 -1
  130. package/substrate/host/node/net.mjs +2 -2
  131. package/substrate/host/node/net.sub +13 -6
  132. package/substrate/host/node/process.mjs +4 -4
  133. package/substrate/host/node/process.sub +25 -24
  134. package/substrate/host/node/signal.mjs +3 -2
  135. package/substrate/host/node/signal.sub +9 -6
  136. package/substrate/host/node/watch.mjs +1 -1
  137. package/substrate/host/node/watch.sub +11 -9
  138. package/substrate/host/stream.sub +2 -0
  139. package/substrate/host/subhost-core.mjs +9 -1
  140. package/substrate/host/web/clipboard.mjs +2 -2
  141. package/substrate/host/web/clipboard.sub +10 -3
  142. package/substrate/host/web/files.mjs +2 -2
  143. package/substrate/host/web/files.sub +6 -2
  144. package/substrate/host/web/fs.mjs +3 -3
  145. package/substrate/host/web/location.mjs +3 -1
  146. package/substrate/host/web/location.sub +8 -4
  147. package/substrate/host/worker-side.mjs +3 -1
  148. package/substrate/host/worker.mjs +6 -5
  149. package/substrate/host/worker.sub +10 -10
  150. package/build/compiler/checker.2b0ea87ed311@0+0.wasm +0 -0
  151. package/build/compiler/expander.80707e1666d6@0+0.wasm +0 -0
  152. package/build/compiler/fs.5017b627cbd2@0+0.wasm +0 -0
  153. package/build/compiler/reader.d256e69e09e2@0+0.wasm +0 -0
  154. package/build/compiler/roots.e366210c01d6@0+0.wasm +0 -0
  155. package/build/compiler/serialize.a12536bbbe9a@0+0.wasm +0 -0
  156. package/build/compiler/substrate.728c690187f2@0+0.wasm +0 -0
  157. package/build/sub/build.115aeefc15e8@0+0.wasm +0 -0
  158. package/build/sub/chromium.fc0bfea0fbe6@0+0.wasm +0 -0
  159. package/build/sub/common.997c21b0b8cf@0+0.wasm +0 -0
  160. package/build/sub/deflate.3138a38325a1@0+0.wasm +0 -0
  161. package/build/sub/doc.e3f9a998cd91@0+0.wasm +0 -0
  162. package/build/sub/env.861d55fff974@0+0.wasm +0 -0
  163. package/build/sub/events.2c981f6f1ec7@0+0.wasm +0 -0
  164. package/build/sub/fetch.b0ce8f8b3da8@0+0.wasm +0 -0
  165. package/build/sub/fetch.d62aa5fc9623@0+0.wasm +0 -0
  166. package/build/sub/files.1706cc0941c0@0+0.wasm +0 -0
  167. package/build/sub/fs.5017b627cbd2@0+0.wasm +0 -0
  168. package/build/sub/git.1c5791236e35@0+0.wasm +0 -0
  169. package/build/sub/grants.cd99dff2854e@0+0.wasm +0 -0
  170. package/build/sub/gzip.9ebea150f218@0+0.wasm +0 -0
  171. package/build/sub/hash.ba8330dad9ff@0+0.wasm +0 -0
  172. package/build/sub/json.af2e0ae20084@0+0.wasm +0 -0
  173. package/build/sub/manifest.6e014ac19e5d@0+0.wasm +0 -0
  174. package/build/sub/pack.4295e4f5bdbd@0+0.wasm +0 -0
  175. package/build/sub/path.de22f6659534@0+0.wasm +0 -0
  176. package/build/sub/process.ca10ac0b8a62@0+0.wasm +0 -0
  177. package/build/sub/read.279fafcda508@0+0.wasm +0 -0
  178. package/build/sub/site.76aa8286c257@0+0.wasm +0 -0
  179. package/build/sub/site.e6e415bc3170@0+0.wasm +0 -0
  180. package/build/sub/store.c48db3345968@0+0.wasm +0 -0
  181. package/build/sub/stream.27fd2fe858e1@0+0.wasm +0 -0
  182. package/build/sub/sub.c0fb7310de12@0+0.wasm +0 -0
  183. package/build/sub/substrate.728c690187f2@0+0.wasm +0 -0
  184. package/build/sub/tar.692c0e8827cd@0+0.wasm +0 -0
  185. package/build/sub/test.1fd2ff8123bf@0+0.wasm +0 -0
  186. package/build/sub/upgrade.2a9219e6a45d@0+0.wasm +0 -0
  187. package/build/sub/worker.ea1e11f8f5e2@0+0.wasm +0 -0
  188. package/build/sub/writer.550227768eb9@0+0.wasm +0 -0
@@ -5,30 +5,29 @@
5
5
 
6
6
  (provide git-tracked)
7
7
 
8
- ;; git-tracked adds the paths, relative to dir, of the regular files the index lists under dir. It gives 1 when they
9
- ;; include dir's marker file, 0 when they do not or no repository holds dir, and -1, with err set, when it cannot read
10
- ;; the index.
11
- (define (git-tracked [a (ptr arena)] [dir string] [marker string] [into (ptr buffer)] [err (ptr buffer)]) -> i32
12
- (let ([top string] [git string] [b (slice u8)] [why string] [prefix ""] [index string] [name (make-buffer)]
13
- [got i32 0])
14
- (unless (repository a dir (& top) (& git)) (return 0))
8
+ ;; git-tracked adds the paths, relative to dir, of the regular files the index lists under dir. It sets marked when they
9
+ ;; include dir's marker file.
10
+ (define (git-tracked [a (ptr arena)] [dir string] [marker string] [into (ptr buffer)] [marked (ptr bool)]
11
+ [err (ptr buffer)]) -> bool
12
+ (let ([top string] [git string] [b (slice u8)] [prefix ""] [index string] [name (make-buffer)] [got i32 0])
13
+ (set! (@ marked) #f)
14
+ (unless (repository a dir (& top) (& git)) (return #t))
15
15
  (unless (== dir top)
16
16
  (let ([p (joined-path (slice dir (if (== top "/") 1 (+ (-> top length) 1))) "")])
17
17
  (set! prefix (kept a p))
18
18
  (free (-> p bytes))))
19
19
  (set! index (joined-path git "index"))
20
- (if (< (fs-read-file index (& b) (& why)) 0)
21
- (free (-> why bytes))
22
- (begin
23
- (set! got (listed! a b (oid-size git) prefix marker (& name) into))
24
- (free (-> b items))
25
- (when (< got 0)
26
- (buffer-add-string! err "cannot read the git index at ")
27
- (buffer-add-string! err index)
28
- (buffer-add-string! err ": sub reads index versions 2 to 4, but not a split or sparse index"))))
20
+ (when (fs-read-file index (& b) 0)
21
+ (set! got (listed! a b (oid-size git) prefix marker (& name) into))
22
+ (free (-> b items))
23
+ (when (< got 0)
24
+ (buffer-add-string! err "cannot read the git index at ")
25
+ (buffer-add-string! err index)
26
+ (buffer-add-string! err ": sub reads index versions 2 to 4, but not a split or sparse index")))
29
27
  (buffer-free! (& name))
30
28
  (free (-> index bytes))
31
- got))
29
+ (set! (@ marked) (== got 1))
30
+ (>= got 0)))
32
31
 
33
32
  ;; repository finds the working tree holding dir, and its git directory: the .git directory, or the directory a .git file
34
33
  ;; points to.
@@ -36,7 +35,7 @@
36
35
  (let ([d dir] [info fs-info] [found i32 0])
37
36
  (while (== found 0)
38
37
  (let ([dot (joined-path d ".git")])
39
- (cond [(== (fs-lstat dot (& info) 0) 0)
38
+ (cond [(fs-lstat dot (& info) 0)
40
39
  (set! found -1)
41
40
  (cond [(== (-> info kind) fs-directory)
42
41
  (set! (@ git) (kept a dot))
@@ -49,10 +48,8 @@
49
48
  (== found 1)))
50
49
 
51
50
  (define (named-git! [a (ptr arena)] [d string] [dot string] [git (ptr string)]) -> bool
52
- (let ([b (slice u8)] [why string] [s string] [end u32 8] [full string])
53
- (when (< (fs-read-file dot (& b) (& why)) 0)
54
- (free (-> why bytes))
55
- (return #f))
51
+ (let ([b (slice u8)] [s string] [end u32 8] [full string])
52
+ (unless (fs-read-file dot (& b) 0) (return #f))
56
53
  (set! s (cast string b))
57
54
  (unless (starts? s "gitdir: ")
58
55
  (free (-> b items))
@@ -65,24 +62,20 @@
65
62
  #t))
66
63
 
67
64
  (define (oid-size [git string]) -> u32
68
- (let ([common (common-dir git)] [config string] [b (slice u8)] [why string] [size u32 20])
65
+ (let ([common (common-dir git)] [config string] [b (slice u8)] [size u32 20])
69
66
  (set! config (joined-path common "config"))
70
- (if (< (fs-read-file config (& b) (& why)) 0)
71
- (free (-> why bytes))
72
- (begin
73
- (when (sha256-objects? (cast string b)) (set! size 32))
74
- (free (-> b items))))
67
+ (when (fs-read-file config (& b) 0)
68
+ (when (sha256-objects? (cast string b)) (set! size 32))
69
+ (free (-> b items)))
75
70
  (free (-> config bytes))
76
71
  (free (-> common bytes))
77
72
  size))
78
73
 
79
74
  ;; common-dir gives the main git directory of a worktree, which holds the config.
80
75
  (define (common-dir [git string]) -> string
81
- (let ([file (joined-path git "commondir")] [b (slice u8)] [why string] [s string] [end u32 0] [out string])
82
- (if (< (fs-read-file file (& b) (& why)) 0)
83
- (begin
84
- (free (-> why bytes))
85
- (set! out (string-copy git)))
76
+ (let ([file (joined-path git "commondir")] [b (slice u8)] [s string] [end u32 0] [out string])
77
+ (if (not (fs-read-file file (& b) 0))
78
+ (set! out (string-copy git))
86
79
  (begin
87
80
  (set! s (cast string b))
88
81
  (while (and (< end (-> s length)) (!= (@ s end) 10) (!= (@ s end) 13)) (+= end 1))
@@ -19,9 +19,9 @@
19
19
  ok))
20
20
 
21
21
  (define (hash! [a (ptr arena)] [given string] [w (ptr waiting)] [into (ptr buffer)] [err (ptr buffer)]) -> bool
22
- (let ([dir string] [why string] [o w] [m manifest] [paths (make-buffer)] [lines (make-buffer)] [digest (array u8 32)]
22
+ (let ([dir string] [why error] [o w] [m manifest] [paths (make-buffer)] [lines (make-buffer)] [digest (array u8 32)]
23
23
  [ok #t] [me (new a waiting)])
24
- (when (< (fs-real-path given (& dir) (& why)) 0) (return (cannot! err why)))
24
+ (unless (fs-real-path given (& dir) (& why)) (return (cannot! err (& why))))
25
25
  (while (and (!= o 0) (!= (-> o dir) dir)) (set! o (-> o next)))
26
26
  (when (!= o 0)
27
27
  (buffer-add-string! err "the package ")
@@ -79,9 +79,9 @@
79
79
  ok))
80
80
 
81
81
  (define (file-line! [dir string] [path string] [lines (ptr buffer)] [err (ptr buffer)]) -> bool
82
- (let ([full (joined-path dir path)] [bytes (slice u8)] [why string] [digest (array u8 32)] [ok #t])
83
- (if (< (fs-read-file full (& bytes) (& why)) 0)
84
- (set! ok (cannot! err why))
82
+ (let ([full (joined-path dir path)] [bytes (slice u8)] [why error] [digest (array u8 32)] [ok #t])
83
+ (if (not (fs-read-file full (& bytes) (& why)))
84
+ (set! ok (cannot! err (& why)))
85
85
  (begin
86
86
  (sha256-of bytes (slice digest))
87
87
  (add-hex! lines (slice digest))
@@ -92,10 +92,10 @@
92
92
  (free (-> full bytes))
93
93
  ok))
94
94
 
95
- (define (cannot! [err (ptr buffer)] [why string]) -> bool
95
+ (define (cannot! [err (ptr buffer)] [why (ptr error)]) -> bool
96
96
  (buffer-add-string! err "cannot read ")
97
- (buffer-add-string! err why)
98
- (free (-> why bytes))
97
+ (buffer-add-string! err (error-text why))
98
+ (error-free! why)
99
99
  #f)
100
100
 
101
101
  (define (add-hex! [b (ptr buffer)] [bytes (slice u8)])
@@ -3,16 +3,17 @@
3
3
  ;; (dependencies (name (path "directory") (hash "sha256:hex")) (name (url "address") (hash "sha256:hex")) ...)
4
4
  ;; (tests "path" ... (browser))
5
5
  ;; (sites (name "program.sub" (html "file.html") (files "/dir" (from "directory") "path" ...)) ...))
6
- ;; The substrate clause gives the oldest substrate the package builds with. Every clause but version is optional, and so
7
- ;; are a path dependency's hash and a site's html and files. A files part gives the program the files matching its
8
- ;; paths, from its from directory, under the directory it names; * matches any text in a name and ** any directories.
9
- ;; (browser) says that the package's tests open browsers with std/test/browser.sub.
6
+ ;; The substrate clause gives the oldest substrate the package builds with. (substrate "0.10.0") also takes later 0.10
7
+ ;; releases, and (substrate "1.2.0") takes later 1.x releases. Every clause but version is optional, and so are a path
8
+ ;; dependency's hash and a site's html and files. A files part gives the program the files matching its paths, from its
9
+ ;; from directory, under the directory it names; * matches any text in a name and ** any directories. (browser) says
10
+ ;; that the package's tests open browsers with std/test/browser.sub.
10
11
  (require-unqualified "read.sub")
11
12
  (require-unqualified host/fs)
12
13
  (require-unqualified "path.sub")
13
14
 
14
15
  (provide manifest dependency declared-site site-files manifest-read manifest-of-program manifest-find package-holding
15
- package-name? full-hash? version-before?)
16
+ package-name? full-hash? version-before? version-compatible?)
16
17
 
17
18
  (struct dependency [name string] [path string] [url string] [hash string] [line u32] [column u32])
18
19
  (struct site-files [dir string] [from string] [patterns (slice string)])
@@ -24,41 +25,53 @@
24
25
  (define default-tests (array string 1))
25
26
 
26
27
  (define (manifest-read [a (ptr arena)] [file string] [m (ptr manifest)] [err (ptr buffer)]) -> bool
27
- (let ([forms (slice data)] [e data-error])
28
- (cond [(not (read-forms a file #f (& forms) (& e) err)) #f]
29
- [(!= (-> e line) 0) (failed! err file (-> e line) (-> e column) (-> e message))]
30
- [(!= (-> forms length) 1) (failed! err file 1 1 "a package.sub holds one form, (package ...)")]
31
- [else (manifest-of file (& (@ forms 0)) a m err)])))
28
+ (let* ([forms (slice data)] [e data-error]
29
+ [ok (cond [(not (read-forms a file #f (& forms) (& e) err)) #f]
30
+ [(!= (-> e line) 0) (failed! err file (-> e line) (-> e column) (error-text (& (-> e error))))]
31
+ [(!= (-> forms length) 1) (failed! err file 1 1 "a package.sub holds one form, (package ...)")]
32
+ [else (manifest-of file (& (@ forms 0)) a m err)])])
33
+ (error-free! (& (-> e error)))
34
+ ok))
32
35
 
33
- (define (manifest-of-program [a (ptr arena)] [file string] [m (ptr manifest)] [err (ptr buffer)]) -> i32
34
- (let ([text (slice u8)] [why string] [forms (slice data)] [e data-error] [found i32 -1])
35
- (when (< (fs-read-file file (& text) (& why)) 0)
36
+ (define (manifest-of-program [a (ptr arena)] [file string] [m (ptr manifest)] [found (ptr bool)] [err (ptr buffer)])
37
+ -> bool
38
+ (let ([text (slice u8)] [why error] [forms (slice data)] [e data-error] [ok #t])
39
+ (set! (@ found) #f)
40
+ (unless (fs-read-file file (& text) (& why))
36
41
  (buffer-add-string! err "cannot read ")
37
- (buffer-add-string! err why)
38
- (free (-> why bytes))
39
- (return -1))
40
- (cond [(!= (data-head a (cast string text)) "package") (set! found 0)]
41
- [(not (data-read a (cast string text) #t (& forms) (& e))) (failed! err file (-> e line) (-> e column) (-> e message))]
42
- [(manifest-of file (& (@ forms 0)) a m err) (set! found 1)])
42
+ (buffer-add-string! err (error-text (& why)))
43
+ (error-free! (& why))
44
+ (return #f))
45
+ (cond [(!= (data-head a (cast string text)) "package") (begin)]
46
+ [(not (data-read a (cast string text) #t (& forms) (& e)))
47
+ (set! ok (failed! err file (-> e line) (-> e column) (error-text (& (-> e error)))))]
48
+ [(manifest-of file (& (@ forms 0)) a m err) (set! (@ found) #t)]
49
+ [else (set! ok #f)])
50
+ (error-free! (& (-> e error)))
43
51
  (free (-> text items))
44
- found))
52
+ ok))
45
53
 
46
- ;; manifest-find finds the manifest of the package that holds the program in file, given from /: the program's own,
47
- ;; giving 1, or the nearest package.sub above it, giving 2, with the package's directory added to dir. It gives 0 when
48
- ;; there is none, and -1 with err saying why when the manifest is wrong.
49
- (define (manifest-find [a (ptr arena)] [file string] [m (ptr manifest)] [dir (ptr buffer)] [err (ptr buffer)]) -> i32
50
- (let ([own (manifest-of-program a file m err)] [d string] [found i32 0])
51
- (when (!= own 0) (return own))
54
+ ;; manifest-find finds the manifest for the program in file, given from /. found is 1 for the program's own manifest,
55
+ ;; 2 for the nearest package.sub above it, whose directory goes into dir, and 0 when there is none.
56
+ (define (manifest-find [a (ptr arena)] [file string] [m (ptr manifest)] [dir (ptr buffer)] [found (ptr i32)]
57
+ [err (ptr buffer)]) -> bool
58
+ (let ([own #f] [d string])
59
+ (set! (@ found) 0)
60
+ (unless (manifest-of-program a file m (& own) err) (return #f))
61
+ (when own
62
+ (set! (@ found) 1)
63
+ (return #t))
52
64
  (set! d (package-holding a (parent-of file)))
53
65
  (when (> (-> d length) 0)
54
- (set! found (if (manifest-read a (joined-path d "package.sub") m err) 2 -1))
55
- (when (== found 2) (buffer-add-string! dir d)))
56
- found))
66
+ (unless (manifest-read a (joined-path d "package.sub") m err) (return #f))
67
+ (set! (@ found) 2)
68
+ (buffer-add-string! dir d))
69
+ #t))
57
70
 
58
71
  (define (package-holding [a (ptr arena)] [dir string]) -> string
59
72
  (let ([d dir] [info fs-info] [found ""])
60
73
  (while (> (-> d length) 0)
61
- (when (and (== (fs-stat (joined-path d "package.sub") (& info) 0) 0) (== (-> info kind) fs-file))
74
+ (when (and (fs-stat (joined-path d "package.sub") (& info) 0) (== (-> info kind) fs-file))
62
75
  (set! found (copy a d))
63
76
  (break))
64
77
  (set! d (if (root-path? d) "" (parent-of d))))
@@ -66,12 +79,12 @@
66
79
 
67
80
  (define (read-forms [a (ptr arena)] [file string] [first bool] [into (ptr (slice data))] [e (ptr data-error)]
68
81
  [err (ptr buffer)]) -> bool
69
- (let ([text (slice u8)] [why string])
82
+ (let ([text (slice u8)] [why error])
70
83
  (set! (-> e line) 0)
71
- (when (< (fs-read-file file (& text) (& why)) 0)
84
+ (unless (fs-read-file file (& text) (& why))
72
85
  (buffer-add-string! err "cannot read ")
73
- (buffer-add-string! err why)
74
- (free (-> why bytes))
86
+ (buffer-add-string! err (error-text (& why)))
87
+ (error-free! (& why))
75
88
  (return #f))
76
89
  (unless (data-read a (cast string text) first into e)
77
90
  (when (== (-> e line) 0) (set! (-> e line) 1)))
@@ -132,17 +145,29 @@
132
145
 
133
146
  ;; version-before? is whether version a comes before version b, both major.minor.patch. No version comes before "".
134
147
  (define (version-before? [a string] [b string]) -> bool
135
- (let ([i u32 0] [j u32 0] [x i64 0] [y i64 0])
148
+ (let ([i u32 0] [j u32 0])
136
149
  (for ([k u32 0]) (< k 3) (+= k 1)
137
- (set! x 0)
138
- (set! y 0)
139
- (while (and (< i (-> a length)) (!= (@ a i) #\.)) (set! x (+ (* x 10) (cast i64 (- (@ a i) #\0)))) (+= i 1))
140
- (while (and (< j (-> b length)) (!= (@ b j) #\.)) (set! y (+ (* y 10) (cast i64 (- (@ b j) #\0)))) (+= j 1))
141
- (+= i 1)
142
- (+= j 1)
143
- (when (!= x y) (return (< x y))))
150
+ (let ([x (version-part a (& i))] [y (version-part b (& j))])
151
+ (when (!= x y) (return (< x y)))))
144
152
  #f))
145
153
 
154
+ (define (version-compatible? [a string] [b string]) -> bool
155
+ (let ([i u32 0] [j u32 0])
156
+ (when (== (-> b length) 0) (return #t))
157
+ (for ([k u32 0]) (< k 2) (+= k 1)
158
+ (let ([x (version-part a (& i))] [y (version-part b (& j))])
159
+ (when (!= x y) (return #f))
160
+ (when (!= y 0) (break))))
161
+ (not (version-before? a b))))
162
+
163
+ (define (version-part [s string] [at (ptr u32)]) -> i64
164
+ (let ([n i64 0])
165
+ (while (and (< (@ at) (-> s length)) (!= (@ s (@ at)) #\.))
166
+ (set! n (+ (* n 10) (cast i64 (- (@ s (@ at)) #\0))))
167
+ (+= (@ at) 1))
168
+ (+= (@ at) 1)
169
+ n))
170
+
146
171
  (define (manifest-of [file string] [f (ptr data)] [a (ptr arena)] [m (ptr manifest)] [err (ptr buffer)]) -> bool
147
172
  (let ([items (items-of f)] [versioned #f] [needed #f] [exported #f] [listed #f] [tested #f] [sited #f] [major i64 0])
148
173
  (set! (-> m substrate) "")
@@ -78,7 +78,7 @@
78
78
  (set! (@ dirs i) (normal-path a full))
79
79
  (free (-> full bytes))))
80
80
  (when (and (> (-> d url length) 0)
81
- (or (!= (fs-stat (@ dirs i) (& info) 0) 0) (!= (-> info kind) fs-directory)))
81
+ (or (not (fs-stat (@ dirs i) (& info) 0)) (!= (-> info kind) fs-directory)))
82
82
  (buffer-add-string! err (-> d name))
83
83
  (buffer-add-string! err ", from ")
84
84
  (buffer-add-string! err (-> d url))
@@ -23,9 +23,9 @@
23
23
  (let ([pack (make-buffer)] [ok #t] [fs (cast (ptr packed-file) (-> files bytes))]
24
24
  [n (/ (-> files length) (sizeof packed-file))])
25
25
  (for ([k u32 0]) (and ok (< k n)) (+= k 1)
26
- (let ([name (-> (@ fs k) name)] [why string] [bytes (slice u8)])
27
- (if (< (fs-read-file (-> (@ fs k) path) (& bytes) (& why)) 0)
28
- (set! ok (failed! err "cannot read " why))
26
+ (let ([name (-> (@ fs k) name)] [why error] [bytes (slice u8)])
27
+ (if (not (fs-read-file (-> (@ fs k) path) (& bytes) (& why)))
28
+ (set! ok (failed! err "cannot read " (& why)))
29
29
  (begin
30
30
  (buffer-add-u32! (& pack) (-> name length))
31
31
  (buffer-add-string! (& pack) name)
@@ -33,8 +33,8 @@
33
33
  (buffer-add! (& pack) bytes)
34
34
  (free (-> bytes items))))))
35
35
  (when ok
36
- (let ([why string])
37
- (when (< (fs-write-file out (buffer-bytes (& pack)) (& why)) 0) (set! ok (failed! err "cannot write " why)))))
36
+ (let ([why error])
37
+ (unless (fs-write-file out (buffer-bytes (& pack)) (& why)) (set! ok (failed! err "cannot write " (& why))))))
38
38
  (for ([k u32 0]) (< k n) (+= k 1)
39
39
  (free (-> (-> (@ fs k) name) bytes))
40
40
  (free (-> (-> (@ fs k) path) bytes)))
@@ -50,22 +50,22 @@
50
50
  (buffer-add-string! (& b) name)
51
51
  (buffer-string (& b))))
52
52
 
53
- (define (failed! [err (ptr buffer)] [what string] [why string]) -> bool
53
+ (define (failed! [err (ptr buffer)] [what string] [why (ptr error)]) -> bool
54
54
  (buffer-add-string! err what)
55
- (buffer-add-string! err why)
56
- (free (-> why bytes))
55
+ (buffer-add-string! err (error-text why))
56
+ (error-free! why)
57
57
  #f)
58
58
 
59
59
  (define (add! [dir string] [name string] [at string] [files (ptr buffer)] [err (ptr buffer)]) -> bool
60
- (let* ([full (joined dir name)] [why string] [info fs-info] [ok #t])
61
- (cond [(< (fs-stat full (& info) (& why)) 0)
62
- (set! ok (failed! err "cannot read " why))
60
+ (let* ([full (joined dir name)] [why error] [info fs-info] [ok #t])
61
+ (cond [(not (fs-stat full (& info) (& why)))
62
+ (set! ok (failed! err "cannot read " (& why)))
63
63
  (free (-> name bytes))
64
64
  (free (-> full bytes))]
65
65
  [(== (-> info kind) fs-directory)
66
66
  (let ([listed (slice string)])
67
- (if (< (fs-list full (& listed) (& why)) 0)
68
- (set! ok (failed! err "cannot read " why))
67
+ (if (not (fs-list full (& listed) (& why)))
68
+ (set! ok (failed! err "cannot read " (& why)))
69
69
  (begin
70
70
  (for ([j u32 0]) (and ok (< j (-> listed length))) (+= j 1)
71
71
  (set! ok (add! dir (joined name (@ listed j)) at files err)))
@@ -7,7 +7,7 @@
7
7
  [data-symbol [text string] [line u32] [column u32]]
8
8
  [data-string [text string] [line u32] [column u32]])
9
9
 
10
- (struct data-error [message string] [line u32] [column u32])
10
+ (struct data-error [error error] [line u32] [column u32])
11
11
 
12
12
  (struct data-reader [text string] [at u32] [line u32] [column u32] [arena (ptr arena)] [error (ptr data-error)])
13
13
 
@@ -34,13 +34,13 @@
34
34
  #t))
35
35
 
36
36
  (define (data-head [a (ptr arena)] [text string]) -> string
37
- (let ([r data-reader] [e data-error] [start u32 0])
37
+ (let ([r data-reader] [start u32 0])
38
38
  (set! (-> r text) text)
39
39
  (set! (-> r at) 0)
40
40
  (set! (-> r line) 1)
41
41
  (set! (-> r column) 1)
42
42
  (set! (-> r arena) a)
43
- (set! (-> r error) (& e))
43
+ (set! (-> r error) 0)
44
44
  (unless (and (skip-space! (& r)) (more? (& r)) (or (== (here (& r)) #\() (== (here (& r)) #\[))) (return ""))
45
45
  (advance! (& r))
46
46
  (unless (skip-space! (& r)) (return ""))
@@ -93,9 +93,10 @@
93
93
  (or (== c 32) (and (>= c 9) (<= c 13)) (== c #\() (== c #\)) (== c #\[) (== c #\]) (== c #\") (== c 59)))
94
94
 
95
95
  (define (failed! [r (ptr data-reader)] [message string] [line u32] [column u32]) -> bool
96
- (set! (-> r error message) message)
97
- (set! (-> r error line) line)
98
- (set! (-> r error column) column)
96
+ (unless (== (-> r error) 0)
97
+ (error-fail! (& (-> r error error)) error-invalid message)
98
+ (set! (-> r error line) line)
99
+ (set! (-> r error column) column))
99
100
  #f)
100
101
 
101
102
  (define (read-one! [r (ptr data-reader)] [into (ptr data)]) -> bool
@@ -23,18 +23,18 @@
23
23
  (let ([info fs-info]) (fs-stat path (& info) 0) (-> info kind)))
24
24
 
25
25
  (define (made! [path string])
26
- (let ([why string]) (when (< (fs-make-dir path (& why)) 0) (throw site-failed why))))
26
+ (let ([why error]) (unless (fs-make-dir path (& why)) (throw site-failed (error-text (& why))))))
27
27
 
28
28
  (define (copied! [from string] [to string])
29
- (let ([why string]) (when (< (fs-copy from to (& why)) 0) (throw site-failed why))))
29
+ (let ([why error]) (unless (fs-copy from to (& why)) (throw site-failed (error-text (& why))))))
30
30
 
31
31
  (define (names-in [dir string]) -> (slice string)
32
- (let ([names (slice string)] [why string])
33
- (when (< (fs-list dir (& names) (& why)) 0) (throw site-failed why))
32
+ (let ([names (slice string)] [why error])
33
+ (unless (fs-list dir (& names) (& why)) (throw site-failed (error-text (& why))))
34
34
  names))
35
35
 
36
36
  (define (written! [path string] [b (slice u8)])
37
- (let ([why string]) (when (< (fs-write-file path b (& why)) 0) (throw site-failed why))))
37
+ (let ([why error]) (unless (fs-write-file path b (& why)) (throw site-failed (error-text (& why))))))
38
38
 
39
39
  (define (copy-tree! [from string] [to string] [base string] [files (ptr buffer)])
40
40
  (let ([names (names-in from)])
@@ -131,12 +131,12 @@
131
131
  #f]))
132
132
 
133
133
  (define (site-written! [p (ptr site-plan)] [out string] [toolchain string])
134
- (let ([list (make-buffer)] [files (make-buffer)] [packed (make-buffer)] [err (make-buffer)] [why string])
134
+ (let ([list (make-buffer)] [files (make-buffer)] [packed (make-buffer)] [err (make-buffer)] [why error])
135
135
  (when (and (!= (kind-of out) fs-none)
136
136
  (or (!= (kind-of out) fs-directory)
137
137
  (and (> (-> (names-in out) length) 0) (!= (kind-of (joined-path out ".site")) fs-file))))
138
138
  (throw site-failed (joined (joined "site: " out) " is not a site, so it is not replaced")))
139
- (when (and (!= (kind-of out) fs-none) (< (fs-remove out #t (& why)) 0)) (throw site-failed why))
139
+ (when (and (!= (kind-of out) fs-none) (not (fs-remove out #t (& why)))) (throw site-failed (error-text (& why))))
140
140
  (made! (joined-path out "host/modules"))
141
141
  (made! (joined-path out "host/web"))
142
142
  (written! (joined-path out ".site") (cast (slice u8) (joined (-> p program) "\n")))
@@ -24,7 +24,7 @@
24
24
  (let* ([d (& (@ deps i))] [url (> (-> d url length) 0)] [dm manifest] [err (make-buffer)] [info fs-info]
25
25
  [next (if url (store-entry a store (-> d hash)) (dependency-dir a dir (-> d path)))]
26
26
  [file (joined-path next "package.sub")])
27
- (if (and url (or (!= (fs-stat next (& info) 0) 0) (!= (-> info kind) fs-directory)))
27
+ (if (and url (or (not (fs-stat next (& info) 0)) (!= (-> info kind) fs-directory)))
28
28
  (let ([w wanted])
29
29
  (set! (-> w name) (-> d name))
30
30
  (set! (-> w url) (-> d url))
@@ -45,8 +45,8 @@
45
45
  (define (store-install! [a (ptr arena)] [store string] [staging string] [pin string] [m (ptr manifest)]
46
46
  [into (ptr buffer)] [err (ptr buffer)]) -> bool
47
47
  (let ([file (joined-path staging "package.sub")] [info fs-info] [h (make-buffer)] [hash string] [entry string]
48
- [kept string] [why string])
49
- (unless (and (== (fs-stat file (& info) 0) 0) (== (-> info kind) fs-file))
48
+ [kept string] [why error])
49
+ (unless (and (fs-stat file (& info) 0) (== (-> info kind) fs-file))
50
50
  (return (not-installed! staging err "it has no package.sub at its top")))
51
51
  (unless (manifest-read a file m err) (return (not-installed! staging err "")))
52
52
  (let ([deps (-> m dependencies)])
@@ -64,18 +64,21 @@
64
64
  (buffer-add-string! err ", not the one its dependency pins, ")
65
65
  (return (not-installed! staging err pin)))
66
66
  (set! entry (store-entry a store hash))
67
- (when (< (fs-make-temp-dir store ".staging-" "" (& kept) (& why)) 0)
68
- (buffer-add-string! err why)
67
+ (unless (fs-make-temp-dir store ".staging-" "" (& kept) (& why))
68
+ (buffer-add-string! err (error-text (& why)))
69
+ (error-free! (& why))
69
70
  (return (not-installed! staging err "")))
70
71
  (unless (copied! a staging staging kept err)
71
72
  (fs-remove kept #t 0)
72
73
  (return (not-installed! staging err "")))
73
74
  (fs-remove staging #t 0)
74
- (when (< (fs-rename kept entry (& why)) 0)
75
+ (unless (fs-rename kept entry (& why))
75
76
  (fs-remove kept #t 0)
76
- (unless (and (== (fs-stat entry (& info) 0) 0) (== (-> info kind) fs-directory))
77
- (buffer-add-string! err why)
78
- (return #f)))
77
+ (unless (and (fs-stat entry (& info) 0) (== (-> info kind) fs-directory))
78
+ (buffer-add-string! err (error-text (& why)))
79
+ (error-free! (& why))
80
+ (return #f))
81
+ (error-free! (& why)))
79
82
  (buffer-add-string! into hash)
80
83
  #t))
81
84
 
@@ -95,9 +98,10 @@
95
98
  ok))
96
99
 
97
100
  (define (copied-file! [top string] [dir string] [p string] [to string] [err (ptr buffer)]) -> bool
98
- (let* ([from (joined-path dir p)] [dest (joined-path to (slice from (+ (-> top length) 1)))] [why string] [ok #t])
99
- (when (or (< (fs-make-dir (parent-of dest) (& why)) 0) (< (fs-copy from dest (& why)) 0))
100
- (buffer-add-string! err why)
101
+ (let* ([from (joined-path dir p)] [dest (joined-path to (slice from (+ (-> top length) 1)))] [why error] [ok #t])
102
+ (unless (and (fs-make-dir (parent-of dest) (& why)) (fs-copy from dest (& why)))
103
+ (buffer-add-string! err (error-text (& why)))
104
+ (error-free! (& why))
101
105
  (set! ok #f))
102
106
  (free (-> from bytes))
103
107
  (free (-> dest bytes))
package/std/package.sub CHANGED
@@ -1,13 +1,13 @@
1
1
  (package std
2
- (version "0.9.0")
3
- (substrate "0.9.0")
2
+ (version "0.10.0")
3
+ (substrate "0.10.0")
4
4
  (exports archive/tar browser/chromium browser/devtools compress/deflate compress/gzip compress/inflate crypto/hmac
5
5
  crypto/password crypto/sha1
6
6
  crypto/sha256 crypto/sha512 doc/doc doc/html doc/root doc/text encoding/base64 encoding/json encoding/utf8
7
7
  encoding/wire html/html http/checks http/conditional http/cookie http/form http/http http/multipart
8
8
  http/route http/server http/session http/sse http/sse-client http/static http/test http/token http/url
9
- http/websocket log/log meta/derive meta/equal meta/type-info package/files package/hash package/manifest
10
- package/map package/pack package/path package/read package/site package/store test/browser test/build
11
- test/run test/session test/test web/canvas web/dom web/gpu web/patches)
9
+ http/websocket log/log meta/derive meta/equal meta/method meta/type-info package/files package/hash
10
+ package/manifest package/map package/pack package/path package/read package/site package/store test/browser
11
+ test/build test/run test/session test/test vector/vector web/canvas web/dom web/gpu web/patches)
12
12
  (tests "tests/archive/*.sub" "tests/compress/*.sub" "tests/crypto/*.sub" "tests/encoding/*.sub" "tests/http/*.sub"
13
- "tests/log/*.sub" "tests/meta/*.sub" "tests/test/*.sub"))
13
+ "tests/log/*.sub" "tests/meta/*.sub" "tests/test/*.sub" "tests/vector/*.sub"))
@@ -111,8 +111,9 @@
111
111
  (unless (env-get "SUBSTRATE_DEVTOOLS" (& address) 0)
112
112
  (throw test-failed (lines-joined message "a test that opens a browser needs (browser) in the tests clause of its package's package.sub")))
113
113
  (when (== (-> address length) 0) (throw test-skipped "need Chromium"))
114
- (let* ([dir (site-built spec html message)] [why string] [p (page-open dir (with-args url args) address server (& why))])
115
- (when (== (cast u32 p) 0) (throw test-failed (lines-joined message why)))
114
+ (let ([dir (site-built spec html message)] [why error] [p (ptr page) 0])
115
+ (unless (page-open dir (with-args url args) address server (& p) (& why))
116
+ (throw test-failed (lines-joined message (error-text (& why)))))
116
117
  (browser #:page p))))
117
118
 
118
119
  ;; Adds args to url as arg parameters, which a site passes to its program as its arguments.
@@ -143,7 +144,7 @@
143
144
  (when (> (-> html length) 0) (set! (-> p html) html))
144
145
  (unless (site-write! (& p) dir (toolchain) (& err))
145
146
  (throw test-failed (lines-joined message (buffer-string (& err)))))
146
- (unless (and (== (fs-stat (-> p program) (& info) 0) 0) (== (-> info kind) fs-directory))
147
+ (unless (and (fs-stat (-> p program) (& info) 0) (== (-> info kind) fs-directory))
147
148
  (unless (program-write! (-> p program) (joined-path dir "program") (& err))
148
149
  (throw test-failed (lines-joined message (buffer-string (& err)))))))
149
150
  (set! b (built #:spec spec #:html html #:dir dir))
@@ -152,8 +153,8 @@
152
153
 
153
154
  ;; spec is the name of a site the package declares, or else the path of a program.
154
155
  (define (planned [spec string] [name string] [message string]) -> site-plan
155
- (let ([p site-plan] [a (make-arena)] [here string] [why string] [err (make-buffer)])
156
- (when (< (fs-cwd (& here) (& why)) 0) (throw test-failed (lines-joined message why)))
156
+ (let ([p site-plan] [a (make-arena)] [here string] [why error] [err (make-buffer)])
157
+ (unless (fs-cwd (& here) (& why)) (throw test-failed (lines-joined message (error-text (& why)))))
157
158
  (if (site-named? spec)
158
159
  (unless (site-declared (& a) here spec (& p) (& err)) (throw test-failed (lines-joined message (buffer-string (& err)))))
159
160
  (set! p (site-plan #:name name #:program (resolved-path here spec) #:html ""
@@ -173,12 +174,12 @@
173
174
 
174
175
  ;; Saves a PNG of the browser's window as build/test/screenshots/name.png in the package, and gives that path.
175
176
  (define (browser-screenshot [b browser] [name string]) -> string
176
- (let* ([dir "build/test/screenshots"] [file (make-buffer)] [why string] [png (page-screenshot (-> b page))])
177
+ (let* ([dir "build/test/screenshots"] [file (make-buffer)] [why error] [png (page-screenshot (-> b page))])
177
178
  (buffer-add-string! (& file) name)
178
179
  (buffer-add-string! (& file) ".png")
179
180
  (let ([path (joined-path dir (buffer-string (& file)))])
180
- (when (or (< (fs-make-dir dir (& why)) 0) (< (fs-write-file path png (& why)) 0))
181
- (throw test-failed (page-stepped why)))
181
+ (unless (and (fs-make-dir dir (& why)) (fs-write-file path png (& why)))
182
+ (throw test-failed (page-stepped (error-text (& why)))))
182
183
  path)))
183
184
 
184
185
  (define (lines-joined [a string] [b string]) -> string
@@ -17,8 +17,8 @@
17
17
  (define (ready!)
18
18
  (unless ready
19
19
  (set! ready #t)
20
- (let ([why string] [toolchain string] [map-file string] [cache string])
21
- (when (< (fs-cwd (& directory) (& why)) 0) (throw test-failed why))
20
+ (let ([why error] [toolchain string] [map-file string] [cache string])
21
+ (unless (fs-cwd (& directory) (& why)) (throw test-failed (error-text (& why))))
22
22
  (env-get "SUBSTRATE_TOOLCHAIN" (& toolchain) 0)
23
23
  (env-get "SUBSTRATE_MODULE_MAP" (& map-file) 0)
24
24
  (env-get "SUBSTRATE_CACHE" (& cache) 0)