1
1
program help_test
2
2
use ,intrinsic :: iso_fortran_env, only : stdin= >input_unit, stdout= >output_unit, stderr= >error_unit
3
3
implicit none
4
- integer :: i
4
+ integer :: i, j
5
5
integer :: be, af
6
6
character (len= :),allocatable :: path
7
7
integer :: estat, cstat
8
8
character (len= 256 ) :: message
9
9
logical ,allocatable :: tally(:)
10
10
! intel-bug!character(len=:),allocatable :: book1(:), book2(:)
11
- character (len= 132 ),allocatable :: book1(:), book2(:)
11
+ character (len= 132 ),allocatable :: book1(:), book2(:), book3(:)
12
12
! intel-bug!character(len=:),allocatable :: page1(:)
13
13
character (len= 132 ),allocatable :: page1(:)
14
14
integer :: lines
15
15
integer :: chars
16
16
! run a variety of "fpm help" variations and verify expected files are generated
17
17
character (len=* ),parameter :: cmds(* ) = [character (len= 80 ) :: &
18
18
! build manual as pieces using various help commands
19
+ ! debug version
19
20
' fpm run -- --version ' ,& ! verify fpm version being used
20
21
' fpm run -- --help > fpm_scratch_help.txt' ,&
21
22
' fpm run -- help new >> fpm_scratch_help.txt' ,&
@@ -26,51 +27,70 @@ program help_test
26
27
' fpm run -- help list >> fpm_scratch_help.txt' ,&
27
28
' fpm run -- help help >> fpm_scratch_help.txt' ,&
28
29
' fpm run -- --version >> fpm_scratch_help.txt' ,&
30
+ ! release version
31
+ ' fpm run --release -- --version ' ,& ! verify fpm version being used
32
+ ' fpm run --release -- --help > fpm_scratch_help3.txt' ,&
33
+ ' fpm run --release -- help new >> fpm_scratch_help3.txt' ,&
34
+ ' fpm run --release -- build --help >> fpm_scratch_help3.txt' ,&
35
+ ' fpm run --release -- help run >> fpm_scratch_help3.txt' ,&
36
+ ' fpm run --release -- help test >> fpm_scratch_help3.txt' ,&
37
+ ' fpm run --release -- help runner >> fpm_scratch_help3.txt' ,&
38
+ ' fpm run --release -- help list >> fpm_scratch_help3.txt' ,&
39
+ ' fpm run --release -- help help >> fpm_scratch_help3.txt' ,&
40
+ ' fpm run --release -- --version >> fpm_scratch_help3.txt' ,&
29
41
! generate manual
30
42
' fpm run -- help manual > fpm_scratch_manual.txt' ]
31
43
32
44
! 'fpm run >> fpm_scratch_help.txt',&
33
45
! 'fpm run -- --list >> fpm_scratch_help.txt',&
34
46
! 'fpm run -- list --list >> fpm_scratch_help.txt',&
35
47
character (len=* ),parameter :: names(* )= [character (len= 10 ) :: ' fpm' ,' new' ,' build' ,' run' ,' test' ,' runner' ,' list' ,' help' ]
48
+ character (len= :),allocatable :: add
36
49
37
50
write (* ,' (g0:,1x)' )' <INFO>TEST help SUBCOMMAND STARTED'
38
51
if (allocated (tally))deallocate (tally)
39
52
allocate (tally(0 ))
40
53
call wipe(' fpm_scratch_help.txt' )
54
+ call wipe(' fpm_scratch_help3.txt' )
41
55
call wipe(' fpm_scratch_manual.txt' )
42
56
43
57
! check that output has NAME SYNOPSIS DESCRIPTION
44
- do i= 1 ,size (names)
45
- write (* ,* )' <INFO>check ' // names(i)// ' for NAME SYNOPSIS DESCRIPTION'
46
- path= ' fpm run -- help ' // names(i)// ' >fpm_scratch_help.txt'
47
- message= ' '
48
- call execute_command_line(path,exitstat= estat,cmdstat= cstat,cmdmsg= message)
49
- write (* ,' (*(g0))' )' <INFO>CMD=' ,path,' EXITSTAT=' ,estat,' CMDSTAT=' ,cstat,' MESSAGE=' ,trim (message)
50
- tally= [tally,all ([estat.eq. 0 ,cstat.eq. 0 ])]
51
- call swallow(' fpm_scratch_help.txt' ,page1)
52
- if (size (page1).lt. 3 )then
53
- write (* ,* )' <ERROR>help for ' // names(i)// ' ridiculiously small'
54
- tally= [tally,.false. ]
55
- exit
56
- endif
57
- ! !write(*,*)findloc(page1,'NAME').eq.1
58
- be= count (.not. tally)
59
- tally= [tally,count (page1.eq. ' NAME' ).eq. 1 ]
60
- tally= [tally,count (page1.eq. ' SYNOPSIS' ).eq. 1 ]
61
- tally= [tally,count (page1.eq. ' DESCRIPTION' ).eq. 1 ]
62
- af= count (.not. tally)
63
- if (be.ne. af)then
64
- write (* ,* )' <ERROR>missing expected sections in ' ,names(i)
65
- write (* ,* )page1(1 ) ! assuming at least size 1 for debugging mingw
66
- write (* ,* )count (page1.eq. ' NAME' )
67
- write (* ,* )count (page1.eq. ' SYNOPSIS' )
68
- write (* ,* )count (page1.eq. ' DESCRIPTION' )
69
- write (* ,' (a)' )page1
58
+ do j= 1 ,2
59
+ if (j.eq. 1 )then
60
+ ADD= ' '
61
+ else
62
+ ADD= ' --release '
70
63
endif
71
- write (* ,* )' <INFO>have completed ' ,count (tally),' tests'
72
- call wipe(' fpm_scratch_help.txt' )
73
- call wipe(' fpm_scratch_manual.txt' )
64
+ do i= 1 ,size (names)
65
+ write (* ,* )' <INFO>check ' // names(i)// ' for NAME SYNOPSIS DESCRIPTION'
66
+ path= ' fpm run ' // add// ' -- help ' // names(i)// ' >fpm_scratch_help.txt'
67
+ message= ' '
68
+ call execute_command_line(path,exitstat= estat,cmdstat= cstat,cmdmsg= message)
69
+ write (* ,' (*(g0))' )' <INFO>CMD=' ,path,' EXITSTAT=' ,estat,' CMDSTAT=' ,cstat,' MESSAGE=' ,trim (message)
70
+ tally= [tally,all ([estat.eq. 0 ,cstat.eq. 0 ])]
71
+ call swallow(' fpm_scratch_help.txt' ,page1)
72
+ if (size (page1).lt. 3 )then
73
+ write (* ,* )' <ERROR>help for ' // names(i)// ' ridiculiously small'
74
+ tally= [tally,.false. ]
75
+ exit
76
+ endif
77
+ ! !write(*,*)findloc(page1,'NAME').eq.1
78
+ be= count (.not. tally)
79
+ tally= [tally,count (page1.eq. ' NAME' ).eq. 1 ]
80
+ tally= [tally,count (page1.eq. ' SYNOPSIS' ).eq. 1 ]
81
+ tally= [tally,count (page1.eq. ' DESCRIPTION' ).eq. 1 ]
82
+ af= count (.not. tally)
83
+ if (be.ne. af)then
84
+ write (* ,* )' <ERROR>missing expected sections in ' ,names(i)
85
+ write (* ,* )page1(1 ) ! assuming at least size 1 for debugging mingw
86
+ write (* ,* )count (page1.eq. ' NAME' )
87
+ write (* ,* )count (page1.eq. ' SYNOPSIS' )
88
+ write (* ,* )count (page1.eq. ' DESCRIPTION' )
89
+ write (* ,' (a)' )page1
90
+ endif
91
+ write (* ,* )' <INFO>have completed ' ,count (tally),' tests'
92
+ call wipe(' fpm_scratch_help.txt' )
93
+ enddo
74
94
enddo
75
95
76
96
@@ -86,20 +106,35 @@ program help_test
86
106
! compare book written in fragments with manual
87
107
call swallow(' fpm_scratch_help.txt' ,book1)
88
108
call swallow(' fpm_scratch_manual.txt' ,book2)
109
+ call swallow(' fpm_scratch_help3.txt' ,book3)
89
110
! get rid of lines from run() which is not on stderr at the moment
90
111
book1= pack (book1,index (book1,' + build/' ).eq. 0 )
91
112
book2= pack (book1,index (book2,' + build/' ).eq. 0 )
113
+ book3= pack (book3,index (book3,' + build/' ).eq. 0 )
92
114
write (* ,* )' <INFO>book1 ' ,size (book1), len (book1)
93
115
write (* ,* )' <INFO>book2 ' ,size (book2), len (book2)
116
+ write (* ,* )' <INFO>book2 ' ,size (book3), len (book3)
94
117
if (size (book1).ne. size (book2))then
95
- write (* ,* )' <ERROR>manual and appended pages are not the same size'
118
+ write (* ,* )' <ERROR>manual and "debug" appended pages are not the same size'
96
119
tally= [tally,.false. ]
97
120
else
98
121
if (all (book1.ne. book2))then
99
122
tally= [tally,.false. ]
100
- write (* ,* )' <ERROR>manual and appended pages are not the same'
123
+ write (* ,* )' <ERROR>manual and "debug" appended pages are not the same'
101
124
else
102
- write (* ,* )' <INFO>manual and appended pages are the same'
125
+ write (* ,* )' <INFO>manual and "debug" appended pages are the same'
126
+ tally= [tally,.true. ]
127
+ endif
128
+ endif
129
+ if (size (book3).ne. size (book2))then
130
+ write (* ,* )' <ERROR>manual and "release" appended pages are not the same size'
131
+ tally= [tally,.false. ]
132
+ else
133
+ if (all (book3.ne. book2))then
134
+ tally= [tally,.false. ]
135
+ write (* ,* )' <ERROR>manual and "release" appended pages are not the same'
136
+ else
137
+ write (* ,* )' <INFO>manual and "release" appended pages are the same'
103
138
tally= [tally,.true. ]
104
139
endif
105
140
endif
@@ -110,15 +145,25 @@ program help_test
110
145
chars= size (book2)* len (book2)
111
146
lines= size (book2)
112
147
if ( (chars.lt. 13000 ) .or. (lines.lt. 350 ) )then
113
- write (* ,* )' <ERROR>manual is suspiciously small, bytes=' ,chars,' lines=' ,lines
148
+ write (* ,* )' <ERROR>"debug" manual is suspiciously small, bytes=' ,chars,' lines=' ,lines
149
+ tally= [tally,.false. ]
150
+ else
151
+ write (* ,* )' <INFO>"debug" manual size is bytes=' ,chars,' lines=' ,lines
152
+ tally= [tally,.true. ]
153
+ endif
154
+ chars= size (book3)* len (book3)
155
+ lines= size (book3)
156
+ if ( (chars.lt. 13000 ) .or. (lines.lt. 350 ) )then
157
+ write (* ,* )' <ERROR>"release" manual is suspiciously small, bytes=' ,chars,' lines=' ,lines
114
158
tally= [tally,.false. ]
115
159
else
116
- write (* ,* )' <INFO>manual size is bytes=' ,chars,' lines=' ,lines
160
+ write (* ,* )' <INFO>"release" manual size is bytes=' ,chars,' lines=' ,lines
117
161
tally= [tally,.true. ]
118
162
endif
119
163
120
164
write (* ,' ("<INFO>HELP TEST TALLY=",*(g0))' )tally
121
165
call wipe(' fpm_scratch_help.txt' )
166
+ call wipe(' fpm_scratch_help3.txt' )
122
167
call wipe(' fpm_scratch_manual.txt' )
123
168
if (all (tally))then
124
169
write (* ,' (*(g0))' )' <INFO>PASSED: all ' ,count (tally),' tests passed '
@@ -249,7 +294,13 @@ function page(array) result (table)
249
294
position= 1
250
295
elseif (array(i).eq. cr)then
251
296
elseif (linelength.ne. 0 )then
252
- table(linecount)(position:position)= array(i)
297
+ if (position.gt. len (table))then
298
+ write (* ,* )' <ERROR> adding character past edge of text' ,table(linecount),array(i)
299
+ elseif (linecount.gt. size (table))then
300
+ write (* ,* )' <ERROR> adding line past end of text' ,linecount,size (table)
301
+ else
302
+ table(linecount)(position:position)= array(i)
303
+ endif
253
304
position= position+1
254
305
endif
255
306
enddo
0 commit comments