@@ -2,8 +2,8 @@ module test_filesystem
2
2
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
3
3
use stdlib_system, only: is_directory, delete_file, FS_ERROR, FS_ERROR_CODE, &
4
4
make_directory, remove_directory, make_directory_all, is_windows, OS_TYPE, &
5
- OS_WINDOWS, get_cwd, set_cwd, operator (/ ), exists, fs_type_unknown, &
6
- fs_type_regular_file, fs_type_directory, fs_type_symlink, is_regular_file
5
+ OS_WINDOWS, get_cwd, set_cwd, operator (/ ), exists, fs_type_unknown, &
6
+ fs_type_regular_file, fs_type_directory, fs_type_symlink, is_file
7
7
use stdlib_error, only: state_type, STDLIB_FS_ERROR
8
8
use stdlib_strings, only: to_string
9
9
@@ -22,18 +22,18 @@ subroutine collect_suite(testsuite)
22
22
new_unittest(" fs_exists_reg_file" , test_exists_reg_file), &
23
23
new_unittest(" fs_exists_dir" , test_exists_dir), &
24
24
new_unittest(" fs_exists_symlink" , test_exists_symlink), &
25
- new_unittest(" fs_is_regular_file " , test_is_regular_file ), &
25
+ new_unittest(" fs_is_file " , test_is_file ), &
26
26
new_unittest(" fs_is_directory_dir" , test_is_directory_dir), &
27
27
new_unittest(" fs_is_directory_file" , test_is_directory_file), &
28
28
new_unittest(" fs_delete_non_existent" , test_delete_file_non_existent), &
29
29
new_unittest(" fs_delete_existing_file" , test_delete_file_existing), &
30
- new_unittest(" fs_delete_file_being_dir" , test_delete_directory), &
31
- new_unittest(" fs_make_dir" , test_make_directory), &
32
- new_unittest(" fs_make_dir_existing_dir" , test_make_directory_existing), &
33
- new_unittest(" fs_make_dir_all" , test_make_directory_all), &
34
- new_unittest(" fs_remove_dir" , test_remove_directory), &
35
- new_unittest(" fs_remove_dir_non_existent" , test_remove_directory_nonexistent), &
36
- new_unittest(" fs_cwd" , test_cwd) &
30
+ new_unittest(" fs_delete_file_being_dir" , test_delete_directory), &
31
+ new_unittest(" fs_make_dir" , test_make_directory), &
32
+ new_unittest(" fs_make_dir_existing_dir" , test_make_directory_existing), &
33
+ new_unittest(" fs_make_dir_all" , test_make_directory_all), &
34
+ new_unittest(" fs_remove_dir" , test_remove_directory), &
35
+ new_unittest(" fs_remove_dir_non_existent" , test_remove_directory_nonexistent), &
36
+ new_unittest(" fs_cwd" , test_cwd) &
37
37
]
38
38
end subroutine collect_suite
39
39
@@ -108,23 +108,23 @@ subroutine test_exists_reg_file(error)
108
108
if (allocated (error)) return
109
109
end subroutine test_exists_reg_file
110
110
111
- subroutine test_is_regular_file (error )
111
+ subroutine test_is_file (error )
112
112
type (error_type), allocatable , intent (out ) :: error
113
113
character (len= 256 ) :: filename
114
114
integer :: ios, iunit
115
115
character (len= 512 ) :: msg
116
116
117
- logical :: is_file
117
+ logical :: is_reg_file
118
118
119
119
filename = " test_file.txt"
120
120
121
121
! Create a file
122
122
open (newunit= iunit, file= filename, status= " replace" , iostat= ios, iomsg= msg)
123
- call check(error, ios == 0 , " Cannot init test_is_regular_file : " // trim (msg))
123
+ call check(error, ios == 0 , " Cannot init test_is_file : " // trim (msg))
124
124
if (allocated (error)) return
125
125
126
- is_file = is_regular_file (filename)
127
- call check(error, is_file , " is_regular_file could not identify a file" )
126
+ is_reg_file = is_file (filename)
127
+ call check(error, is_reg_file , " is_file could not identify a file" )
128
128
129
129
if (allocated (error)) then
130
130
! Clean up: remove the file
@@ -137,7 +137,7 @@ subroutine test_is_regular_file(error)
137
137
close (iunit,status= ' delete' ,iostat= ios,iomsg= msg)
138
138
call check(error, ios == 0 , " Cannot delete test file: " // trim (msg))
139
139
if (allocated (error)) return
140
- end subroutine test_is_regular_file
140
+ end subroutine test_is_file
141
141
142
142
subroutine test_exists_dir (error )
143
143
type (error_type), allocatable , intent (out ) :: error
@@ -293,7 +293,7 @@ subroutine test_is_directory_file(error)
293
293
! Create a file
294
294
open (newunit= iunit, file= filename, status= " replace" , iostat= ios, iomsg= msg)
295
295
call check(error, ios == 0 , " Cannot create test file: " // trim (msg))
296
- if (allocated (error)) return
296
+ if (allocated (error)) return
297
297
298
298
! Verify `is_directory` identifies it as not a directory
299
299
result = is_directory(filename)
@@ -303,7 +303,7 @@ subroutine test_is_directory_file(error)
303
303
! Clean up: remove the file
304
304
close (iunit,status= ' delete' ,iostat= ios,iomsg= msg)
305
305
call check(error, ios == 0 , " Cannot delete test file: " // trim (msg))
306
- if (allocated (error)) return
306
+ if (allocated (error)) return
307
307
308
308
end subroutine test_is_directory_file
309
309
@@ -378,10 +378,10 @@ subroutine test_delete_directory(error)
378
378
! Clean up: remove the empty directory
379
379
call execute_command_line(' rmdir ' // filename, exitstat= ios, cmdstat= iocmd, cmdmsg= msg)
380
380
call check(error, ios== 0 .and. iocmd== 0 , ' Cannot cleanup delete_directory test: ' // trim (msg))
381
- if (allocated (error)) return
381
+ if (allocated (error)) return
382
382
383
383
end subroutine test_delete_directory
384
-
384
+
385
385
subroutine test_make_directory (error )
386
386
type (error_type), allocatable , intent (out ) :: error
387
387
type (state_type) :: err
@@ -471,7 +471,7 @@ subroutine test_remove_directory(error)
471
471
call remove_directory(dir_name, err)
472
472
call check(error, err% ok(), ' Could not remove directory: ' // err% print ())
473
473
474
- if (allocated (error)) then
474
+ if (allocated (error)) then
475
475
! clean up: remove the empty directory
476
476
call execute_command_line(' rmdir ' // dir_name, exitstat= ios, cmdstat= iocmd, cmdmsg= msg)
477
477
call check(error, ios== 0 .and. iocmd== 0 , error% message // ' and cannot cleanup make_directory test: ' // trim (msg))
@@ -518,14 +518,14 @@ subroutine test_cwd(error)
518
518
call check(error, err% ok(), ' Could not get current working directory: ' // err% print ())
519
519
if (allocated (error)) return
520
520
521
- call check(error, pwd2 == abs_dir_name, ' Working directory is wrong, &
521
+ call check(error, pwd2 == abs_dir_name, ' Working directory is wrong, &
522
522
& expected: ' // abs_dir_name// " got: " // pwd2)
523
523
if (allocated (error)) return
524
524
525
525
! cleanup: set the cwd back to the initial value
526
526
call set_cwd(pwd1, err)
527
527
call check(error, err% ok(), ' Could not clean up cwd test, could not set the cwd back: ' // err% print ())
528
- if (allocated (error)) then
528
+ if (allocated (error)) then
529
529
! our cwd now is `./test_directory`
530
530
! there is no way of removing the empty test directory
531
531
return
0 commit comments