]> gitweb.factorcode.org Git - factor.git/blob - basis/io/directories/directories-tests.factor
factor: clean up spaces in -tests files
[factor.git] / basis / io / directories / directories-tests.factor
1 USING: continuations destructors io io.directories
2 io.directories.hierarchy io.encodings.ascii io.encodings.utf8
3 io.files io.files.info io.files.temp io.launcher io.pathnames
4 kernel sequences tools.test ;
5 IN: io.directories.tests
6
7 [ { "kernel" } ] [
8     "core" resource-path [
9         "." directory-files [ "kernel" = ] filter
10     ] with-directory
11 ] unit-test
12
13 [ { "kernel" } ] [
14     "resource:core" [
15         "." directory-files [ "kernel" = ] filter
16     ] with-directory
17 ] unit-test
18
19 [ { "kernel" } ] [
20     "resource:core" [
21         [ "kernel" = ] filter
22     ] with-directory-files
23 ] unit-test
24
25 [ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test
26 [ ] [ "blahblah" temp-file make-directory ] unit-test
27 [ t ] [ "blahblah" temp-file file-info directory? ] unit-test
28
29 [ t ] [
30     [ temp-directory "loldir" append-path delete-directory ] ignore-errors
31     temp-directory [
32         "loldir" make-directory
33     ] with-directory
34     temp-directory "loldir" append-path exists?
35 ] unit-test
36
37 [ ] [
38     [ temp-directory "loldir" append-path delete-directory ] ignore-errors
39     temp-directory [
40         "loldir" make-directory
41         "loldir" delete-directory
42     ] with-directory
43 ] unit-test
44
45 [ "file1 contents" ] [
46     [ temp-directory "loldir" append-path delete-directory ] ignore-errors
47     temp-directory [
48         "file1 contents" "file1" utf8 set-file-contents
49         "file1" "file2" copy-file
50         "file2" utf8 file-contents
51     ] with-directory
52     "file1" temp-file delete-file
53     "file2" temp-file delete-file
54 ] unit-test
55
56 [ "file3 contents" ] [
57     temp-directory [
58         "file3 contents" "file3" utf8 set-file-contents
59         "file3" "file4" move-file
60         "file4" utf8 file-contents
61     ] with-directory
62     "file4" temp-file delete-file
63 ] unit-test
64
65 [ "file5" temp-file delete-file ] ignore-errors
66
67 [ ] [
68     temp-directory [
69         "file5" touch-file
70         "file5" delete-file
71     ] with-directory
72 ] unit-test
73
74 [ "file6" temp-file delete-file ] ignore-errors
75
76 [ ] [
77     temp-directory [
78         "file6" touch-file
79         "file6" link-info drop
80     ] with-directory
81 ] unit-test
82
83 [ ] [
84     { "Hello world." }
85     "test-foo.txt" temp-file ascii set-file-lines
86 ] unit-test
87
88 [ ] [
89     "test-foo.txt" temp-file ascii [
90         "Hello appender." print
91     ] with-file-appender
92 ] unit-test
93
94 [ ] [
95     "test-bar.txt" temp-file ascii [
96         "Hello appender." print
97     ] with-file-appender
98 ] unit-test
99
100 [ "Hello world.\nHello appender.\n" ] [
101     "test-foo.txt" temp-file ascii file-contents
102 ] unit-test
103
104 [ "Hello appender.\n" ] [
105     "test-bar.txt" temp-file ascii file-contents
106 ] unit-test
107
108 [ ] [ "test-foo.txt" temp-file delete-file ] unit-test
109
110 [ ] [ "test-bar.txt" temp-file delete-file ] unit-test
111
112 [ f ] [ "test-foo.txt" temp-file exists? ] unit-test
113
114 [ f ] [ "test-bar.txt" temp-file exists? ] unit-test
115
116 [ "test-blah" temp-file delete-tree ] ignore-errors
117
118 [ ] [ "test-blah" temp-file make-directory ] unit-test
119
120 [ ] [
121     "test-blah/fooz" temp-file ascii <file-writer> dispose
122 ] unit-test
123
124 [ t ] [
125     "test-blah/fooz" temp-file exists?
126 ] unit-test
127
128 [ ] [ "test-blah/fooz" temp-file delete-file ] unit-test
129
130 [ ] [ "test-blah" temp-file delete-directory ] unit-test
131
132 [ f ] [ "test-blah" temp-file exists? ] unit-test
133
134 [ ] [ "delete-tree-test/a/b/c" temp-file make-directories ] unit-test
135
136 [ ] [
137     { "Hi" }
138     "delete-tree-test/a/b/c/d" temp-file ascii set-file-lines
139 ] unit-test
140
141 [ ] [
142     "delete-tree-test" temp-file delete-tree
143 ] unit-test
144
145 [ ] [
146     "copy-tree-test/a/b/c" temp-file make-directories
147 ] unit-test
148
149 [ ] [
150     "Foobar"
151     "copy-tree-test/a/b/c/d" temp-file
152     ascii set-file-contents
153 ] unit-test
154
155 [ ] [
156     "copy-tree-test" temp-file
157     "copy-destination" temp-file copy-tree
158 ] unit-test
159
160 [ "Foobar" ] [
161     "copy-destination/a/b/c/d" temp-file ascii file-contents
162 ] unit-test
163
164 [ ] [
165     "copy-destination" temp-file delete-tree
166 ] unit-test
167
168 [ ] [
169     "copy-tree-test" temp-file
170     "copy-destination" temp-file copy-tree-into
171 ] unit-test
172
173 [ "Foobar" ] [
174     "copy-destination/copy-tree-test/a/b/c/d" temp-file ascii file-contents
175 ] unit-test
176
177 [ ] [
178     "copy-destination/copy-tree-test/a/b/c/d" temp-file "" temp-file copy-file-into
179 ] unit-test
180
181 [ "Foobar" ] [
182     "d" temp-file ascii file-contents
183 ] unit-test
184
185 [ ] [ "d" temp-file delete-file ] unit-test
186
187 [ ] [ "copy-destination" temp-file delete-tree ] unit-test
188
189 [ ] [ "copy-tree-test" temp-file delete-tree ] unit-test
190
191 [ ] [ "resource:deleteme" touch-file ] unit-test
192 [ ] [ "resource:deleteme" delete-file ] unit-test
193
194 ! Issue #890
195
196 { } [
197     "foo" temp-file [ make-directories ] keep
198     [ "touch bar" try-output-process ] with-directory
199 ] unit-test