@@ -2,6 +2,8 @@ program help_test
2
2
! note hardcoded len=k1 instead of len=: in this test is a work-around a gfortran bug in old
3
3
! pre-v8.3 versions
4
4
use ,intrinsic :: iso_fortran_env, only : stdin= >input_unit, stdout= >output_unit, stderr= >error_unit
5
+ use fpm_filesystem, only : dirname, join_path, exists
6
+ use fpm_environment, only : get_os_type, OS_WINDOWS
5
7
implicit none
6
8
integer :: i, j
7
9
integer :: be, af
@@ -11,7 +13,7 @@ program help_test
11
13
character (len= k1) :: message
12
14
logical ,allocatable :: tally(:)
13
15
! intel-bug!character(len=:),allocatable :: book1(:), book2(:)
14
- character (len= k1),allocatable :: book1(:), book2(:), book3(:)
16
+ character (len= k1),allocatable :: book1(:), book2(:)
15
17
! intel-bug!character(len=:),allocatable :: page1(:)
16
18
character (len= k1),allocatable :: page1(:)
17
19
integer :: lines
@@ -20,58 +22,57 @@ program help_test
20
22
character (len=* ),parameter :: cmds(* ) = [character (len= 80 ) :: &
21
23
! build manual as pieces using various help commands
22
24
! debug version
23
- ' fpm run -- --version ' ,& ! verify fpm version being used
24
- ' fpm run -- --help > fpm_scratch_help.txt' ,&
25
- ' fpm run -- help new >> fpm_scratch_help.txt' ,&
26
- ' fpm run -- help update >> fpm_scratch_help.txt' ,&
27
- ' fpm run -- build --help >> fpm_scratch_help.txt' ,&
28
- ' fpm run -- help run >> fpm_scratch_help.txt' ,&
29
- ' fpm run -- help test >> fpm_scratch_help.txt' ,&
30
- ' fpm run -- help runner >> fpm_scratch_help.txt' ,&
31
- ' fpm run -- help install >> fpm_scratch_help.txt' ,&
32
- ' fpm run -- help list >> fpm_scratch_help.txt' ,&
33
- ' fpm run -- help help >> fpm_scratch_help.txt' ,&
34
- ' fpm run -- --version >> fpm_scratch_help.txt' ,&
35
- ! release version
36
- ' fpm run --release -- --version ' ,& ! verify fpm version being used
37
- ' fpm run --release -- --help > fpm_scratch_help3.txt' ,&
38
- ' fpm run --release -- help new >> fpm_scratch_help3.txt' ,&
39
- ' fpm run --release -- help update >> fpm_scratch_help3.txt' ,&
40
- ' fpm run --release -- build --help >> fpm_scratch_help3.txt' ,&
41
- ' fpm run --release -- help run >> fpm_scratch_help3.txt' ,&
42
- ' fpm run --release -- help test >> fpm_scratch_help3.txt' ,&
43
- ' fpm run --release -- help runner >> fpm_scratch_help3.txt' ,&
44
- ' fpm run --release -- help install >> fpm_scratch_help3.txt' ,&
45
- ' fpm run --release -- help list >> fpm_scratch_help3.txt' ,&
46
- ' fpm run --release -- help help >> fpm_scratch_help3.txt' ,&
47
- ' fpm run --release -- --version >> fpm_scratch_help3.txt' ,&
25
+ ' --version ' ,& ! verify fpm version being used
26
+ ' --help > fpm_scratch_help.txt' ,&
27
+ ' help new >> fpm_scratch_help.txt' ,&
28
+ ' help update >> fpm_scratch_help.txt' ,&
29
+ ' build --help >> fpm_scratch_help.txt' ,&
30
+ ' help run >> fpm_scratch_help.txt' ,&
31
+ ' help test >> fpm_scratch_help.txt' ,&
32
+ ' help runner >> fpm_scratch_help.txt' ,&
33
+ ' help install >> fpm_scratch_help.txt' ,&
34
+ ' help list >> fpm_scratch_help.txt' ,&
35
+ ' help help >> fpm_scratch_help.txt' ,&
36
+ ' --version >> fpm_scratch_help.txt' ,&
48
37
! generate manual
49
- ' fpm run -- help manual > fpm_scratch_manual.txt' ]
38
+ ' help manual > fpm_scratch_manual.txt' ]
50
39
51
40
! 'fpm run >> fpm_scratch_help.txt',&
52
41
! 'fpm run -- --list >> fpm_scratch_help.txt',&
53
42
! 'fpm run -- list --list >> fpm_scratch_help.txt',&
54
43
character (len=* ),parameter :: names(* )= [character (len= 10 ) :: &
55
44
' fpm' ,' new' ,' update' ,' build' ,' run' ,' test' ,' runner' ,' install' ,' list' ,' help' ]
56
- character (len= :),allocatable :: add
45
+ character (len= :), allocatable :: prog
46
+ integer :: length
47
+
48
+ ! FIXME: Super hacky way to get the name of the fpm executable,
49
+ ! it works better than invoking fpm again but should be replaced ASAP.
50
+ call get_command_argument(0 , length= length)
51
+ allocate (character (len= length) :: prog)
52
+ call get_command_argument(0 , prog)
53
+ path = dirname(prog)
54
+ if (get_os_type() == OS_WINDOWS) then
55
+ prog = join_path(path, " .." , " app" , " fpm.exe" )
56
+ if (.not. exists(prog)) then
57
+ prog = join_path(path, " .." , " .." , " app" , " fpm.exe" )
58
+ end if
59
+ else
60
+ prog = join_path(path, " .." , " app" , " fpm" )
61
+ if (.not. exists(prog)) then
62
+ prog = join_path(path, " .." , " .." , " app" , " fpm" )
63
+ end if
64
+ end if
57
65
58
66
write (* ,' (g0:,1x)' )' <INFO>TEST help SUBCOMMAND STARTED'
59
67
if (allocated (tally))deallocate (tally)
60
68
allocate (tally(0 ))
61
69
call wipe(' fpm_scratch_help.txt' )
62
- call wipe(' fpm_scratch_help3.txt' )
63
70
call wipe(' fpm_scratch_manual.txt' )
64
71
65
72
! check that output has NAME SYNOPSIS DESCRIPTION
66
- do j= 1 ,2
67
- if (j.eq. 1 )then
68
- ADD= ' '
69
- else
70
- ADD= ' --release '
71
- endif
72
73
do i= 1 ,size (names)
73
74
write (* ,* )' <INFO>check ' // names(i)// ' for NAME SYNOPSIS DESCRIPTION'
74
- path= ' fpm run ' // add // ' -- help ' // names(i)// ' >fpm_scratch_help.txt'
75
+ path= prog // ' help ' // names(i)// ' >fpm_scratch_help.txt'
75
76
message= ' '
76
77
call execute_command_line(path,exitstat= estat,cmdstat= cstat,cmdmsg= message)
77
78
write (* ,' (*(g0))' )' <INFO>CMD=' ,path,' EXITSTAT=' ,estat,' CMDSTAT=' ,cstat,' MESSAGE=' ,trim (message)
@@ -99,13 +100,12 @@ program help_test
99
100
write (* ,* )' <INFO>have completed ' ,count (tally),' tests'
100
101
call wipe(' fpm_scratch_help.txt' )
101
102
enddo
102
- enddo
103
103
104
104
105
105
! execute the fpm(1) commands
106
106
do i= 1 ,size (cmds)
107
107
message= ' '
108
- path= cmds(i)
108
+ path= prog // cmds(i)
109
109
call execute_command_line(path,exitstat= estat,cmdstat= cstat,cmdmsg= message)
110
110
write (* ,' (*(g0))' )' <INFO>CMD=' ,path,' EXITSTAT=' ,estat,' CMDSTAT=' ,cstat,' MESSAGE=' ,trim (message)
111
111
tally= [tally,all ([estat.eq. 0 ,cstat.eq. 0 ])]
@@ -114,14 +114,11 @@ program help_test
114
114
! compare book written in fragments with manual
115
115
call swallow(' fpm_scratch_help.txt' ,book1)
116
116
call swallow(' fpm_scratch_manual.txt' ,book2)
117
- call swallow(' fpm_scratch_help3.txt' ,book3)
118
117
! get rid of lines from run() which is not on stderr at the moment
119
118
book1= pack (book1,index (book1,' + build/' ).eq. 0 )
120
119
book2= pack (book1,index (book2,' + build/' ).eq. 0 )
121
- book3= pack (book3,index (book3,' + build/' ).eq. 0 )
122
120
write (* ,* )' <INFO>book1 ' ,size (book1), len (book1)
123
121
write (* ,* )' <INFO>book2 ' ,size (book2), len (book2)
124
- write (* ,* )' <INFO>book2 ' ,size (book3), len (book3)
125
122
if (size (book1).ne. size (book2))then
126
123
write (* ,* )' <ERROR>manual and "debug" appended pages are not the same size'
127
124
tally= [tally,.false. ]
@@ -134,18 +131,6 @@ program help_test
134
131
tally= [tally,.true. ]
135
132
endif
136
133
endif
137
- if (size (book3).ne. size (book2))then
138
- write (* ,* )' <ERROR>manual and "release" appended pages are not the same size'
139
- tally= [tally,.false. ]
140
- else
141
- if (all (book3.ne. book2))then
142
- tally= [tally,.false. ]
143
- write (* ,* )' <ERROR>manual and "release" appended pages are not the same'
144
- else
145
- write (* ,* )' <INFO>manual and "release" appended pages are the same'
146
- tally= [tally,.true. ]
147
- endif
148
- endif
149
134
150
135
! overall size of manual
151
136
! chars=size(book2)
@@ -159,19 +144,9 @@ program help_test
159
144
write (* ,* )' <INFO>"debug" manual size in bytes=' ,chars,' lines=' ,lines
160
145
tally= [tally,.true. ]
161
146
endif
162
- chars= sum (len_trim (book3)) ! SUM TRIMMED LENGTH
163
- lines= size (book3)
164
- if ( (chars.lt. 12000 ) .or. (lines.lt. 350 ) )then
165
- write (* ,* )' <ERROR>"release" manual is suspiciously small, bytes=' ,chars,' lines=' ,lines
166
- tally= [tally,.false. ]
167
- else
168
- write (* ,* )' <INFO>"release" manual size in bytes=' ,chars,' lines=' ,lines
169
- tally= [tally,.true. ]
170
- endif
171
147
172
148
write (* ,' ("<INFO>HELP TEST TALLY=",*(g0))' )tally
173
149
call wipe(' fpm_scratch_help.txt' )
174
- call wipe(' fpm_scratch_help3.txt' )
175
150
call wipe(' fpm_scratch_manual.txt' )
176
151
if (all (tally))then
177
152
write (* ,' (*(g0))' )' <INFO>PASSED: all ' ,count (tally),' tests passed '
0 commit comments