1
1
program new_test
2
2
use ,intrinsic :: iso_fortran_env, only : stdin= >input_unit, stdout= >output_unit, stderr= >error_unit
3
- use fpm_filesystem, only : is_dir, list_files, exists, windows_path
3
+ use fpm_filesystem, only : is_dir, list_files, exists, windows_path, join_path
4
4
use fpm_strings, only : string_t, operator (.in .)
5
- use fpm_environment, only : run, get_os_type
5
+ use fpm_environment, only : run, get_os_type
6
6
use fpm_environment, only : OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_WINDOWS
7
7
implicit none
8
8
type (string_t), allocatable :: file_names(:)
9
9
integer :: i, j, k
10
- character (len=* ), parameter :: cmdpath = ' build/gfortran_debug/app/fpm '
10
+ character (len= :), allocatable :: cmdpath
11
11
character (len= :),allocatable :: path
12
12
character (len=* ),parameter :: scr = ' fpm_scratch_'
13
13
character (len=* ),parameter :: cmds(* ) = [character (len= 80 ) :: &
@@ -35,6 +35,8 @@ program new_test
35
35
logical ,allocatable :: tally(:)
36
36
logical :: IS_OS_WINDOWS
37
37
write (* ,' (g0:,1x)' )' TEST new SUBCOMMAND (draft):'
38
+
39
+ cmdpath = get_command_path()
38
40
allocate (tally(0 ))
39
41
shortdirs= [character (len= 80 ) :: ' A' ,' B' ,' C' ,' D' ,' E' ,' F' ,' G' ,' BB' ,' CC' ]
40
42
allocate (character (len= 80 ) :: directories(size (shortdirs)))
@@ -44,18 +46,18 @@ program new_test
44
46
! ! o assuming fpm command is in expected path and the new version
45
47
! ! o DOS versus POSIX filenames
46
48
is_os_windows= .false.
47
- select case (get_os_type())
49
+ select case (get_os_type())
48
50
case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
49
51
call execute_command_line(' rm -rf fpm_scratch_*' ,exitstat= estat,cmdstat= cstat,cmdmsg= message)
50
52
path= cmdpath
51
- case (OS_WINDOWS)
53
+ case (OS_WINDOWS)
52
54
path= windows_path(cmdpath)
53
55
is_os_windows= .true.
54
56
call execute_command_line(' rmdir fpm_scratch_* /s /q' ,exitstat= estat,cmdstat= cstat,cmdmsg= message)
55
57
case default
56
58
write (* ,* )' ERROR: unknown OS. Stopping test'
57
59
stop 2
58
- end select
60
+ end select
59
61
do i= 1 ,size (directories)
60
62
directories(i)= scr// trim (shortdirs(i))
61
63
if ( is_dir(trim (directories(i))) ) then
@@ -121,7 +123,7 @@ program new_test
121
123
endif
122
124
123
125
do j= 1 ,size (expected)
124
-
126
+
125
127
expected(j)= scr// expected(j)
126
128
if (is_os_windows) expected(j)= windows_path(expected(j))
127
129
if ( .not. (trim (expected(j)).in .file_names) )then
@@ -137,12 +139,12 @@ program new_test
137
139
enddo TESTS
138
140
139
141
! clean up scratch files; might want an option to leave them for inspection
140
- select case (get_os_type())
142
+ select case (get_os_type())
141
143
case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
142
144
call execute_command_line(' rm -rf fpm_scratch_*' ,exitstat= estat,cmdstat= cstat,cmdmsg= message)
143
- case (OS_WINDOWS)
145
+ case (OS_WINDOWS)
144
146
call execute_command_line(' rmdir fpm_scratch_* /s /q' ,exitstat= estat,cmdstat= cstat,cmdmsg= message)
145
- end select
147
+ end select
146
148
147
149
write (* ,' ("TALLY=",*(g0))' )tally
148
150
if (all (tally))then
@@ -151,5 +153,19 @@ program new_test
151
153
write (* ,* )' FAILED: PASSED=' ,count (tally),' FAILED=' ,count (.not. tally)
152
154
stop 5
153
155
endif
156
+ contains
157
+ function get_command_path () result(command_path)
158
+ character (len= :), allocatable :: command_path
159
+
160
+ type (string_t), allocatable :: files(:)
161
+ integer :: i
154
162
163
+ call list_files(" build" , files)
164
+ do i = 1 , size (files)
165
+ if (index (files(i)% s, " gfortran" ) > 0 ) then
166
+ command_path = join_path(files(i)% s, " app" , " fpm" )
167
+ return
168
+ end if
169
+ end do
170
+ end function
155
171
end program new_test
0 commit comments