2 USING: tools.test io.files io.files.private io threads kernel
3 continuations io.encodings.ascii sequences
4 strings accessors io.encodings.utf8 math destructors
10 \ link-info must-infer
12 [ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test
13 [ ] [ "blahblah" temp-file make-directory ] unit-test
14 [ t ] [ "blahblah" temp-file file-info directory? ] unit-test
17 [ temp-directory "loldir" append-path delete-directory ] ignore-errors
19 "loldir" make-directory
21 temp-directory "loldir" append-path exists?
25 [ temp-directory "loldir" append-path delete-directory ] ignore-errors
27 "loldir" make-directory
28 "loldir" delete-directory
32 [ "file1 contents" ] [
33 [ temp-directory "loldir" append-path delete-directory ] ignore-errors
35 "file1 contents" "file1" utf8 set-file-contents
36 "file1" "file2" copy-file
37 "file2" utf8 file-contents
39 "file1" temp-file delete-file
40 "file2" temp-file delete-file
43 [ "file3 contents" ] [
45 "file3 contents" "file3" utf8 set-file-contents
46 "file3" "file4" move-file
47 "file4" utf8 file-contents
49 "file4" temp-file delete-file
52 [ "file5" temp-file delete-file ] ignore-errors
61 [ "file6" temp-file delete-file ] ignore-errors
66 "file6" link-info drop
70 [ "passwd" ] [ "/etc/passwd" file-name ] unit-test
71 [ "awk" ] [ "/usr/libexec/awk/" file-name ] unit-test
72 [ "awk" ] [ "/usr/libexec/awk///" file-name ] unit-test
73 [ "" ] [ "" file-name ] unit-test
75 [ "freetype6.dll" ] [ "resource:freetype6.dll" file-name ] unit-test
76 [ "freetype6.dll" ] [ "resource:/freetype6.dll" file-name ] unit-test
80 "test-foo.txt" temp-file ascii set-file-lines
84 "test-foo.txt" temp-file ascii [
85 "Hello appender." print
90 "test-bar.txt" temp-file ascii [
91 "Hello appender." print
95 [ "Hello world.\nHello appender.\n" ] [
96 "test-foo.txt" temp-file ascii file-contents
99 [ "Hello appender.\n" ] [
100 "test-bar.txt" temp-file ascii file-contents
103 [ ] [ "test-foo.txt" temp-file delete-file ] unit-test
105 [ ] [ "test-bar.txt" temp-file delete-file ] unit-test
107 [ f ] [ "test-foo.txt" temp-file exists? ] unit-test
109 [ f ] [ "test-bar.txt" temp-file exists? ] unit-test
111 [ "test-blah" temp-file delete-tree ] ignore-errors
113 [ ] [ "test-blah" temp-file make-directory ] unit-test
116 "test-blah/fooz" temp-file ascii <file-writer> dispose
120 "test-blah/fooz" temp-file exists?
123 [ ] [ "test-blah/fooz" temp-file delete-file ] unit-test
125 [ ] [ "test-blah" temp-file delete-directory ] unit-test
127 [ f ] [ "test-blah" temp-file exists? ] unit-test
129 USE: debugger.threads
131 [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test
133 [ ] [ "test-quux.txt" temp-file delete-file ] unit-test
135 [ ] [ "test-quux.txt" temp-file ascii [ [ yield "Hi" write ] "Test" spawn drop ] with-file-writer ] unit-test
137 [ ] [ "test-quux.txt" "quux-test.txt" [ temp-file ] bi@ move-file ] unit-test
139 [ t ] [ "quux-test.txt" temp-file exists? ] unit-test
141 [ ] [ "quux-test.txt" temp-file delete-file ] unit-test
143 [ ] [ "delete-tree-test/a/b/c" temp-file make-directories ] unit-test
147 "delete-tree-test/a/b/c/d" temp-file ascii set-file-lines
151 "delete-tree-test" temp-file delete-tree
154 [ { { "kernel" t } } ] [
155 "core" resource-path [
156 "." directory [ first "kernel" = ] filter
160 [ { { "kernel" t } } ] [
162 "." directory [ first "kernel" = ] filter
167 "copy-tree-test/a/b/c" temp-file make-directories
172 "copy-tree-test/a/b/c/d" temp-file
173 ascii set-file-contents
177 "copy-tree-test" temp-file
178 "copy-destination" temp-file copy-tree
182 "copy-destination/a/b/c/d" temp-file ascii file-contents
186 "copy-destination" temp-file delete-tree
190 "copy-tree-test" temp-file
191 "copy-destination" temp-file copy-tree-into
195 "copy-destination/copy-tree-test/a/b/c/d" temp-file ascii file-contents
199 "copy-destination/copy-tree-test/a/b/c/d" temp-file "" temp-file copy-file-into
203 "d" temp-file ascii file-contents
206 [ ] [ "d" temp-file delete-file ] unit-test
208 [ ] [ "copy-destination" temp-file delete-tree ] unit-test
210 [ ] [ "copy-tree-test" temp-file delete-tree ] unit-test
212 [ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test
215 temp-directory [ "hi41" "test41" utf8 set-file-contents ] with-directory
216 temp-directory "test41" append-path utf8 file-contents "hi41" =
220 temp-directory [ "test41" file-info size>> ] with-directory 4 =
223 [ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test
225 [ ] [ "append-test" temp-file ascii <file-appender> dispose ] unit-test
227 [ "/usr/lib" ] [ "/usr" "lib" append-path ] unit-test
228 [ "/usr/lib" ] [ "/usr/" "lib" append-path ] unit-test
229 [ "/usr/lib" ] [ "/usr" "./lib" append-path ] unit-test
230 [ "/usr/lib/" ] [ "/usr" "./lib/" append-path ] unit-test
231 [ "/lib" ] [ "/usr" "../lib" append-path ] unit-test
232 [ "/lib/" ] [ "/usr" "../lib/" append-path ] unit-test
234 [ "" ] [ "" "." append-path ] unit-test
235 [ "" ".." append-path ] must-fail
237 [ "/" ] [ "/" "./." append-path ] unit-test
238 [ "/" ] [ "/" "././" append-path ] unit-test
239 [ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test
240 [ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test
242 [ "" "../lib/" append-path ] must-fail
243 [ "lib" ] [ "" "lib" append-path ] unit-test
244 [ "lib" ] [ "" "./lib" append-path ] unit-test
246 [ "foo/bar/." parent-directory ] must-fail
247 [ "foo/bar/./" parent-directory ] must-fail
248 [ "foo/bar/baz/.." parent-directory ] must-fail
249 [ "foo/bar/baz/../" parent-directory ] must-fail
251 [ "." parent-directory ] must-fail
252 [ "./" parent-directory ] must-fail
253 [ ".." parent-directory ] must-fail
254 [ "../" parent-directory ] must-fail
255 [ "../../" parent-directory ] must-fail
256 [ "foo/.." parent-directory ] must-fail
257 [ "foo/../" parent-directory ] must-fail
258 [ "" parent-directory ] must-fail
259 [ "." ] [ "boot.x86.64.image" parent-directory ] unit-test
261 [ "bar/foo" ] [ "bar/baz" "..///foo" append-path ] unit-test
262 [ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test
263 [ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test
264 [ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test
266 [ t ] [ "resource:core" absolute-path? ] unit-test
267 [ f ] [ "" absolute-path? ] unit-test
269 [ "touch-twice-test" temp-file delete-file ] ignore-errors
270 [ ] [ 2 [ "touch-twice-test" temp-file touch-file ] times ] unit-test
274 "." current-directory set
275 ".." "resource-path" set
276 [ "../core/bootstrap/stage2.factor" ]
277 [ "resource:core/bootstrap/stage2.factor" (normalize-path) ]