@@ -25,7 +25,8 @@ subroutine collect_filesystem(testsuite)
25
25
new_unittest(" fs_run_valid_command" , fs_run_valid_command), &
26
26
new_unittest(" fs_list_dir_empty" , fs_list_dir_empty), &
27
27
new_unittest(" fs_list_dir_one_file" , fs_list_dir_one_file), &
28
- new_unittest(" fs_list_dir_two_files" , fs_list_dir_two_files) &
28
+ new_unittest(" fs_list_dir_two_files" , fs_list_dir_two_files), &
29
+ new_unittest(" fs_list_dir_one_file_one_dir" , fs_list_dir_one_file_one_dir) &
29
30
]
30
31
end
31
32
@@ -181,6 +182,44 @@ subroutine fs_list_dir_two_files(error)
181
182
call run(' rm -rf ' // temp_list_dir, iostat= stat)
182
183
end
183
184
185
+ subroutine fs_list_dir_one_file_one_dir (error )
186
+ type (error_type), allocatable , intent (out ) :: error
187
+
188
+ integer :: stat
189
+
190
+ type (string_type), allocatable :: contents(:)
191
+ character (* ), parameter :: filename1 = ' abc.txt'
192
+ character (* ), parameter :: dir = ' xyz'
193
+
194
+ call run(' rm -rf ' // temp_list_dir, iostat= stat)
195
+ if (stat /= 0 ) then
196
+ call test_failed(error, " Removing directory '" // temp_list_dir// " ' failed." ); return
197
+ end if
198
+
199
+ call run(' mkdir ' // temp_list_dir, iostat= stat)
200
+ if (stat /= 0 ) then
201
+ call test_failed(error, " Creating directory '" // temp_list_dir// " ' failed." ); return
202
+ end if
203
+
204
+ call run(' touch ' // temp_list_dir// ' /' // filename1, iostat= stat)
205
+ if (stat /= 0 ) then
206
+ call test_failed(error, " Creating file 1 in directory '" // temp_list_dir// " ' failed." ); return
207
+ end if
208
+
209
+ call run(' mkdir ' // temp_list_dir// ' /' // dir, iostat= stat)
210
+ if (stat /= 0 ) then
211
+ call test_failed(error, " Creating dir in directory '" // temp_list_dir// " ' failed." ); return
212
+ end if
213
+
214
+ call list_dir(temp_list_dir, contents, stat)
215
+ call check(error, stat, " Listing the contents of an empty directory shouldn't fail." )
216
+ call check(error, size (contents) == 2 , " The directory should contain two files." )
217
+ call check(error, char (contents(1 )) == filename1, " The file should be '" // filename1// " '." )
218
+ call check(error, char (contents(2 )) == dir, " The file should be '" // dir// " '." )
219
+
220
+ call run(' rm -rf ' // temp_list_dir, iostat= stat)
221
+ end
222
+
184
223
subroutine delete_file (filename )
185
224
character (len=* ), intent (in ) :: filename
186
225
0 commit comments