Skip to content

Commit 401efe6

Browse files
committed
have new_test.f90 clean up scratch directories
1 parent 3726ca3 commit 401efe6

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

fpm/test/new_test/new_test.f90

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ program new_test
1111
character(len=:),allocatable :: path
1212
character(len=*),parameter :: scr = 'fpm_scratch_'
1313
character(len=*),parameter :: cmds(*) = [character(len=80) :: &
14+
! run a variety of "fpm new" variations and verify expected files are generated
1415
' new', &
1516
' new no-no', &
1617
' new '//scr//'A', &
@@ -38,31 +39,32 @@ program new_test
3839
shortdirs=[character(len=80) :: 'A','B','C','D','E','F','G','BB','CC']
3940
allocate(character(len=80) :: directories(size(shortdirs)))
4041

41-
do i=1,size(directories)
42-
directories(i)=scr//trim(shortdirs(i))
43-
if( is_dir(trim(directories(i))) ) then
44-
write(*,*)'ERROR:',trim( directories(i) ),' already exists'
45-
write(*,*)' you must remove scratch directories before performing this test'
46-
write(*,'(*(g0:,1x))')'directories:',(trim(directories(j)),j=1,size(directories)),'no-no'
47-
stop
48-
endif
49-
enddo
50-
5142
!! SEE IF EXPECTED FILES ARE GENERATED
5243
!! Issues:
5344
!! o assuming fpm command is in expected path and the new version
5445
!! o DOS versus POSIX filenames
5546
is_os_windows=.false.
5647
select case (get_os_type())
5748
case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
49+
call execute_command_line('rm -rf fpm_scratch_*',exitstat=estat,cmdstat=cstat,cmdmsg=message)
5850
path=cmdpath
5951
case (OS_WINDOWS)
6052
path=windows_path(cmdpath)
6153
is_os_windows=.true.
54+
call execute_command_line('rmdir fpm_scratch_* /s /q',exitstat=estat,cmdstat=cstat,cmdmsg=message)
6255
case default
6356
write(*,*)'ERROR: unknown OS. Stopping test'
6457
stop 2
6558
end select
59+
do i=1,size(directories)
60+
directories(i)=scr//trim(shortdirs(i))
61+
if( is_dir(trim(directories(i))) ) then
62+
write(*,*)'ERROR:',trim( directories(i) ),' already exists'
63+
write(*,*)' you must remove scratch directories before performing this test'
64+
write(*,'(*(g0:,1x))')'directories:',(trim(directories(j)),j=1,size(directories)),'no-no'
65+
stop
66+
endif
67+
enddo
6668
! execute the fpm(1) commands
6769
do i=1,size(cmds)
6870
message=''
@@ -134,6 +136,14 @@ program new_test
134136
endif
135137
enddo TESTS
136138

139+
! clean up scratch files; might want an option to leave them for inspection
140+
select case (get_os_type())
141+
case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
142+
call execute_command_line('rm -rf fpm_scratch_*',exitstat=estat,cmdstat=cstat,cmdmsg=message)
143+
case (OS_WINDOWS)
144+
call execute_command_line('rmdir fpm_scratch_* /s /q',exitstat=estat,cmdstat=cstat,cmdmsg=message)
145+
end select
146+
137147
write(*,'("TALLY=",*(g0))')tally
138148
if(all(tally))then
139149
write(*,'(*(g0))')'PASSED: all ',count(tally),' tests passed '

0 commit comments

Comments
 (0)